]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
Release 3.2.6 - stability release
[thirdparty/mdadm.git] / Detail.c
index 1d7e3a1648288472ef396f55f2e55ed1e2b14042..946b5e9be783150b9d713aebc03ee143d1d5f2b9 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -27,7 +27,7 @@
 #include       "md_u.h"
 #include       <dirent.h>
 
-int Detail(char *dev, int brief, int export, int test, char *homehost)
+int Detail(char *dev, int brief, int export, int test, char *homehost, char *prefer)
 {
        /*
         * Print out details for an md array by using
@@ -105,7 +105,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                int dn = st->container_dev;
 
                member = subarray;
-               container = map_dev(dev2major(dn), dev2minor(dn), 1);
+               container = map_dev_preferred(dev2major(dn), dev2minor(dn), 1, prefer);
        }
 
        /* try to load a superblock */
@@ -206,8 +206,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        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);
+                           strncmp(mp->path, "/dev/md/", 8) == 0) {
+                               printf("MD_DEVNAME=");
+                               print_escape(mp->path+8);
+                               putchar('\n');
+                       }
 
                        if (st->ss->export_detail_super)
                                st->ss->export_detail_super(st);
@@ -220,8 +223,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                                printf("MD_UUID=%s\n", nbuf+5);
                        }
                        if (mp && mp->path &&
-                           strncmp(mp->path, "/dev/md/", 8) == 0)
-                               printf("MD_DEVNAME=%s\n", mp->path+8);
+                           strncmp(mp->path, "/dev/md/", 8) == 0) {
+                               printf("MD_DEVNAME=");
+                               print_escape(mp->path+8);
+                               putchar('\n');
+                       }
                }
                goto out;
        }
@@ -374,11 +380,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
 
                        printf("          State : %s%s%s%s%s%s \n",
                               (array.state&(1<<MD_SB_CLEAN))?"clean":"active", st,
-                              (!e || (e->percent < 0 && e->percent != PROCESS_PENDING &&
-                              e->percent != PROCESS_DELAYED)) ? "" : sync_action[e->resync],
+                              (!e || (e->percent < 0 && e->percent != RESYNC_PENDING &&
+                              e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
                               larray_size ? "": ", Not Started",
-                              e->percent == PROCESS_DELAYED ? " (DELAYED)": "",
-                              e->percent == PROCESS_PENDING ? " (PENDING)": "");
+                              e->percent == RESYNC_DELAYED ? " (DELAYED)": "",
+                              e->percent == RESYNC_PENDING ? " (PENDING)": "");
                }
                if (array.raid_disks)
                        printf(" Active Devices : %d\n", array.active_disks);
@@ -424,7 +430,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                }
                free_mdstat(ms);
 
-               if (st->sb && info->reshape_active) {
+               if ((st && st->sb) && (info && info->reshape_active)) {
 #if 0
 This is pretty boring
                        printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9,
@@ -491,8 +497,9 @@ This is pretty boring
                                    vbuf[10+nlen] != '/')
                                        continue;
                                dn = devname2devnum(de->d_name);
-                               printf(" %s", map_dev(dev2major(dn),
-                                                     dev2minor(dn), 1));
+                               printf(" %s", map_dev_preferred(
+                                              dev2major(dn),
+                                              dev2minor(dn), 1, prefer));
                        }
                        if (dir)
                                closedir(dir);
@@ -536,7 +543,8 @@ This is pretty boring
                        if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed");
                        if (disk.state & (1<<MD_DISK_WRITEMOSTLY)) printf(" writemostly");
                        if ((disk.state &
-                            ((1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC)|(1<<MD_DISK_REMOVED)))
+                            ((1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC)
+                             |(1<<MD_DISK_REMOVED)|(1<<MD_DISK_FAULTY)))
                            == 0) {
                                printf(" spare");
                                if (is_26) {
@@ -558,7 +566,7 @@ This is pretty boring
                if (test && d < array.raid_disks
                    && !(disk.state & (1<<MD_DISK_SYNC)))
                        rv |= 1;
-               if ((dv=map_dev(disk.major, disk.minor, 0))) {
+               if ((dv=map_dev_preferred(disk.major, disk.minor, 0, prefer))) {
                        if (brief) {
                                if (devices) {
                                        devices = realloc(devices,
@@ -574,7 +582,8 @@ This is pretty boring
        if (spares && brief && array.raid_disks) printf(" spares=%d", spares);
        if (brief && st && st->sb)
                st->ss->brief_detail_super(st);
-       st->ss->free_super(st);
+       if (st)
+               st->ss->free_super(st);
 
        if (brief > 1 && devices) printf("\n   devices=%s", devices);
        if (brief) printf("\n");