>>>>> "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.
Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
tools/mkimage.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 58fd20f..aec74ab 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -205,8 +205,9 @@ NXTARG: ;
/*
* list header information of existing image
*/
- 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",
cmdname, imagefile, strerror(errno));
exit (EXIT_FAILURE);
}
--
1.5.6.5
--
Bye, Peter Korsgaard
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot