
Dear Peter Korsgaard,
In message 87vdu2tka2.fsf@macbook.be.48ers.dk you wrote:
"Thomas" == Thomas De Schampheleire patrickdepinguin@gmail.com 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 jacmet@sunsite.dk 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