mtd/util ftl_check.c,1.3,1.4

gleixner at infradead.org gleixner at infradead.org
Wed May 5 17:44:21 EDT 2004


Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv8661

Modified Files:
	ftl_check.c 
Log Message:
add -h and explain -v

Index: ftl_check.c
===================================================================
RCS file: /home/cvs/mtd/util/ftl_check.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ftl_check.c	5 May 2004 11:57:55 -0000	1.3
+++ ftl_check.c	5 May 2004 21:44:18 -0000	1.4
@@ -163,6 +163,13 @@
     }
 } /* format_partition */
 
+/* Show usage information */
+void showusage(char *pname)
+{
+	fprintf(stderr, "usage: %s [-v] device\n", pname);
+	fprintf(stderr, "-v verbose messages\n");
+}
+
 /*====================================================================*/
 
 int main(int argc, char *argv[])
@@ -173,17 +180,19 @@
     
     errflg = 0;
     verbose = 0;
-    while ((optch = getopt(argc, argv, "v")) != -1) {
+    while ((optch = getopt(argc, argv, "vh")) != -1) {
 	switch (optch) {
+	case 'h':
+	    errflg = 1; break;
 	case 'v':
 	    verbose = 1; break;
 	default:
-	    errflg = 1; break;
+	    errflg = -1; break;
 	}
     }
     if (errflg || (optind != argc-1)) {
-	fprintf(stderr, "usage: %s [-v] device\n", argv[0]);
-	exit(EXIT_FAILURE);
+	showusage(argv[0]);
+	exit(errflg > 0 ? 0 : EXIT_FAILURE);
     }
 
     if (stat(argv[optind], &buf) != 0) {




More information about the linux-mtd-cvs mailing list