From a77be586720af37f175f3e9f48047d65ef5f67de Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 21 May 2007 14:25:50 +1000 Subject: Make return code for "--detail --test" more reliable. Missing devices as well as failed devices cause an error. --- Detail.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Detail.c') diff --git a/Detail.c b/Detail.c index 58de67e..0ed81d1 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; } -- cgit