]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mapfile.c
Assemble: split out "start_array()" function.
[thirdparty/mdadm.git] / mapfile.c
index 70ff3558361bf543db55c0fcb7e9042e22386820..34ebdb54f7ee567e112d3346587ce4a7c2745b47 100644 (file)
--- a/mapfile.c
+++ b/mapfile.c
@@ -166,12 +166,12 @@ void map_fork(void)
 void map_add(struct map_ent **melp,
            int devnum, char *metadata, int uuid[4], char *path)
 {
-       struct map_ent *me = malloc(sizeof(*me));
+       struct map_ent *me = xmalloc(sizeof(*me));
 
        me->devnum = devnum;
        strcpy(me->metadata, metadata);
        memcpy(me->uuid, uuid, 16);
-       me->path = path ? strdup(path) : NULL;
+       me->path = path ? xstrdup(path) : NULL;
        me->next = *melp;
        me->bad = 0;
        *melp = me;
@@ -237,7 +237,7 @@ int map_update(struct map_ent **mpp, int devnum, char *metadata,
                        strcpy(mp->metadata, metadata);
                        memcpy(mp->uuid, uuid, 16);
                        free(mp->path);
-                       mp->path = path ? strdup(path) : NULL;
+                       mp->path = path ? xstrdup(path) : NULL;
                        mp->bad = 0;
                        break;
                }
@@ -403,7 +403,12 @@ void RebuildMap(void)
                        close(dfd);
                        if (ok != 0)
                                continue;
-                       info = st->ss->container_content(st, subarray);
+                       if (subarray)
+                               info = st->ss->container_content(st, subarray);
+                       else {
+                               info = xmalloc(sizeof(*info));
+                               st->ss->getinfo_super(st, info, NULL);
+                       }
                        if (!info)
                                continue;
 
@@ -417,7 +422,7 @@ void RebuildMap(void)
                                 * an MD_DEVNAME for udev.
                                 * The name needs to be unique both in /dev/md/
                                 * and in this mapfile.
-                                * It needs to match watch -I or -As would come
+                                * It needs to match what -I or -As would come
                                 * up with.
                                 * That means:
                                 *   Check if array is in mdadm.conf