From: NeilBrown Date: Mon, 13 May 2013 02:56:38 +0000 (+1000) Subject: misc_scan: don't trust the mapping file too much for device names. X-Git-Tag: mdadm-3.3-rc1~82 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=743eaf8b70501c64c58ad56b435873bf788c878b misc_scan: don't trust the mapping file too much for device names. 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 --- diff --git a/mdadm.c b/mdadm.c index c4c5f294..e053db59 100644 --- 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) {