]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
Assemble: allow members of containers to be assembled and auto-assembled.
[thirdparty/mdadm.git] / Detail.c
index dfe10c2c6e8c77e3506c15d4d3125d4dc66b2401..5ff8cd138fd759d6ae2e1ecd1b180d7a7eab1404 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);
@@ -164,12 +166,31 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        if (sra && sra->array.major_version < 0)
                                printf("MD_METADATA=%s\n", sra->text_version);
                        else
-                               printf("MD_METADATA=%02d.%02d\n",
+                               printf("MD_METADATA=%d.%02d\n",
                                       array.major_version, array.minor_version);
                }
+               
+               if (st && st->sb) {
+                       struct mdinfo info;
+                       char nbuf[64];
+                       struct map_ent *mp, *map = NULL;
+                       st->ss->getinfo_super(st, &info);
+                       fname_from_uuid(st, &info, nbuf, ':');
+                       printf("MD_UUID=%s\n", nbuf+5);
+                       mp = map_by_uuid(&map, info.uuid);
+                       if (mp && mp->path &&
+                           strncmp(mp->path, "/dev/md/", 8) == 0)
+                               printf("MD_DEVNAME=%s\n", mp->path+8);
 
-               if (st && st->sb)
-                       st->ss->export_detail_super(st);
+                       if (st->ss->export_detail_super)
+                               st->ss->export_detail_super(st);
+               } else {
+                       struct map_ent *mp, *map = NULL;
+                       mp = map_by_devnum(&map, fd2devnum(fd));
+                       if (mp && mp->path &&
+                           strncmp(mp->path, "/dev/md/", 8) == 0)
+                               printf("MD_DEVNAME=%s\n", mp->path+8);
+               }
                goto out;
        }
 
@@ -190,7 +211,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        if (sra && sra->array.major_version < 0)
                                printf(" metadata=%s", sra->text_version);
                        else
-                               printf(" metadata=%02d.%02d",
+                               printf(" metadata=%d.%02d",
                                       array.major_version, array.minor_version);
                }
 
@@ -206,7 +227,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                struct mdstat_ent *ms = mdstat_read(0, 0);
                struct mdstat_ent *e;
                int devnum = array.md_minor;
-               if (major(stb.st_rdev) != MD_MAJOR)
+               if (major(stb.st_rdev) == get_mdp_major())
                        devnum = -1 - devnum;
 
                for (e=ms; e; e=e->next)
@@ -223,7 +244,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                if (sra && sra->array.major_version < 0)
                        printf("        Version : %s\n", sra->text_version);
                else
-                       printf("        Version : %02d.%02d\n",
+                       printf("        Version : %d.%02d\n",
                               array.major_version, array.minor_version);
                }
 
@@ -290,9 +311,9 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        printf("         Layout : %s\n", c?c:"-unknown-");
                }
                if (array.level == 10) {
-                       printf("         Layout : near=%d, %s=%d\n",
-                              array.layout&255, (array.layout&0x10000)?"offset":"far",
-                              (array.layout>>8)&255);
+                       printf("         Layout :");
+                       print_r10_layout(array.layout);
+                       printf("\n");
                }
                switch (array.level) {
                case 0: