]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix oddity where mdadm did not recognise a relative path
authorWol <anthony@youngman.org.uk>
Tue, 17 Jan 2017 17:47:05 +0000 (17:47 +0000)
committerJes Sorensen <Jes.Sorensen@gmail.com>
Sun, 29 Jan 2017 17:45:20 +0000 (12:45 -0500)
mdadm assumed that a pathname started with a "/", while an array
name didn't. This alters the logic so that if the first character
is not a "/" it tries to open an array, and if that fails it drops
through to the pathname code rather than terminating immediately
with an error.

Signed-off-by: Wol <anthony@youngman.org.uk>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index c3a265b80947bfee847d4de53e1f2d920d6e3664..b5d89e4355c6d04dd48aba4808a1f1f0964b0ae8 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1899,12 +1899,12 @@ static int misc_list(struct mddev_dev *devlist,
                        rv |= SetAction(dv->devname, c->action);
                        continue;
                }
-               if (dv->devname[0] == '/')
-                       mdfd = open_mddev(dv->devname, 1);
-               else {
-                       mdfd = open_dev(dv->devname);
-                       if (mdfd < 0)
-                               pr_err("Cannot open %s\n", dv->devname);
+               switch(dv->devname[0] == '/') {
+                       case 0:
+                               mdfd = open_dev(dv->devname);
+                               if (mdfd >= 0) break;
+                       case 1:
+                               mdfd = open_mddev(dv->devname, 1);  
                }
                if (mdfd>=0) {
                        switch(dv->disposition) {