]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix parsing of "-a" in various contexts.
authorDoug Ledford <dledford@redhat.com>
Sun, 8 Jul 2007 23:59:59 +0000 (09:59 +1000)
committerNeil Brown <neilb@suse.de>
Sun, 8 Jul 2007 23:59:59 +0000 (09:59 +1000)
From: Doug Ledford <dledford@redhat.com>

This one fixes a bug where once manage mode is set, the -a short option
is no longer parsed correctly (true of grow mode as well).  This happens
because when you switch the short opts to the bitmap_auto version, it
specifies that the argument must follow a, yet the loop expects to get
an undecorated option and parse it as the disk dev instead of trying to
parse optarg.  So, create a new short opt array that is used for manage
and grow that doesn't list a as having an argument.

ReadMe.c
mdadm.c
mdadm.h

index 9423db3264f28a66a65d14479b311416bb7b4b2a..201651eb5fdb104258abced164570067646f956f 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -87,6 +87,8 @@ char Version[] = Name " - v2.6.2 - 21st May 2007\n";
  */
 
 char short_options[]="-ABCDEFGIQhVXWvqbc:i:l:p:m:n:x:u:c:d:z:U:sarfRSow1tye:";
+char short_bitmap_options[]=
+                   "-ABCDEFGIQhVXWvqb:c:i:l:p:m:n:x:u:c:d:z:U:sarfRSow1tye:";
 char short_bitmap_auto_options[]=
                    "-ABCDEFGIQhVXWvqb:c:i:l:p:m:n:x:u:c:d:z:U:sa:rfRSow1tye:";
 
diff --git a/mdadm.c b/mdadm.c
index 069c6d6dba0e6ec7babef81ea49d2af6ad088513..e96ce68aa41e2980a1b0a161cd9ab04063c76b77 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
                switch(opt) {
                case '@': /* just incase they say --manage */
                        newmode = MANAGE;
-                       shortopt = short_bitmap_auto_options;
+                       shortopt = short_bitmap_options;
                        break;
                case 'a':
                case 'r':
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
                case ReAdd: /* re-add */
                        if (!mode) {
                                newmode = MANAGE;
-                               shortopt = short_bitmap_auto_options;
+                               shortopt = short_bitmap_options;
                        }
                        break;
 
@@ -196,7 +196,9 @@ int main(int argc, char *argv[])
                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; shortopt = short_bitmap_auto_options; break;
+               case 'G': newmode = GROW;
+                       shortopt = short_bitmap_options;
+                       break;
                case 'I': newmode = INCREMENTAL; break;
                case AutoDetect:
                        newmode = AUTODETECT; break;
diff --git a/mdadm.h b/mdadm.h
index 2ecd9fc1c5fa538cb45b867cf0e7a53ea1003e36..ac7d4b47430404e34837b085393d771f405c1ef3 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -155,6 +155,7 @@ enum mode {
 };
 
 extern char short_options[];
+extern char short_bitmap_options[];
 extern char short_bitmap_auto_options[];
 extern struct option long_options[];
 extern char Version[], Usage[], Help[], OptionHelp[],