diff options
author | Neil Brown <neilb@suse.de> | 2005-12-05 05:54:33 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-12-05 05:54:33 +0000 |
commit | c06487ce2061b7acfe6bc40bea7ad12393b0e4c6 (patch) | |
tree | a6aed423f10c74af40acd662ef09d060123904b7 /mdadm.c | |
parent | 8b0dabea0762e2cd786c1539845823ecd914657a (diff) | |
download | mdadm-c06487ce2061b7acfe6bc40bea7ad12393b0e4c6.tar.gz mdadm-c06487ce2061b7acfe6bc40bea7ad12393b0e4c6.tar.xz mdadm-c06487ce2061b7acfe6bc40bea7ad12393b0e4c6.zip |
Improve option parsing
stuff
====Do Not Remove====
Status: ok
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -93,6 +93,7 @@ int main(int argc, char *argv[]) struct supertype *ss = NULL; int writemostly = 0; int re_add = 0; + char *shortopt = short_options; int copies; @@ -113,7 +114,7 @@ int main(int argc, char *argv[]) while ((option_index = -1) , (opt=getopt_long(argc, argv, - short_options, long_options, + shortopt, long_options, &option_index)) != -1) { int newmode = mode; /* firstly, some mode-independant options */ @@ -150,6 +151,10 @@ int main(int argc, char *argv[]) if (mode == ASSEMBLE || mode == BUILD || mode == CREATE || mode == GROW) break; /* b means bitmap */ brief = 1; + if (optarg) { + fprintf(stderr, Name ": -b cannot have any extra immediately after it, sorry.\n"); + exit(2); + } continue; case ':': @@ -164,19 +169,24 @@ int main(int argc, char *argv[]) switch(opt) { case '@': /* just incase they say --manage */ - newmode = MANAGE; break; + newmode = MANAGE; + shortopt = short_bitmap_auto_options; + break; case 'a': case 'r': case 'f': case 6: /* re-add */ - if (!mode) newmode = MANAGE; + if (!mode) { + newmode = MANAGE; + shortopt = short_bitmap_auto_options; + } break; - case 'A': newmode = ASSEMBLE; break; - case 'B': newmode = BUILD; break; - case 'C': newmode = CREATE; break; + case 'A': newmode = ASSEMBLE; shortopt = short_bitmap_auto_options; break; + case 'B': newmode = BUILD; shortopt = short_bitmap_auto_options; break; + case 'C': newmode = CREATE; shortopt = short_bitmap_auto_options; break; case 'F': newmode = MONITOR;break; - case 'G': newmode = GROW; break; + case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break; case '#': case 'D': |