]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdopen.c
Assemble: return correct status from assemble_container_content.
[thirdparty/mdadm.git] / mdopen.c
index 32ccdbbe404f2cb977e73c38a578b1cd8e3d5c86..26da33e3e11bb74d7e1c1498c0b7562e5b291c33 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -88,7 +88,7 @@ void make_parts(char *dev, int cnt)
                        if (chmod(name, stb2.st_mode & 07777))
                                perror("chmod");
                } else {
-                       snprintf(sym, 10000, "%s%s%d", orig, odig?"p":"", i);
+                       snprintf(sym, sizeof(sym), "%s%s%d", orig, odig?"p":"", i);
                        symlink(sym, name);
                }
                stat(name, &stb2);
@@ -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) {