summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-07-02 10:46:43 +1000
committerNeilBrown <neilb@suse.de>2013-07-02 10:46:43 +1000
commiteb2306f8411070bc7bcd46ad8fee0f02c826380a (patch)
tree5c6f4ea1dfcff54dd2f83f5f81bce779ea416908 /config.c
parentbabb8dd4274c80b08af3f583a136a9f12e9b5f69 (diff)
Config: use better device names for "DEVICES container"
When "containers" appears on the "DEVICES" line (which is does by default), use names from the mdadm map file instead of kernel names, when possible. This mean that the name will be more likely to appear in mdadm.conf and so more likely to match "container=" tags. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'config.c')
-rw-r--r--config.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/config.c b/config.c
index 5cf6ae5f..5c8b03a3 100644
--- a/config.c
+++ b/config.c
@@ -154,6 +154,7 @@ struct mddev_dev *load_containers(void)
struct mdstat_ent *ent;
struct mddev_dev *d;
struct mddev_dev *rv = NULL;
+ struct map_ent *map = NULL, *me;
if (!mdstat)
return NULL;
@@ -164,7 +165,10 @@ struct mddev_dev *load_containers(void)
!is_subarray(&ent->metadata_version[9])) {
d = xmalloc(sizeof(*d));
memset(d, 0, sizeof(*d));
- if (asprintf(&d->devname, "/dev/%s", ent->dev) < 0) {
+ me = map_by_devnm(&map, ent->dev);
+ if (me)
+ d->devname = xstrdup(me->path);
+ else if (asprintf(&d->devname, "/dev/%s", ent->dev) < 0) {
free(d);
continue;
}
@@ -172,6 +176,7 @@ struct mddev_dev *load_containers(void)
rv = d;
}
free_mdstat(mdstat);
+ map_free(map);
return rv;
}