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 <neilb@suse.de>
This commit is contained in:
NeilBrown 2013-05-13 12:56:38 +10:00
parent 6b63c1a457
commit 743eaf8b70
1 changed files with 4 additions and 2 deletions

View File

@ -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) {