]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Give suitable error for mdadm /dev/md0 --stop
authorNeilBrown <neilb@suse.de>
Tue, 10 May 2011 06:30:40 +0000 (16:30 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 10 May 2011 06:30:40 +0000 (16:30 +1000)
Options like --stop must come before the device that is being
stopped.  If (in --misc mode) a  device does not have an option,
nothing will be done to it, which can be confusing.
So report an error in this case.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index 96d32b53059f0f5dac98ab8ae4e103ae977e3b75..662822d1c50dc43df806765fa905ce9d076ad7de 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -253,6 +253,12 @@ int main(int argc, char *argv[])
                        exit(2);
                } else if (!mode && newmode) {
                        mode = newmode;
+                       if (mode == MISC && devs_found) {
+                               fprintf(stderr, Name ": No action given for %s in --misc mode\n",
+                                       devlist->devname);
+                               fprintf(stderr,"       Action options must come before device names\n");
+                               exit(2);
+                       }
                } else {
                        /* special case of -c --help */
                        if ((opt == 'c' || opt == ConfigFile) &&