Whamcloud - gitweb
Add handling for invalid option characters in debugfs subcommands
authorTheodore Ts'o <tytso@mit.edu>
Fri, 28 Apr 2006 00:59:42 +0000 (20:59 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 28 Apr 2006 00:59:42 +0000 (20:59 -0400)
Fix the debugfs commands htree_dump, dx_hash, and list_dir so they print a
print a usage message when an illegal option character is given.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/ChangeLog
debugfs/htree.c
debugfs/ls.c

index d71f6d8..a9fb8a4 100644 (file)
@@ -1,3 +1,10 @@
+2006-04-27  Theodore Ts'o  <tytso@mit.edu>
+
+       * htree.c (do_htree_dump, do_dx_hash), ls.c (do_list_dir): Add
+               missing default case in the getopt() while/switch loop so
+               that we print a usage() statement when the user specified
+               an illegal option.
+
 2006-03-18  Theodore Ts'o  <tytso@mit.edu>
 
        * debugfs.c, htree.c, unused.c: Change printf statements to use
index 6dbe426..a266cb3 100644 (file)
@@ -197,10 +197,13 @@ void do_htree_dump(int argc, char *argv[])
                case 'l':
                        long_opt++;
                        break;
+               default:
+                       goto print_usage;
                }
        }
 
        if (argc > optind+1) {
+       print_usage:
                com_err(0, 0, "Usage: htree_dump [-l] file");
                goto errout;
        }
@@ -279,9 +282,12 @@ void do_dx_hash(int argc, char *argv[])
                case 'h':
                        hash_version = atoi(optarg);
                        break;
+               default:
+                       goto print_usage;
                }
        }
        if (optind != argc-1) {
+       print_usage:
                com_err(argv[0], 0, "usage: dx_hash filename");
                return;
        }
index f1c52c9..8e97ce8 100644 (file)
@@ -131,10 +131,13 @@ void do_list_dir(int argc, char *argv[])
                case 'd':
                        ls.options |= DELETED_OPT;
                        break;
+               default:
+                       goto print_usage;
                }
        }
 
        if (argc > optind+1) {
+       print_usage:
                com_err(0, 0, "Usage: ls [-l] [-d] file");
                return;
        }