From: Neil Brown Date: Mon, 21 May 2007 04:25:50 +0000 (+1000) Subject: Make return code for "--detail --test" more reliable. X-Git-Tag: mdadm-2.6.2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a77be586720af37f175f3e9f48047d65ef5f67de;p=thirdparty%2Fmdadm.git Make return code for "--detail --test" more reliable. Missing devices as well as failed devices cause an error. --- diff --git a/ChangeLog b/ChangeLog index 2d81c3da..d92f5ef0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ Changes Prior to this release - Various manpage updates. - Make "--grow --add" for linear arrays really work. - --auto-detect to trigger in-kernel autodetect. + - Make return code for "--detail --test" more reliable. Missing + devices as well as failed devices cause an error. Changes Prior to 2.6.1 release - --monitor was producing some meaningless warnings due to a bug. diff --git a/Detail.c b/Detail.c index 58de67e1..0ed81d12 100644 --- a/Detail.c +++ b/Detail.c @@ -58,6 +58,8 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) void *super = NULL; int rv = test ? 4 : 1; + int avail_disks = 0; + char *avail; if (fd < 0) { fprintf(stderr, Name ": cannot open %s: %s\n", @@ -301,6 +303,7 @@ This is pretty boring disks[next++] = disk; } + avail = calloc(array.raid_disks, 1); for (d= 0; d < max_disks; d++) { char *dv; mdu_disk_info_t disk = disks[d]; @@ -347,10 +350,13 @@ This is pretty boring } } if (disk.state == 0) spares++; - if (test && d < array.raid_disks && disk.state & (1< 1 && devices) printf("\n devices=%s", devices); if (brief) printf("\n"); out: - if (test && (rv&2)) rv &= ~1; + if (test && + !enough(array.level, array.raid_disks, array.layout, + 1, avail, avail_disks)) + rv = 2; + close(fd); return rv; } diff --git a/mdadm.8 b/mdadm.8 index e70a1a92..0d3adfc3 100644 --- a/mdadm.8 +++ b/mdadm.8 @@ -1457,8 +1457,7 @@ The array is functioning normally. The array has at least one failed device. .TP 2 -The array has multiple failed devices and hence is unusable (raid4 or -raid5). +The array has multiple failed devices such that it is unusable. .TP 4 There was an error while trying to get information about the device.