]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
introduce --detail-platform to display platform raid capabilities
[thirdparty/mdadm.git] / super-ddf.c
index 4264bdf726984161af95874583a01d340764c6ff..51f97d3b84ec6cecb38bfadc0e734221af8947fb 100644 (file)
@@ -970,6 +970,15 @@ static int map_num1(struct num_mapping *map, int num)
        return map[i].num2;
 }
 
+static int all_ff(char *guid)
+{
+       int i;
+       for (i = 0; i < DDF_GUID_LEN; i++)
+               if (guid[i] != (char)0xff)
+                       return 0;
+       return 1;
+}
+
 #ifndef MDASSEMBLE
 static void print_guid(char *guid, int tstamp)
 {
@@ -1128,16 +1137,33 @@ static void examine_super_ddf(struct supertype *st, char *homehost)
 
 static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info);
 
+static void uuid_from_super_ddf(struct supertype *st, int uuid[4]);
 
 static void brief_examine_super_ddf(struct supertype *st)
 {
        /* We just write a generic DDF ARRAY entry
         */
+       struct ddf_super *ddf = st->sb;
        struct mdinfo info;
+       int i;
        char nbuf[64];
        getinfo_super_ddf(st, &info);
        fname_from_uuid(st, &info, nbuf, ':');
-       printf("ARRAY /dev/ddf metadata=ddf UUID=%s\n", nbuf + 5);
+       printf("ARRAY metadata=ddf UUID=%s\n", nbuf + 5);
+
+       for (i=0; i<__be16_to_cpu(ddf->virt->max_vdes); i++) {
+               struct virtual_entry *ve = &ddf->virt->entries[i];
+               struct vcl vcl;
+               char nbuf1[64];
+               if (all_ff(ve->guid))
+                       continue;
+               memcpy(vcl.conf.guid, ve->guid, DDF_GUID_LEN);
+               ddf->currentconf =&vcl;
+               uuid_from_super_ddf(st, info.uuid);
+               fname_from_uuid(st, &info, nbuf1, ':');
+               printf("ARRAY container=%s member=%d UUID=%s\n",
+                      nbuf+5, i, nbuf1+5);
+       }
 }
 
 static void detail_super_ddf(struct supertype *st, char *homehost)
@@ -1237,8 +1263,6 @@ static void uuid_from_super_ddf(struct supertype *st, int uuid[4])
 
        sha1_init_ctx(&ctx);
        sha1_process_bytes(guid, DDF_GUID_LEN, &ctx);
-       if (vcl && vcl->conf.sec_elmnt_count > 1)
-               sha1_process_bytes(&vcl->conf.sec_elmnt_seq, 1, &ctx);
        sha1_finish_ctx(&ctx, buf);
        memcpy(uuid, buf, 4*4);
 }
@@ -1300,6 +1324,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info)
        struct ddf_super *ddf = st->sb;
        struct vcl *vc = ddf->currentconf;
        int cd = ddf->currentdev;
+       int j;
 
        /* FIXME this returns BVD info - what if we want SVD ?? */
 
@@ -1347,7 +1372,11 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info)
                st->subarray);
        info->safe_mode_delay = 200;
 
-       info->name[0] = 0;
+       memcpy(info->name, ddf->virt->entries[info->container_member].name, 16);
+       info->name[16]=0;
+       for(j=0; j<16; j++)
+               if (info->name[j] == ' ')
+                       info->name[j] = 0;
 }
 
 
@@ -1628,6 +1657,8 @@ static int init_super_ddf(struct supertype *st,
        memcpy(ddf->controller.product_id, "What Is My PID??", 16);
        memset(ddf->controller.pad, 0xff, 8);
        memset(ddf->controller.vendor_data, 0xff, 448);
+       if (homehost && strlen(homehost) < 440)
+               strcpy((char*)ddf->controller.vendor_data, homehost);
 
        if (posix_memalign((void**)&pd, 512, pdsize) != 0) {
                fprintf(stderr, Name ": %s could not allocate pd\n", __func__);
@@ -1663,14 +1694,6 @@ static int init_super_ddf(struct supertype *st,
        return 1;
 }
 
-static int all_ff(char *guid)
-{
-       int i;
-       for (i = 0; i < DDF_GUID_LEN; i++)
-               if (guid[i] != (char)0xff)
-                       return 0;
-       return 1;
-}
 static int chunk_to_shift(int chunksize)
 {
        return ffs(chunksize/512)-1;
@@ -2027,7 +2050,7 @@ static void add_to_super_ddf_bvd(struct supertype *st,
 /* add a device to a container, either while creating it or while
  * expanding a pre-existing container
  */
-static void add_to_super_ddf(struct supertype *st,
+static int add_to_super_ddf(struct supertype *st,
                             mdu_disk_info_t *dk, int fd, char *devname)
 {
        struct ddf_super *ddf = st->sb;
@@ -2041,7 +2064,7 @@ static void add_to_super_ddf(struct supertype *st,
 
        if (ddf->currentconf) {
                add_to_super_ddf_bvd(st, dk, fd, devname);
-               return;
+               return 0;
        }
 
        /* This is device numbered dk->number.  We need to create
@@ -2053,7 +2076,7 @@ static void add_to_super_ddf(struct supertype *st,
                fprintf(stderr, Name
                        ": %s could allocate buffer for new disk, aborting\n",
                        __func__);
-               abort();
+               return 1;
        }
        dd->major = major(stb.st_rdev);
        dd->minor = minor(stb.st_rdev);
@@ -2124,6 +2147,8 @@ static void add_to_super_ddf(struct supertype *st,
                ddf->dlist = dd;
                ddf->updates_pending = 1;
        }
+
+       return 0;
 }
 
 /*
@@ -2661,6 +2686,7 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
        for (vc = ddf->conflist ; vc ; vc=vc->next)
        {
                int i;
+               int j;
                struct mdinfo *this;
                this = malloc(sizeof(*this));
                memset(this, 0, sizeof(*this));
@@ -2691,8 +2717,11 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
                        this->array.state = 1;
                        this->resync_start = ~0ULL;
                }
-               memcpy(this->name, ddf->virt->entries[i].name, 32);
-               this->name[32]=0;
+               memcpy(this->name, ddf->virt->entries[i].name, 16);
+               this->name[16]=0;
+               for(j=0; j<16; j++)
+                       if (this->name[j] == ' ')
+                               this->name[j] = 0;
 
                memset(this->uuid, 0, sizeof(this->uuid));
                this->component_size = __be64_to_cpu(vc->conf.blocks);
@@ -3397,4 +3426,5 @@ struct superswitch super_ddf = {
        .prepare_update = ddf_prepare_update,
        .activate_spare = ddf_activate_spare,
 #endif
+       .name = "ddf",
 };