Dear Peter Korsgaard, In message <[EMAIL PROTECTED]> you wrote: > >>>>> "Thomas" == Thomas De Schampheleire <[EMAIL PROTECTED]> writes: > > Thomas> I'd change the error message as well, to be independent of the tool > Thomas> used to get the file size. For example: > Thomas> fprintf (stderr, "%s: Can't get size of %s: %s\n", > > Ahh yes, good idea. > > From d7c4cb9f290e22d3fc97e43816158c9fd744200c Mon Sep 17 00:00:00 2001 > From: Peter Korsgaard <[EMAIL PROTECTED]> > Date: Mon, 1 Dec 2008 17:13:17 +0100 > Subject: [PATCH] tools/mkimage: use lseek rather than fstat for file size for > -l option > > Use lseek rather than fstat for file size for list mode, so > mkimage -l /dev/mtdblockN works (stat returns st_size == 0 for devices). > > Notice that you have to use /dev/mtdblockN and not /dev/mtdN, as the > latter doesn't support mmap.
Hm... but lseek() on /dev/mtdblockN will return the size of the MTD device, not of the image that may be stored in it, right? Later, you should get data checksum errors because of the incorrect lenght, i. e. a ``ERROR: "<image>" has corrupted data!'' error message. 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", If you don't use *stat(), you should not use any struct stat type either. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED] Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot