From: Neil Brown Date: Tue, 14 Jun 2005 00:14:32 +0000 (+0000) Subject: Make --examine --brief report spares= properly X-Git-Tag: mdadm-1.12.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0869bd203f2a5a78c2e8a04fca6600568b1e973;p=thirdparty%2Fmdadm.git Make --examine --brief report spares= properly Signed-off-by: Neil Brown --- diff --git a/ChangeLog b/ChangeLog index 55ab3553..fbde4ecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ Changes Prior to 1.12.0 release This is because the device list can change and so is not a stable aspect of the array - Allow --force with --grow so '-Gfn1' works (on raid1) + - Make --examine --brief report spares= properly. Changes Prior to 1.11.0 release - Fix embarassing bug which causes --add to always fail. diff --git a/Examine.c b/Examine.c index 186b6b14..898d2a5f 100644 --- a/Examine.c +++ b/Examine.c @@ -60,12 +60,12 @@ int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) char *c; int rv = 0; int err; - int spares = 0; struct array { mdp_super_t super; void *devs; struct array *next; + int spares; } *arrays = NULL; for (; devlist ; devlist=devlist->next) { @@ -126,10 +126,13 @@ int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) ap->super = super; ap->devs = dl_head(); ap->next = arrays; + ap->spares = 0; arrays = ap; } d = dl_strdup(devlist->devname); dl_add(ap->devs, d); + if (super.this_disk.state == 0) + ap->spares++; } else { printf("%s:\n",devlist->devname); printf(" Magic : %08x\n", super.md_magic); @@ -215,7 +218,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) if (dp->state & (1<state & (1<state & (1<state == 0) { printf(" spare"); spares++; } + if (dp->state == 0) printf(" spare"); if ((dv=map_dev(dp->major, dp->minor))) printf(" %s", dv); printf("\n"); @@ -246,15 +249,15 @@ int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) char sep='='; char *c=map_num(pers, ap->super.level); char *d; - printf("ARRAY %s level=%s num-devices=%d UUID=", + printf("ARRAY %s level=%s num-devices=%d", get_md_name(ap->super.md_minor), c?c:"-unknown-", ap->super.raid_disks); - if (spares) printf(" spares=%d", spares); + if (ap->spares) printf(" spares=%d", ap->spares); if (ap->super.minor_version >= 90) - printf("%08x:%08x:%08x:%08x", ap->super.set_uuid0, ap->super.set_uuid1, + printf(" UUID=%08x:%08x:%08x:%08x", ap->super.set_uuid0, ap->super.set_uuid1, ap->super.set_uuid2, ap->super.set_uuid3); else - printf("%08x", ap->super.set_uuid0); + printf(" UUID=%08x", ap->super.set_uuid0); if (brief > 1) { printf("\n devices"); for (d=dl_next(ap->devs); d!= ap->devs; d=dl_next(d)) {