summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdopen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mdopen.c b/mdopen.c
index 32ccdbb..e1c0d7f 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -235,11 +235,14 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
use_mdp = 0;
}
if (num < 0 && trustworthy == LOCAL && name) {
- /* if name is numeric, us that for num */
+ /* if name is numeric, use that for num
+ * if it is not already in use */
char *ep;
num = strtoul(name, &ep, 10);
if (ep == name || *ep)
num = -1;
+ else if (mddev_busy(use_mdp ? (-1-num) : num))
+ num = -1;
}
if (num < 0) {