]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
misc_scan: don't trust the mapping file too much for device names.
authorNeilBrown <neilb@suse.de>
Mon, 13 May 2013 02:56:38 +0000 (12:56 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 13 May 2013 02:56:38 +0000 (12:56 +1000)
misc_scan assumes that any device name found in the 'mapping' file
is usable.  Usually it is but sometimes not, such as for inactive
devices.
Depending on it isn't really robust, when a name is found, check that
it exists. If not, fall back on map_dev.

This will allow "--detail --scan" to notice inactive devices.

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

diff --git a/mdadm.c b/mdadm.c
index c4c5f2948d950104983cb74f61abdf08bc83dd06..e053db599fe2b0d245e871057dd7e9f284c16e1b 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1645,8 +1645,9 @@ static int misc_scan(char devmode, struct context *c)
 
        for (members = 0; members <= 1; members++) {
                for (e=ms ; e ; e=e->next) {
-                       char *name;
+                       char *name = NULL;
                        struct map_ent *me;
+                       struct stat stb;
                        int member = e->metadata_version &&
                                strncmp(e->metadata_version,
                                        "external:/", 10) == 0;
@@ -1656,7 +1657,8 @@ static int misc_scan(char devmode, struct context *c)
                        if (me && me->path
                            && strcmp(me->path, "/unknown") != 0)
                                name = me->path;
-                       else
+                       if (name == NULL ||
+                           stat(name, &stb) != 0)
                                name = get_md_name(e->devnm);
 
                        if (!name) {