diff options
author | NeilBrown <neilb@suse.de> | 2013-12-03 04:01:24 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-12-03 04:01:24 +0100 |
commit | b11fe74db0d764c3a245d95bc3651be9bbd59463 (patch) | |
tree | 8da452583d18057e67f65462a2e5dec2f4f3dee8 /Incremental.c | |
parent | Systemd integration for starting newly-degraded arrays. (diff) | |
download | mdadm-b11fe74db0d764c3a245d95bc3651be9bbd59463.tar.xz mdadm-b11fe74db0d764c3a245d95bc3651be9bbd59463.zip |
Incremental: improve support for "DEVICE" based restriction in mdadm.conf
--incremental currently fails if the device name passed does not
textually match the names permitted by the DEVICE line in mdadm.conf.
This is problematic when "mdadm -I" is run by udev as the name given
can be a temp name.
This patch makes two improvements:
1/ We generate a list of all existing devices that match the names
in mdadm.conf, and allow rdev based matching
2/ We allows extra aliases to be provided on the command line, and
perform textual matching on those. This is particularly suitable
for udev usages as ${DEVLINKS} can be provided even though the links
make not yet be created.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Incremental.c')
-rw-r--r-- | Incremental.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Incremental.c b/Incremental.c index 0703deae..f548bad9 100644 --- a/Incremental.c +++ b/Incremental.c @@ -46,7 +46,7 @@ static int try_spare(char *devname, int *dfdp, struct dev_policy *pol, static int Incremental_container(struct supertype *st, char *devname, struct context *c, char *only); -int Incremental(char *devname, struct context *c, +int Incremental(struct mddev_dev *devlist, struct context *c, struct supertype *st) { /* Add this device to an array, creating the array if necessary @@ -103,6 +103,7 @@ int Incremental(char *devname, struct context *c, struct dev_policy *policy = NULL; struct map_ent target_array; int have_target; + char *devname = devlist->devname; struct createinfo *ci = conf_get_create_info(); @@ -153,7 +154,20 @@ int Incremental(char *devname, struct context *c, /* 1/ Check if device is permitted by mdadm.conf */ - if (!conf_test_dev(devname)) { + for (;devlist; devlist = devlist->next) + if (conf_test_dev(devlist->devname)) + break; + if (!devlist) { + devlist = conf_get_devs(); + for (;devlist; devlist = devlist->next) { + struct stat st2; + if (stat(devlist->devname, &st2) == 0 && + (st2.st_mode & S_IFMT) == S_IFBLK && + st2.st_rdev == stb.st_rdev) + break; + } + } + if (!devlist) { if (c->verbose >= 0) pr_err("%s not permitted by mdadm.conf.\n", devname); |