]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Report uuid in --detail --brief for ddf and intel
authorNeilBrown <neilb@suse.de>
Thu, 18 Sep 2008 06:11:40 +0000 (16:11 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 18 Sep 2008 06:11:40 +0000 (16:11 +1000)
The uuid is slightly fictitious but needed for array matching.

Assemble.c
Detail.c
Incremental.c
mdadm.h
super-ddf.c
super-intel.c
util.c

index 3d29d41b68a76d57bd834ff4c407f6877c75e378..a73e101ed047e75c139ab48b84a70f0c15270df2 100644 (file)
@@ -401,7 +401,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                }
                st->ss->getinfo_super(st, &info);
                if (uuid_for_name)
-                       c = fname_from_uuid(st, &info, nbuf);
+                       c = fname_from_uuid(st, &info, nbuf, '-');
                else {
                        c = strchr(info.name, ':');
                        if (c) c++; else c= info.name;
index dfe10c2c6e8c77e3506c15d4d3125d4dc66b2401..ae00bb493373c46292927fd64d3743c472ec2833 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -128,7 +128,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        continue;
                if ((dv=map_dev(disk.major, disk.minor, 1))) {
                        if ((!st || !st->sb) &&
-                           (disk.state & (1<<MD_DISK_ACTIVE))) {
+                           (array.raid_disks == 0 || 
+                            (disk.state & (1<<MD_DISK_ACTIVE)))) {
                                /* try to read the superblock from this device
                                 * to get more info
                                 */
@@ -136,8 +137,9 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                                if (fd2 >=0 && st &&
                                    st->ss->load_super(st, fd2, NULL) == 0) {
                                        st->ss->getinfo_super(st, &info);
-                                       if (info.array.ctime != array.ctime ||
-                                           info.array.level != array.level)
+                                       if (array.raid_disks != 0 && /* container */
+                                           (info.array.ctime != array.ctime ||
+                                            info.array.level != array.level))
                                                st->ss->free_super(st);
                                }
                                if (fd2 >= 0) close(fd2);
index 869ae8396802f81a729e3678d60de55362f38b03..6474e796bf5af69d3f83225717ab5eb41080b942 100644 (file)
@@ -233,7 +233,7 @@ int Incremental(char *devname, int verbose, int runstop,
        mp = map_by_uuid(&map, info.uuid);
 
        if (uuid_for_name && ! mp) {
-               name_to_use = fname_from_uuid(st, &info, nbuf);
+               name_to_use = fname_from_uuid(st, &info, nbuf, '-');
                if (verbose >= 0)
                        fprintf(stderr, Name
                ": not found in mdadm.conf and not identified by homehost"
@@ -804,7 +804,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
                    ! *name_to_use ||
                    (*devname != '/' || strncmp("UUID-", strrchr(devname,'/')+1,5) == 0)
                        )
-                       name_to_use = fname_from_uuid(st, ra, nbuf);
+                       name_to_use = fname_from_uuid(st, ra, nbuf, '-');
                    
                if (mp)
                        devnum = mp->devnum;
diff --git a/mdadm.h b/mdadm.h
index f70e361b612fef65475ee1e98d3d000581bd09b9..f327020726fa570d32393ab60d2f2671a4eca75f 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -764,7 +764,7 @@ extern void uuid_from_super(int uuid[4], mdp_super_t *super);
 extern int same_uuid(int a[4], int b[4], int swapuuid);
 extern void copy_uuid(void *a, int b[4], int swapuuid);
 extern char *fname_from_uuid(struct supertype *st,
-                            struct mdinfo *info, char *buf);
+                            struct mdinfo *info, char *buf, char sep);
 extern unsigned long calc_csum(void *super, int bytes);
 extern int enough(int level, int raid_disks, int layout, int clean,
                   char *avail, int avail_disks);
index 77ce46fd37de83faff1f329ad45dfd1d58f438e3..ad21e74a3c82fee0ded5074d1b737ac921b330db 100644 (file)
@@ -1100,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)
@@ -1132,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
 
index 4571b869b9d15d25ea2dc11ee415a06ef182e301..3249b2ccbd6c59f66646c389709737f98e3be686 100644 (file)
@@ -560,9 +560,18 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
        }
 }
 
+static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info);
+
 static void brief_examine_super_imsm(struct supertype *st)
 {
-       printf("ARRAY /dev/imsm metadata=imsm\n");
+       /* We just write a generic DDF ARRAY entry
+        */
+       struct mdinfo info;
+       char nbuf[64];
+
+       getinfo_super_imsm(st, &info);
+       fname_from_uuid(st, &info, nbuf,'-');
+       printf("ARRAY /dev/imsm metadata=imsm UUID=%s\n", nbuf + 5);
 }
 
 static void detail_super_imsm(struct supertype *st, char *homehost)
@@ -572,7 +581,11 @@ static void detail_super_imsm(struct supertype *st, char *homehost)
 
 static void brief_detail_super_imsm(struct supertype *st)
 {
-       printf("%s\n", __FUNCTION__);
+       struct mdinfo info;
+       char nbuf[64];
+       getinfo_super_imsm(st, &info);
+       fname_from_uuid(st, &info, nbuf,'-');
+       printf(" UUID=%s", nbuf + 5);
 }
 #endif
 
diff --git a/util.c b/util.c
index b65d2ad890d5e851bad2dd1f3392550ce002ce55..653796f10474803c70ede50b984d7db20b36cbaa 100644 (file)
--- a/util.c
+++ b/util.c
@@ -269,7 +269,7 @@ void copy_uuid(void *a, int b[4], int swapuuid)
                memcpy(a, b, 16);
 }
 
-char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf)
+char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf, char sep)
 {
        int i;
        char uuid[16];
@@ -278,10 +278,8 @@ char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf)
        c += strlen(c);
        copy_uuid(uuid, info->uuid, st->ss->swapuuid);
        for (i=0; i<16; i++) {
-               if (i && (i&3)==0) {
-                       strcpy(c, "-");
-                       c++;
-               }
+               if (i && (i&3)==0)
+                       *c++ = sep;
                sprintf(c,"%02x", (unsigned char)uuid[i]);
                c+= 2;
        }