From: Artur Paszkiewicz Date: Mon, 9 Feb 2015 10:13:50 +0000 (+0100) Subject: Monitor: fix for regression with container devices X-Git-Tag: mdadm-3.3.3~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19d3ea0f0b4decef347770b9b0d1a74fba4f7776;p=thirdparty%2Fmdadm.git Monitor: fix for regression with container devices This patch fixes 2 problems introduced by commit 9a518d8: not closing a file descriptor and ignoring container devices. Array state is always "inactive" for containers, so we make sure that the device is not a container by reading also the "level" sysfs entry. Signed-off-by: Artur Paszkiewicz Reviewed-by: Pawel Baldysiak Signed-off-by: NeilBrown --- diff --git a/Monitor.c b/Monitor.c index 971d2ecb..66d67baf 100644 --- a/Monitor.c +++ b/Monitor.c @@ -483,11 +483,17 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, strncmp(buf,"inact",5) == 0) { if (fd >= 0) close(fd); - if (!st->err) - alert("DeviceDisappeared", dev, NULL, ainfo); - st->err++; - return 0; + fd = sysfs_open(st->devnm, NULL, "level"); + if (fd < 0 || read(fd, buf, 10) != 0) { + if (fd >= 0) + close(fd); + if (!st->err) + alert("DeviceDisappeared", dev, NULL, ainfo); + st->err++; + return 0; + } } + close(fd); } fd = open(dev, O_RDONLY); if (fd < 0) {