]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdopen.c
platform-intel - cache 'intel_devices' for a few seconds.
[thirdparty/mdadm.git] / mdopen.c
index 58e359aa01b7c64d82e38155219c51f7d56a3bda..462743c44bd1fc3bdb183b67ecdc8b0cc2d28944 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -207,7 +207,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                        char *ep;
                        if (cname[0] == 'd')
                                sp++;
-                       num = strtoul(sp, &ep, 10);
+                       if (isdigit(sp[0]))
+                               num = strtoul(sp, &ep, 10);
+                       else
+                               ep = sp;
                        if (ep == sp || *ep || num < 0)
                                num = -1;
                        else if (cname[0] == 'd')
@@ -286,8 +289,17 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                int cnlen;
                strncpy(cname, name, 200);
                cname[200] = 0;
-               while ((cp = strchr(cname, '/')) != NULL)
-                       *cp = '-';
+               for (cp = cname; *cp ; cp++)
+                       switch (*cp) {
+                       case '/':
+                               *cp = '-';
+                               break;
+                       case ' ':
+                       case '\t':
+                               *cp = '_';
+                               break;
+                       }
+
                if (trustworthy == LOCAL ||
                    (trustworthy == FOREIGN && strchr(cname, ':') != NULL)) {
                        /* Only need suffix if there is a conflict */
@@ -318,8 +330,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
         * If we cannot detect udev, we need to make
         * devices and links ourselves.
         */
-       if ((stat("/dev/.udev", &stb) != 0 && stat("/run/udev", &stb) != 0) ||
-           check_env("MDADM_NO_UDEV")) {
+       if (!use_udev()) {
                /* Make sure 'devname' exists and 'chosen' is a symlink to it */
                if (lstat(devname, &stb) == 0) {
                        /* Must be the correct device, else error */