]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Improve names reported by --examine --brief
authorNeil Brown <neilb@suse.de>
Fri, 26 May 2006 02:29:12 +0000 (02:29 +0000)
committerNeil Brown <neilb@suse.de>
Fri, 26 May 2006 02:29:12 +0000 (02:29 +0000)
Instead of depending (too much) on what is in /dev,
we make names based on the content of the superblock.

Signed-off-by: Neil Brown <neilb@suse.de>
super0.c
super1.c

index 87ef1e06158b2946224ef59f94c316bd233cee6c..7bb64ebbe92520d9943360f12a711352867819b5 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -227,10 +227,17 @@ static void brief_examine_super0(void *sbv)
 {
        mdp_super_t *sb = sbv;
        char *c=map_num(pers, sb->level);
-       char *nm;
+       char devname[20];
+       struct stat stb;
+
+       sprintf(devname, "/dev/md%d", sb->md_minor);
+       if (stat(devname, &stb) != 0) {
+               /* /dev/mdX doesn't exist, so use /dev/md/X */
+               sprintf(devname, "/dev/md/%d", sb->md_minor);
+       }
 
        printf("ARRAY %s level=%s num-devices=%d UUID=",
-              nm = get_md_name(sb->md_minor),
+              devname,
               c?c:"-unknown-", sb->raid_disks);
        if (sb->minor_version >= 90)
                printf("%08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
@@ -238,7 +245,6 @@ static void brief_examine_super0(void *sbv)
        else
                printf("%08x", sb->set_uuid0);
        printf("\n");
-       put_md_name(nm);
 }
 
 static void detail_super0(void *sbv, char *homehost)
index 488aabe17119ceda9b41f1df108da92e53009b2e..9f07ddcc53efcf794368453faf21f6c8940a41e5 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -308,10 +308,20 @@ static void brief_examine_super1(void *sbv)
 {
        struct mdp_superblock_1 *sb = sbv;
        int i;
+       char *nm;
+
+       nm = strchr(sb->set_name, ':');
+       if (nm)
+               nm++;
+       else if (sb->set_name[0])
+               nm = sb->set_name;
+       else
+               nm = "??";
 
        char *c=map_num(pers, __le32_to_cpu(sb->level));
 
-       printf("ARRAY /dev/?? level=%s metadata=1 num-devices=%d UUID=",
+       printf("ARRAY /dev/md/%s level=%s metadata=1 num-devices=%d UUID=",
+              nm,
               c?c:"-unknown-", sb->raid_disks);
        for (i=0; i<16; i++) {
                printf("%02x", sb->set_uuid[i]);