dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: bmarzins@sourceware.org
To: dm-cvs@sourceware.org, dm-devel@redhat.com
Subject: multipath-tools/multipathd main.c
Date: 12 Sep 2008 23:49:57 -0000	[thread overview]
Message-ID: <20080912234957.16468.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/dm
Module name:	multipath-tools
Branch: 	RHEL5_FC6
Changes by:	bmarzins@sourceware.org	2008-09-12 23:49:57

Modified files:
	multipathd     : main.c 

Log message:
	Fix for bz 449097.  When multipathd creates a new namespace for the
	callout functions, it now unmounts all of the unneeded mounts that it inherits
	the calling process.

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.12&r2=1.69.2.13

--- multipath-tools/multipathd/main.c	2008/09/08 22:01:20	1.69.2.12
+++ multipath-tools/multipathd/main.c	2008/09/12 23:49:57	1.69.2.13
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/mount.h>
 
 /*
  * libsysfs
@@ -62,6 +63,10 @@
 #include "waiter.h"
 #include "copy.h"
 
+#if !defined(MNT_DETACH)
+#define MNT_DETACH 2
+#endif
+
 #define FILE_NAME_SIZE 256
 #define CMDSIZE 160
 
@@ -1231,6 +1236,47 @@
 	return NULL;
 }
 
+static int
+unmount_extra_devs(void)
+{
+	int ret;
+	char buf[LINE_MAX];
+	FILE *file;
+
+	file = fopen("/proc/mounts", "r");
+	if (!file) {
+		condlog(0, "couldn't open /proc/mounts : %s", strerror(errno));
+		return -1;
+	}
+
+	while (fgets(buf, LINE_MAX, file)) {
+		char *end, *mnt = strchr(buf, ' ');
+		if (!mnt)
+			continue;
+		mnt++;
+		end = strchr(mnt, ' ');
+		if (!end) {
+			condlog(2, "can't process /proc/mounts line (%s). skipping", buf);
+			continue;
+		}
+		*end = '\0';
+		if (strcmp(mnt, "/") == 0 || strcmp(mnt, "/sbin") == 0 ||
+		    strcmp(mnt, "/bin") == 0 || strcmp(mnt, "/tmp") == 0 ||
+		    strcmp(mnt, "/usr") == 0 || strncmp(mnt, "/usr/lib", 8) == 0 ||
+		    strncmp(mnt, "/etc", 4) == 0 || strncmp(mnt, "/proc", 5) == 0 ||
+		    strncmp(mnt, "/dev", 4) == 0 || strncmp(mnt, "/sys", 4) == 0 ||
+		    strncmp(mnt, "/var", 4) == 0 || strncmp(mnt, "/lib", 4) == 0)
+			continue;
+		if (umount2(mnt, MNT_DETACH) < 0 && errno != ENOENT) {
+			condlog(0, "failed to umount '%s' (%s). skipping", mnt, strerror(errno));
+		}
+	}
+	fclose(file);
+	return ret;
+}	
+	
+	
+
 
 #ifdef CLONE_NEWNS
 static int
@@ -1328,7 +1374,8 @@
 		return -1;
 	}
 	condlog(4, "bind ramfs on /tmp");
-
+	if (unmount_extra_devs() < 0)
+		return -1;
 	return 0;
 }
 #endif

             reply	other threads:[~2008-09-12 23:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 23:49 bmarzins [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-08-10 18:49 multipath-tools/multipathd main.c bmarzins
2012-08-07 19:37 bmarzins
2012-03-22 18:02 bmarzins
2011-10-24 13:46 bmarzins
2011-10-10  3:47 bmarzins
2011-04-11 17:01 bmarzins
2010-12-07  6:02 bmarzins
2010-09-01 18:29 bmarzins
2010-08-09 16:16 bmarzins
2009-11-02 19:11 bmarzins
2009-09-10 16:27 bmarzins
2009-04-27 21:19 bmarzins
2008-10-17 18:37 bmarzins
2008-09-04 23:31 bmarzins
2008-05-12 18:48 bmarzins
2007-04-26 17:47 bmarzins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080912234957.16468.qmail@sourceware.org \
    --to=bmarzins@sourceware.org \
    --cc=dm-cvs@sourceware.org \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).