Skip to contentSkip to conversation

multipath-tools/multipathd main.c

PATCH [email protected] 1 participant 1 message May 12, 2008 Device mapper

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/dm
Module name: multipath-tools
Branch: RHEL5_FC6
Changes by: [email protected] 2008-05-12 18:48:03

Modified files:
multipathd : main.c

Log message:
Fix multipathd startup so -d option works correctly.

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.6&r2=1.69.2.7

multipathd/main.c +21 -5
@@ -1422,15 +1422,31 @@
 	umask(0);
 }
 
+enum child_flag_bits {
+	__DAEMONIZE = 0,
+#ifdef CLONE_NEWNS
+	__NEW_NS,
+#endif
+};
+
+#define DAEMONIZE	(1 << __DAEMONIZE)
+#ifdef CLONE_NEWNS
+#define NEW_NS		(1 << __NEW_NS)
+#endif
+
 static int
 child (void * param)
 {
 	pthread_t check_thr, uevent_thr, uxlsnr_thr;
 	pthread_attr_t attr;
 	struct vectors * vecs;
-	unsigned long new_ns = (unsigned long)param;
+	unsigned int daemon = (unsigned long)param & DAEMONIZE;
+#ifdef CLONE_NEWNS
+	unsigned int new_ns = (unsigned long)param & NEW_NS;
+#endif
 
-	setup_daemon();
+	if (daemon)
+		setup_daemon();
 	mlockall(MCL_CURRENT | MCL_FUTURE);
 
 	if (logsink)
@@ -1583,11 +1599,11 @@
 #ifdef CLONE_NEWNS
 	if (unshare(CLONE_NEWNS) < 0) {
 		fprintf(stderr, "Failed to unshare namespace : %s\n", strerror(errno));
-		return child((void *)0);
+		return child((void *)DAEMONIZE);
 	}
-	return child((void *)1);
+	return child((void *)(DAEMONIZE | NEW_NS));
 #else
-	return child((void *)0);
+	return child((void *)DAEMONIZE);
 #endif
 }