]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
mdadm: define DEV_NUM_PREF
[thirdparty/mdadm.git] / config.c
index 9c725457fac98913186896f881edeae149a86d72..f44cc1d3c33bb857f13d0aa97802ccc3d6c475b0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -119,6 +119,34 @@ int match_keyword(char *word)
        return -1;
 }
 
+/**
+ * ident_init() - Set defaults.
+ * @ident: ident pointer, not NULL.
+ */
+inline void ident_init(struct mddev_ident *ident)
+{
+       assert(ident);
+
+       ident->assembled = false;
+       ident->autof = 0;
+       ident->bitmap_fd = -1;
+       ident->bitmap_file = NULL;
+       ident->container = NULL;
+       ident->devices = NULL;
+       ident->devname = NULL;
+       ident->level = UnSet;
+       ident->member = NULL;
+       ident->name[0] = 0;
+       ident->next = NULL;
+       ident->raid_disks = UnSet;
+       ident->spare_group = NULL;
+       ident->spare_disks = 0;
+       ident->st = NULL;
+       ident->super_minor = UnSet;
+       ident->uuid[0] = 0;
+       ident->uuid_set = 0;
+}
+
 struct conf_dev {
        struct conf_dev *next;
        char *name;
@@ -194,7 +222,6 @@ struct mddev_dev *load_containers(void)
 
 struct createinfo createinfo = {
        .autof = 2, /* by default, create devices with standard names */
-       .symlinks = 1,
        .names = 0, /* By default, stick with numbered md devices. */
        .bblist = 1, /* Use a bad block list by default */
 #ifdef DEBIAN
@@ -310,11 +337,7 @@ static void createline(char *line)
                        if (!createinfo.supertype)
                                pr_err("metadata format %s unknown, ignoring\n",
                                        w+9);
-               } else if (strncasecmp(w, "symlinks=yes", 12) == 0)
-                       createinfo.symlinks = 1;
-               else if  (strncasecmp(w, "symlinks=no", 11) == 0)
-                       createinfo.symlinks = 0;
-               else if (strncasecmp(w, "names=yes", 12) == 0)
+               } else if (strncasecmp(w, "names=yes", 12) == 0)
                        createinfo.names = 1;
                else if  (strncasecmp(w, "names=no", 11) == 0)
                        createinfo.names = 0;
@@ -368,22 +391,7 @@ void arrayline(char *line)
        struct mddev_ident mis;
        struct mddev_ident *mi;
 
-       mis.uuid_set = 0;
-       mis.super_minor = UnSet;
-       mis.level = UnSet;
-       mis.raid_disks = UnSet;
-       mis.spare_disks = 0;
-       mis.devices = NULL;
-       mis.devname = NULL;
-       mis.spare_group = NULL;
-       mis.autof = 0;
-       mis.next = NULL;
-       mis.st = NULL;
-       mis.bitmap_fd = -1;
-       mis.bitmap_file = NULL;
-       mis.name[0] = 0;
-       mis.container = NULL;
-       mis.member = NULL;
+       ident_init(&mis);
 
        for (w = dl_next(line); w != line; w = dl_next(w)) {
                if (w[0] == '/' || strchr(w, '=') == NULL) {
@@ -397,10 +405,10 @@ void arrayline(char *line)
                         *  or anything that doesn't start '/' or '<'
                         */
                        if (strcasecmp(w, "<ignore>") == 0 ||
-                           strncmp(w, "/dev/md/", 8) == 0 ||
+                           strncmp(w, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0 ||
                            (w[0] != '/' && w[0] != '<') ||
-                           (strncmp(w, "/dev/md", 7) == 0 &&
-                            is_number(w + 7)) ||
+                           (strncmp(w, DEV_NUM_PREF, DEV_NUM_PREF_LEN) == 0 &&
+                            is_number(w + DEV_NUM_PREF_LEN)) ||
                            (strncmp(w, "/dev/md_d", 9) == 0 &&
                             is_number(w + 9))) {
                                /* This is acceptable */;
@@ -1094,13 +1102,13 @@ int devname_matches(char *name, char *match)
         *  mdNN with NN
         * then just strcmp
         */
-       if (strncmp(name, "/dev/md/", 8) == 0)
-               name += 8;
+       if (strncmp(name, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
+               name += DEV_MD_DIR_LEN;
        else if (strncmp(name, "/dev/", 5) == 0)
                name += 5;
 
-       if (strncmp(match, "/dev/md/", 8) == 0)
-               match += 8;
+       if (strncmp(match, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
+               match += DEV_MD_DIR_LEN;
        else if (strncmp(match, "/dev/", 5) == 0)
                match += 5;