]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Create: user container_dev rather than subarray for some tests.
[thirdparty/mdadm.git] / super1.c
index 24c18c0ee3ea57f55eb321db031edd662bf57710..6974daa0fb304cc26aa794b3e13550d771278efe 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -558,12 +558,13 @@ static void uuid_from_super1(struct supertype *st, int uuid[4])
                cuuid[i] = super->set_uuid[i];
 }
 
-static void getinfo_super1(struct supertype *st, struct mdinfo *info)
+static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
 {
        struct mdp_superblock_1 *sb = st->sb;
        int working = 0;
        unsigned int i;
-       int role;
+       unsigned int role;
+       unsigned int map_disks = info->array.raid_disks;
 
        info->array.major_version = 1;
        info->array.minor_version = st->minor_version;
@@ -629,15 +630,33 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info)
        } else
                info->reshape_active = 0;
 
+       if (map)
+               for (i=0; i<map_disks; i++)
+                       map[i] = 0;
        for (i = 0; i < __le32_to_cpu(sb->max_dev); i++) {
                role = __le16_to_cpu(sb->dev_roles[i]);
-               if (/*role == 0xFFFF || */role < info->array.raid_disks)
+               if (/*role == 0xFFFF || */role < (unsigned) info->array.raid_disks) {
                        working++;
+                       if (map && role < map_disks)
+                               map[role] = 1;
+               }
        }
 
        info->array.working_disks = working;
 }
 
+static struct mdinfo *container_content1(struct supertype *st, char *subarray)
+{
+       struct mdinfo *info;
+
+       if (subarray)
+               return NULL;
+
+       info = malloc(sizeof(*info));
+       getinfo_super1(st, info, NULL);
+       return info;
+}
+
 static int update_super1(struct supertype *st, struct mdinfo *info,
                         char *update,
                         char *devname, int verbose,
@@ -1198,9 +1217,6 @@ static int load_super1(struct supertype *st, int fd, char *devname)
 
        free_super1(st);
 
-       if (st->subarray[0])
-               return 1;
-
        if (st->ss == NULL || st->minor_version == -1) {
                int bestvers = -1;
                struct supertype tst;
@@ -1355,6 +1371,7 @@ static struct supertype *match_metadata_desc1(char *arg)
        if (!st) return st;
 
        memset(st, 0, sizeof(*st));
+       st->container_dev = NoMdDev;
        st->ss = &super1;
        st->max_devs = 384;
        st->sb = NULL;
@@ -1676,6 +1693,7 @@ struct superswitch super1 = {
        .match_home = match_home1,
        .uuid_from_super = uuid_from_super1,
        .getinfo_super = getinfo_super1,
+       .container_content = container_content1,
        .update_super = update_super1,
        .init_super = init_super1,
        .store_super = store_super1,