]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Detail.c
imsm: fix: thunderdome may drop 2tb attribute
[thirdparty/mdadm.git] / Detail.c
index 40806cf0f973a4094f9e14d385063d7b3cd5fd75..ae15846d8d5bd6edb2d68fb00fc314387d3f86ae 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
@@ -58,7 +58,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
 
        int rv = test ? 4 : 1;
        int avail_disks = 0;
-       char *avail;
+       char *avail = NULL;
 
        if (fd < 0) {
                fprintf(stderr, Name ": cannot open %s: %s\n",
@@ -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 */
@@ -367,16 +367,18 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                        if (avail_disks == array.raid_disks)
                                st = "";
                        else if (!enough(array.level, array.raid_disks,
-                                        array.layout, 1, avail, avail_disks))
+                                        array.layout, 1, avail))
                                st = ", FAILED";
                        else
                                st = ", degraded";
 
-                       printf("          State : %s%s%s%s\n",
-                              (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
-                              st,
-                              (!e || e->percent < 0) ? "" : sync_action[e->resync],
-                              larray_size ? "": ", Not Started");
+                       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],
+                              larray_size ? "": ", Not Started",
+                              e->percent == PROCESS_DELAYED ? " (DELAYED)": "",
+                              e->percent == PROCESS_PENDING ? " (PENDING)": "");
                }
                if (array.raid_disks)
                        printf(" Active Devices : %d\n", array.active_disks);
@@ -416,10 +418,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
                }
 
                if (e && e->percent >= 0) {
-                       printf(" Re%s Status : %d%% complete\n",
-                              (st && st->sb && info->reshape_active)?
-                                 "shape":"build",
-                              e->percent);
+                       static char *sync_action[] = {"Rebuild", "Resync", "Reshape", "Check"};
+                       printf(" %7s Status : %d%% complete\n", sync_action[e->resync], e->percent);
                        is_rebuilding = 1;
                }
                free_mdstat(ms);
@@ -491,8 +491,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);
@@ -558,7 +559,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,
@@ -580,13 +581,15 @@ This is pretty boring
        if (brief) printf("\n");
        if (test &&
            !enough(array.level, array.raid_disks, array.layout,
-                   1, avail, avail_disks))
+                   1, avail))
                rv = 2;
 
        free(disks);
 out:
        close(fd);
        free(subarray);
+       free(avail);
+       sysfs_free(sra);
        return rv;
 }