#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
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 */
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);
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;
}
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);
}
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,
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);
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) {
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,
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");