Dan Williams: RebuildMap: handle missing disks

Martin F. Krafft madduck at alioth.debian.org
Thu May 7 12:11:41 UTC 2009


Module: mdadm
Branch: debian/experimental
Commit: 506ffd1e0bd08cc74f5177d4f4db7c66d7724f6a
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=506ffd1e0bd08cc74f5177d4f4db7c66d7724f6a

Author: Dan Williams <dan.j.williams at intel.com>
Date:   Sun Apr 12 00:58:28 2009 -0700

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 <jacek.danecki at intel.com>
Signed-off-by: Dan Williams <dan.j.williams at intel.com>


---

 mapfile.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mapfile.c b/mapfile.c
index ca7072e..f276232 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;




More information about the pkg-mdadm-commits mailing list