[PATCH 3/6] [MTD-UTILS] nandwrite: Pass Real Names as Arguments to perror

Grant Erickson gerickson at nuovations.com
Mon Sep 8 00:28:56 EDT 2008


Pass the MTD device node and input file name as arguments to perror
rather than more ambigous, static messages on open failures.

Signed-off-by: Grant Erickson <gerickson at nuovations.com>
---
This change results in more meaningful error messages when there is an
error with the MTD device node and input file positional parameters:

	# nandwrite /dev/foobar
	/dev/foobar: No such file or directory

versus:

	# nandwrite /dev/foobar vmlinux
	open flash: No such file or directory

or:

	# nandwrite /dev/mtd8 foobar  
	open input file: No such file or directory

versus:

	# ./nandwrite /dev/mtd8 foobar
	foobar: No such file or directory

 nandwrite.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/nandwrite.c b/nandwrite.c
index b1a4307..e5de140 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -230,7 +230,7 @@ int main(int argc, char * const argv[])
 
 	/* Open the device */
 	if ((fd = open(mtd_device, O_RDWR)) == -1) {
-		perror("open flash");
+		perror(mtd_device);
 		exit (EXIT_FAILURE);
 	}
 
@@ -337,7 +337,7 @@ int main(int argc, char * const argv[])
 
 	/* Open the input file */
 	if ((ifd = open(img, O_RDONLY)) == -1) {
-		perror("open input file");
+		perror(img);
 		goto restoreoob;
 	}
 
-- 
1.6.0.1




More information about the linux-mtd mailing list