]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Change handling of devices names in args
authorNeil Brown <neilb@suse.de>
Mon, 4 Apr 2005 05:18:57 +0000 (05:18 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 4 Apr 2005 05:18:57 +0000 (05:18 +0000)
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
ChangeLog
Query.c
mdadm.c

index d9d3b0635521d8e19b5a243a9c0a7a3dbab2b3e1..7e03a5c04645794d25a0e182eb4565c76e4f5c2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,10 @@ Changes Prior to 1.9.0 release
     -   Make "mdadm -Ss" stop stacked devices properly, by reversing the
        order in which arrays are stopped.
     -   Improve some error messages.
+    -   Allow device name to appear before first option, so e.g.
+       mdadm /dev/md0 -A /dev/sd[ab]
+       works.
+    -   Assume '-Q' if just a device is given, rather than being silent.
 
 Changes Prior to 1.8.0 release
     -   Makefile cleanup from  Luca Berra <bluca@comedia.it>
diff --git a/Query.c b/Query.c
index 3f58c8b8150570206d752a11d2e3504673f50794..95d69147a0591b9186ada05aaa5f7d96a33e2182 100644 (file)
--- a/Query.c
+++ b/Query.c
@@ -124,7 +124,7 @@ int Query(char *dev)
                /* array might be active... */
                mddev = get_md_name(super.md_minor);
                disc.number = super.this_disk.number;
-               activity = "inactive";
+               activity = "undetected";
                if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
                        if (md_get_version(fd) >= 9000 &&       
                            ioctl(fd, GET_ARRAY_INFO, &array)>= 0) {
diff --git a/mdadm.c b/mdadm.c
index 868a48b2959b3a7d7866979d7c400e2c0babf8a7..daf24123ab40d430a71540da078170001b92fbc9 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -145,7 +145,8 @@ int main(int argc, char *argv[])
                case 'a':
                case 'r':
                case 'f':
-               case 1 : if (!mode) newmode = MANAGE; break;
+                       if (!mode) newmode = MANAGE; 
+                       break;
 
                case 'A': newmode = ASSEMBLE; break;
                case 'B': newmode = BUILD; break;
@@ -186,11 +187,33 @@ int main(int argc, char *argv[])
                                fputs(Help_config, stderr);
                                exit(0);
                        }
+
+                       /* If first option is a device, don't force the mode yet */
+                       if (opt == 1) {
+                               if (devs_found == 0) {
+                                       dv = malloc(sizeof(*dv));
+                                       if (dv == NULL) {
+                                               fprintf(stderr, Name ": malloc failed\n");
+                                               exit(3);
+                                       }
+                                       dv->devname = optarg;
+                                       dv->disposition = devmode;
+                                       dv->next = NULL;
+                                       *devlistend = dv;
+                                       devlistend = &dv->next;
+                       
+                                       devs_found++;
+                                       continue;
+                               }
+                               /* No mode yet, and this is the second device ... */
+                               fprintf(stderr, Name ": An option must be given to set the mode before a second device is listed\n");
+                               exit(2);
+                       }
                        if (option_index >= 0)
-                               fprintf(stderr, "--%s", long_options[option_index].name);
+                               fprintf(stderr, Name ": --%s", long_options[option_index].name);
                        else
-                               fprintf(stderr, "-%c", opt);
-                       fprintf(stderr, " does not set the mode, and so cannot be first.\n");
+                               fprintf(stderr, Name ": -%c", opt);
+                       fprintf(stderr, " does not set the mode, and so cannot be the first option.\n");
                        exit(2);
                }
 
@@ -645,6 +668,12 @@ int main(int argc, char *argv[])
 
        }
 
+       if (!mode && devs_found) {
+               mode = MISC;
+               devmode = 'Q';
+               if (devlist->disposition == 0)
+                       devlist->disposition = devmode;
+       }
        if (!mode) {
                fputs(Usage, stderr);
                exit(2);