From: Dan Williams Date: Sun, 12 Apr 2009 07:58:28 +0000 (-0700) Subject: RebuildMap: handle missing disks X-Git-Tag: mdadm-3.0-rc1~28^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=506ffd1e0bd08cc74f5177d4f4db7c66d7724f6a;p=thirdparty%2Fmdadm.git RebuildMap: handle missing disks When rebuilding the map file tolerate missing/offline disks, otherwise we will segfault on the NULL return from sysfs_read. Reported-by: Jacek Danecki Signed-off-by: Dan Williams --- diff --git a/mapfile.c b/mapfile.c index ca7072ec..f2762322 100644 --- a/mapfile.c +++ b/mapfile.c @@ -294,9 +294,12 @@ void RebuildMap(void) int mdp = get_mdp_major(); for (md = mdstat ; md ; md = md->next) { - struct mdinfo *sra = sysfs_read(-1, md->devnum, GET_DEVS); + struct mdinfo *sra = sysfs_read(-1, md->devnum, GET_DEVS|SKIP_GONE_DEVS); struct mdinfo *sd; + if (!sra) + continue; + for (sd = sra->devs ; sd ; sd = sd->next) { char dn[30]; int dfd;