]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
Report uuid in --detail --brief for ddf and intel
[thirdparty/mdadm.git] / super-ddf.c
index 70889dc388ee2be5973b2b5c8bb78b6ba7e76c01..ad21e74a3c82fee0ded5074d1b737ac921b330db 100644 (file)
@@ -814,6 +814,7 @@ static int load_super_ddf(struct supertype *st, int fd,
                st->minor_version = 0;
                st->max_devs = 512;
        }
+       st->loaded_container = 0;
        return 0;
 
 }
@@ -1099,20 +1100,18 @@ static void examine_super_ddf(struct supertype *st, char *homehost)
        examine_pds(sb);
 }
 
+static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info);
+
+
 static void brief_examine_super_ddf(struct supertype *st)
 {
        /* We just write a generic DDF ARRAY entry
-        * The uuid is all hex, 6 groups of 4 bytes
         */
-       struct ddf_super *ddf = st->sb;
-       int i;
-       printf("ARRAY /dev/ddf metadata=ddf UUID=");
-       for (i = 0; i < DDF_GUID_LEN; i++) {
-               if ((i&3) == 0 && i != 0)
-                       printf(":");
-               printf("%02X", 255&ddf->anchor.guid[i]);
-       }
-       printf("\n");
+       struct mdinfo info;
+       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);
 }
 
 static void detail_super_ddf(struct supertype *st, char *homehost)
@@ -1131,6 +1130,11 @@ static void brief_detail_super_ddf(struct supertype *st)
         * Can that be stored in ddf_super??
         */
 //     struct ddf_super *ddf = st->sb;
+       struct mdinfo info;
+       char nbuf[64];
+       getinfo_super_ddf(st, &info);
+       fname_from_uuid(st, &info, nbuf,':');
+       printf(" UUID=%s", nbuf + 5);
 }
 #endif
 
@@ -1179,11 +1183,14 @@ static void uuid_from_super_ddf(struct supertype *st, int uuid[4])
         *  uuid to put into bitmap file (Create, Grow)
         *  uuid for backup header when saving critical section (Grow)
         *  comparing uuids when re-adding a device into an array
+        *    In these cases the uuid required is that of the data-array,
+        *    not the device-set.
+        *  uuid to recognise same set when adding a missing device back
+        *    to an array.   This is a uuid for the device-set.
+        *  
         * For each of these we can make do with a truncated
         * or hashed uuid rather than the original, as long as
         * everyone agrees.
-        * In each case the uuid required is that of the data-array,
-        * not the device-set.
         * In the case of SVD we assume the BVD is of interest,
         * though that might be the case if a bitmap were made for
         * a mirrored SVD - worry about that later.
@@ -1193,19 +1200,21 @@ static void uuid_from_super_ddf(struct supertype *st, int uuid[4])
         */
        struct ddf_super *ddf = st->sb;
        struct vcl *vcl = ddf->currentconf;
+       char *guid;
+       char buf[20];
+       struct sha1_ctx ctx;
 
-       if (!vcl)
-               memset(uuid, 0, sizeof (uuid));
-       else {
-               char buf[20];
-               struct sha1_ctx ctx;
-               sha1_init_ctx(&ctx);
-               sha1_process_bytes(&vcl->conf.guid, DDF_GUID_LEN, &ctx);
-               if (vcl->conf.sec_elmnt_count > 1)
-                       sha1_process_bytes(&vcl->conf.sec_elmnt_seq, 1, &ctx);
-               sha1_finish_ctx(&ctx, buf);
-               memcpy(uuid, buf, sizeof(uuid));
-       }
+       if (vcl)
+               guid = vcl->conf.guid;
+       else
+               guid = ddf->anchor.guid;
+
+       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);
 }
 
 static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info);
@@ -1247,15 +1256,15 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info)
 
 
        info->reshape_active = 0;
+       info->name[0] = 0;
 
        info->array.major_version = -1;
        info->array.minor_version = -2;
        strcpy(info->text_version, "ddf");
        info->safe_mode_delay = 0;
 
-//     uuid_from_super_ddf(info->uuid, sbv);
+       uuid_from_super_ddf(st, info->uuid);
 
-//     info->name[] ?? ;
 }
 
 static int rlq_to_layout(int rlq, int prl, int raiddisks);
@@ -1312,7 +1321,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info)
                st->subarray);
        info->safe_mode_delay = 200;
 
-//     info->name[] ?? ;
+       info->name[0] = 0;
 }
 
 
@@ -2562,6 +2571,7 @@ static int load_super_ddf_all(struct supertype *st, int fd,
                st->max_devs = 512;
                st->container_dev = fd2devnum(fd);
        }
+       st->loaded_container = 1;
        return 0;
 }
 #endif /* MDASSEMBLE */
@@ -2621,6 +2631,10 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
                this->array.size = this->component_size / 2;
                this->container_member = i;
 
+               ddf->currentconf = vc;
+               uuid_from_super_ddf(st, this->uuid);
+               ddf->currentconf = NULL;
+
                sprintf(this->text_version, "/%s/%d",
                        devnum2devname(st->container_dev),
                        this->container_member);