diff options
author | NeilBrown <neilb@suse.de> | 2009-05-11 07:16:47 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-05-11 07:16:47 +0200 |
commit | d7ba0c55f07d24b51e6da1a5850d7164e9cf01d9 (patch) | |
tree | 428d877e17862c20118b1e5f7b0570af7c642abd /mdopen.c | |
parent | Wait for POLLPRI on /proc or /sys files. (diff) | |
download | mdadm-d7ba0c55f07d24b51e6da1a5850d7164e9cf01d9.tar.xz mdadm-d7ba0c55f07d24b51e6da1a5850d7164e9cf01d9.zip |
create_dev - allow array names like mdX and /dev/mdX to appear 'numeric'
When choosing the minor number to use with an array, we currently base
the number of the 'name' stored in the metadata if that name is
numeric.
Extend that so that if it looks like a number md device name (/dev/md0
or just md0 or even /dev/md/0), then we use the number at the end to
suggest a minor number.
The means that if someone creates and array with "--name md0" or even
"--name /dev/md0" it will continue to do what they expect.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdopen.c')
-rw-r--r-- | mdopen.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -238,11 +238,19 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, use_mdp = 0; } if (num < 0 && trustworthy == LOCAL && name) { - /* if name is numeric, use that for num + /* if name is numeric, possibly prefixed by + * 'md' or '/dev/md', use that for num * if it is not already in use */ char *ep; - num = strtoul(name, &ep, 10); - if (ep == name || *ep) + char *n2 = name; + if (strncmp(n2, "/dev/", 5) == 0) + n2 += 5; + if (strncmp(n2, "md", 2) == 0) + n2 += 2; + if (*n2 == '/') + n2++; + num = strtoul(n2, &ep, 10); + if (ep == n2 || *ep) num = -1; else if (mddev_busy(use_mdp ? (-1-num) : num)) num = -1; |