]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
mdadm: define DEV_NUM_PREF
[thirdparty/mdadm.git] / config.c
index 7592b2d7aea94a623270fb1029aefd4d54539593..f44cc1d3c33bb857f13d0aa97802ccc3d6c475b0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -81,7 +81,7 @@ char DefaultAltConfDir[] = CONFFILE2 ".d";
 
 enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
                Homehost, HomeCluster, AutoMode, Policy, PartPolicy, Sysfs,
-               LTEnd };
+               MonitorDelay, LTEnd };
 char *keywords[] = {
        [Devices]  = "devices",
        [Array]    = "array",
@@ -95,6 +95,7 @@ char *keywords[] = {
        [Policy]   = "policy",
        [PartPolicy]="part-policy",
        [Sysfs]    = "sysfs",
+       [MonitorDelay] = "monitordelay",
        [LTEnd]    = NULL
 };
 
@@ -118,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;
@@ -193,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
@@ -309,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;
@@ -367,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) {
@@ -396,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 */;
@@ -588,6 +597,17 @@ void homeclusterline(char *line)
        }
 }
 
+static int monitor_delay;
+void monitordelayline(char *line)
+{
+       char *w;
+
+       for (w = dl_next(line); w != line; w = dl_next(w)) {
+               if (monitor_delay == 0)
+                       monitor_delay = strtol(w, NULL, 10);
+       }
+}
+
 char auto_yes[] = "yes";
 char auto_no[] = "no";
 char auto_homehost[] = "homehost";
@@ -769,6 +789,9 @@ void conf_file(FILE *f)
                case Sysfs:
                        sysfsline(line);
                        break;
+               case MonitorDelay:
+                       monitordelayline(line);
+                       break;
                default:
                        pr_err("Unknown keyword %s\n", line);
                }
@@ -925,6 +948,12 @@ char *conf_get_homecluster(void)
        return home_cluster;
 }
 
+int conf_get_monitor_delay(void)
+{
+       load_conffile();
+       return monitor_delay;
+}
+
 struct createinfo *conf_get_create_info(void)
 {
        load_conffile();
@@ -1073,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;