Skip to contentSkip to conversation

multipath-tools/multipathd main.c

PATCH [email protected] 1 participant 1 message Mar 22, 2012 Device mapper

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/dm
Module name: multipath-tools
Branch: RHEL5_FC6
Changes by: [email protected] 2012-03-22 18:02:34

Modified files:
multipathd : main.c

Log message:
Fix for bz803849. applying patch from John Ruemker. multipathd was not correctly unmounting all unnecessary devices from its private namespace. Not applicable upstream.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.69.2.39&r2=1.69.2.40

multipathd/main.c +27 -4
@@ -1377,17 +1377,27 @@
 {
 	char buf[LINE_MAX];
 	FILE *file;
+	vector extra_devs;
+	char *slot;
+	int s;
 
 	file = fopen("/proc/mounts", "r");
 	if (!file) {
 		condlog(0, "couldn't open /proc/mounts : %s", strerror(errno));
 		return -1;
 	}
+
+	extra_devs = vector_alloc();
+	if (!extra_devs) {
+		condlog(0, "couldn't allocate vector for extra devs\n");
+		return -1;
+	}
+
 	find_keep_dirs();
 	while (fgets(buf, LINE_MAX, file)) {
 		int i;
 		char *keep;
-		char *end, *mnt = strchr(buf, ' ');
+		char *end, *extra, *mnt = strchr(buf, ' ');
 		if (!mnt)
 			continue;
 		mnt++;
@@ -1418,13 +1428,26 @@
 		    strncmp(mnt, "/lib64", 6) == 0 || strncmp(mnt, "/usr/lib64", 10) == 0 ||
 		    strncmp(mnt, "/ram", 4) == 0)
 			continue;
-		if (umount2(mnt, MNT_DETACH) < 0 && errno != ENOENT)
-			condlog(0, "failed to umount '%s' (%s). skipping", mnt,
-				strerror(errno));
+		if (!vector_alloc_slot(extra_devs)) {
+			condlog(2, "couldn't allocate vector slot for extra dev (%s). "
+				"skipping,", mnt);
+			continue;
+ 		}
+		extra = strdup(mnt);
+		vector_set_slot(extra_devs, extra);
 next:
 		;
 	}
 	fclose(file);
+
+	vector_foreach_slot(extra_devs, slot, s) {
+	        if (umount2(slot, MNT_DETACH) < 0 && errno != ENOENT) {
+                        condlog(0, "failed to umount '%s' (%s). skipping",
+				slot, strerror(errno));
+                }
+		free(slot);
+	}
+	vector_free(extra_devs);
 	return 0;
 }