]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
RebuildMap: handle missing disks
authorDan Williams <dan.j.williams@intel.com>
Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)
When rebuilding the map file tolerate missing/offline disks, otherwise
we will segfault on the NULL return from sysfs_read.

Reported-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
mapfile.c

index ca7072ecf7219c2a5f6f531d36b68a272f479ea8..f27623221ce9e706cec05d29d0140447bcc7e3fa 100644 (file)
--- 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;