]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
Always update mdadm/map when starting an array.
[thirdparty/mdadm.git] / config.c
index f471cf36e73b1b5de8d3492b1dae2a38f0837df6..9eb8197a9382a1b805f50adb3e8f2d6bc55266ec 100644 (file)
--- a/config.c
+++ b/config.c
@@ -434,6 +434,8 @@ void arrayline(char *line)
        mis.bitmap_fd = -1;
        mis.bitmap_file = NULL;
        mis.name[0] = 0;
+       mis.container = NULL;
+       mis.member = NULL;
 
        for (w=dl_next(line); w!=line; w=dl_next(w)) {
                if (w[0] == '/') {
@@ -520,21 +522,20 @@ void arrayline(char *line)
                        /* subarray within a container */
                        mis.member = strdup(w+7);
                } else if (strncasecmp(w, "container=", 10) == 0) {
-                       /* the container holding this subarray */
+                       /* the container holding this subarray.  Either a device name
+                        * or a uuid */
                        mis.container = strdup(w+10);
                } else {
                        fprintf(stderr, Name ": unrecognised word on ARRAY line: %s\n",
                                w);
                }
        }
-       if (mis.devname == NULL)
-               fprintf(stderr, Name ": ARRAY line with no device\n");
-       else if (mis.uuid_set == 0 && mis.devices == NULL && mis.super_minor == UnSet && mis.name[0] == 0)
+       if (mis.uuid_set == 0 && mis.devices == NULL && mis.super_minor == UnSet && mis.name[0] == 0)
                fprintf(stderr, Name ": ARRAY line %s has no identity information.\n", mis.devname);
        else {
                mi = malloc(sizeof(*mi));
                *mi = mis;
-               mi->devname = strdup(mis.devname);
+               mi->devname = mis.devname ? strdup(mis.devname) : NULL;
                mi->next = NULL;
                *mddevlp = mi;
                mddevlp = &mi->next;
@@ -564,10 +565,12 @@ void mailfromline(char *line)
                if (alert_mail_from == NULL)
                        alert_mail_from = strdup(w);
                else {
-                       char *t= NULL;
-                       asprintf(&t, "%s %s", alert_mail_from, w);
-                       free(alert_mail_from);
-                       alert_mail_from = t;
+                       char *t = NULL;
+
+                       if (asprintf(&t, "%s %s", alert_mail_from, w) > 0) {
+                               free(alert_mail_from);
+                               alert_mail_from = t;
+                       }
                }
        }
 }
@@ -717,7 +720,8 @@ mddev_ident_t conf_get_ident(char *dev)
        mddev_ident_t rv;
        load_conffile();
        rv = mddevlist;
-       while (dev && rv && strcmp(dev, rv->devname)!=0)
+       while (dev && rv && (rv->devname == NULL
+                            || strcmp(dev, rv->devname)!=0))
                rv = rv->next;
        return rv;
 }