tools/firmware-utils/src/mkfwimage.c
/**
 * Checks the availability and validity of all image components.
 * Fills in stats member of the part_data structure.
 */
Checks the availability and validity of all image components.
Fills in stats member of the part_data structure.
Checks the availability and validity of all image components . Fills in stats member of the part_data structure .
static int validate_image_layout(image_info_t* im)
{
	int i;
	if (im->part_count == 0 || im->part_count > MAX_SECTIONS)
	{
		ERROR("Invalid part count '%d'\n", im->part_count);
		return -1;
	}
	for (i = 0; i < im->part_count; ++i)
	{
		part_data_t* d = &im->parts[i];
		int len = strlen(d->partition_name);
		if (len == 0 || len > 16)
		{
			ERROR("Invalid partition name '%s' of the part %d\n",
					d->partition_name, i);
			return -1;
		}
		if (stat(d->filename, &d->stats) < 0)
		{
			ERROR("Couldn't stat file '%s' from part '%s'\n",
				       	d->filename, d->partition_name);
			return -2;
		}
		if (d->stats.st_size == 0)
		{
			ERROR("File '%s' from part '%s' is empty!\n",
				       	d->filename, d->partition_name);
			return -3;
		}
		if (d->stats.st_size > d->partition_length) {
			ERROR("File '%s' too big (%d) - max size: 0x%08X (exceeds %lu bytes)\n",
				       	d->filename, i, d->partition_length,
					d->stats.st_size - d->partition_length);
			return -4;
		}
	}
	return 0;
}
static int validate_image_layout ( image_info_t * im ) { int i ; if ( im -> part_count == 0 || im -> part_count > MAX_SECTIONS ) { ERROR ( " \n " , im -> part_count ) ; return -1 ; } for ( i = 0 ; i < im -> part_count ; ++ i ) { part_data_t * d = & im -> parts [ i ] ; int len = strlen ( d -> partition_name ) ; if ( len == 0 || len > 16 ) { ERROR ( " \n " , d -> partition_name , i ) ; return -1 ; } if ( stat ( d -> filename , & d -> stats ) < 0 ) { ERROR ( " \n " , d -> filename , d -> partition_name ) ; return -2 ; } if ( d -> stats . st_size == 0 ) { ERROR ( " \n " , d -> filename , d -> partition_name ) ; return -3 ; } if ( d -> stats . st_size > d -> partition_length ) { ERROR ( " \n " , d -> filename , i , d -> partition_length , d -> stats . st_size - d -> partition_length ) ; return -4 ; } } return 0 ; }
Checks the availability and validity of all image components.
Checks the availability and validity of all image components .