[U-Boot] [PATCH v2 5/7] tools: add padding of data image file for imximage

Marek Vasut marex at denx.de
Tue Aug 13 07:10:17 CEST 2013


Dear Stefano Babic,

> Implement function vrec_header to be able to pad the final
> data image file according the what has been calculated for
> boot_data.length.
> 
> Signed-off-by: Stefano Babic <sbabic at denx.de>
> ---

[...]

> +	if (!imxhdr) {
> +		fprintf(stderr, "%s: malloc return failure: %s\n",
> +			params->cmdname, strerror(errno));
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	memset(imxhdr, 0, alloc_len);
> +
> +	tparams->header_size = alloc_len;
> +	tparams->hdr         = imxhdr;
> +
> +	/* determine data image file length */

Why dont you just call stat(2) here instead of the open+fstat+close combo?

> +	dfd = open(datafile, O_RDONLY|O_BINARY);
> +	if (dfd < 0) {
> +		fprintf(stderr, "%s: Can't open %s: %s\n",
> +			params->cmdname, datafile, strerror(errno));
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	if (fstat(dfd, &sbuf) < 0) {
> +		fprintf(stderr, "%s: Can't stat %s: %s\n",
> +			params->cmdname, datafile, strerror(errno));
> +		exit(EXIT_FAILURE);
> +	}
> +
> +	pad_len = ROUND(sbuf.st_size, 4096) - sbuf.st_size;
> +
> +	close(dfd);
> +
> +	/* TODO: check i.MX image V1 handling, for now use 'old' style */

[...]

Best regards,
Marek Vasut


More information about the U-Boot mailing list