[U-Boot] [PATCH] tools/mkimage: use lseek rather than fstat for file size for -l option
Peter Korsgaard
jacmet at sunsite.dk
Wed Dec 3 08:43:52 CET 2008
>>>>> "Wolfgang" == Wolfgang Denk <wd at denx.de> writes:
Hi,
Wolfgang> Hm... but lseek() on /dev/mtdblockN will return the size of
Wolfgang> the MTD device, not of the image that may be stored in it,
Wolfgang> right?
Yes.
Wolfgang> Later, you should get data checksum errors because of the
Wolfgang> incorrect lenght, i. e. a ``ERROR: "<image>" has
Wolfgang> corrupted data!'' error message.
Exactly, hence my other patch (tools/mkimage: ignore trailing garbage)
to only error out if the size is smaller than the size defined in the
header.
Wolfgang> I don't think this works.
>> - if (fstat(ifd, &sbuf) < 0) {
>> - fprintf (stderr, "%s: Can't stat %s: %s\n",
>> + sbuf.st_size = lseek(ifd, 0, SEEK_END);
>> + if (sbuf.st_size == (off_t)-1) {
>> + fprintf (stderr, "%s: Can't get size of %s: %s\n",
Wolfgang> If you don't use *stat(), you should not use any struct
Wolfgang> stat type either.
Ok, I kept it like that to keep the patch as minimal as possible -
I'll change it and resend.
--
Bye, Peter Korsgaard
More information about the U-Boot
mailing list