dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/mdadm-3.2.6-mdmon-add-foreground-option.patch

373056
From 030419821fb77f9955f2017b4a6d3d8139d6db25 Mon Sep 17 00:00:00 2001
373056
From: NeilBrown <neilb@suse.de>
373056
Date: Tue, 5 Feb 2013 15:57:09 +1100
373056
Subject: [PATCH 4/4] mdmon: add --foreground option
373056
373056
While not strictly necessary for systemd, it is cleaner to avoid
373056
forking when running from a management daemon.  So add a --foreground
373056
option to mdmon.
373056
373056
Signed-off-by: NeilBrown <neilb@suse.de>
373056
---
373056
 mdmon.8                | 10 +++++++++-
373056
 mdmon.c                |  9 +++++++--
373056
 systemd/mdmon@.service |  2 +-
373056
 3 files changed, 17 insertions(+), 4 deletions(-)
373056
373056
diff --git a/mdmon.8 b/mdmon.8
373056
index 559dd90..a968cdb 100644
373056
--- a/mdmon.8
373056
+++ b/mdmon.8
373056
@@ -5,7 +5,7 @@ mdmon \- monitor MD external metadata arrays
373056
 
373056
 .SH SYNOPSIS
373056
 
373056
-.BI mdmon " [--all] [--takeover] CONTAINER"
373056
+.BI mdmon " [--all] [--takeover] [--foreground] CONTAINER"
373056
 
373056
 .SH OVERVIEW
373056
 The 2.6.27 kernel brings the ability to support external metadata arrays.
373056
@@ -131,6 +131,14 @@ The
373056
 device to monitor.  It can be a full path like /dev/md/container, or a
373056
 simple md device name like md127.
373056
 .TP
373056
+.B \-\-foreground
373056
+Normally,
373056
+.I mdmon
373056
+will fork and continue in the background.  Adding this option will
373056
+skip that step and run
373056
+.I mdmon
373056
+in the foreground.
373056
+.TP
373056
 .B \-\-takeover
373056
 This instructs
373056
 .I mdmon
373056
diff --git a/mdmon.c b/mdmon.c
373056
index 8720aa5..007071b 100644
373056
--- a/mdmon.c
373056
+++ b/mdmon.c
373056
@@ -288,11 +288,13 @@ int main(int argc, char *argv[])
373056
 	int opt;
373056
 	int all = 0;
373056
 	int takeover = 0;
373056
+	int dofork = 1;
373056
 	static struct option options[] = {
373056
 		{"all", 0, NULL, 'a'},
373056
 		{"takeover", 0, NULL, 't'},
373056
 		{"help", 0, NULL, 'h'},
373056
 		{"offroot", 0, NULL, OffRootOpt},
373056
+		{"foreground", 0, NULL, 'F'},
373056
 		{NULL, 0, NULL, 0}
373056
 	};
373056
 
373056
@@ -301,7 +303,7 @@ int main(int argc, char *argv[])
373056
 	 */
373056
 	argv[0][0] = '@';
373056
 
373056
-	while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
373056
+	while ((opt = getopt_long(argc, argv, "thaF", options, NULL)) != -1) {
373056
 		switch (opt) {
373056
 		case 'a':
373056
 			container_name = argv[optind-1];
373056
@@ -310,6 +312,9 @@ int main(int argc, char *argv[])
373056
 		case 't':
373056
 			takeover = 1;
373056
 			break;
373056
+		case 'F':
373056
+			dofork = 0;
373056
+			break;
373056
 		case OffRootOpt:
373056
 			/* silently ignore old option */
373056
 			break;
373056
@@ -381,7 +386,7 @@ int main(int argc, char *argv[])
373056
 			container_name);
373056
 		exit(1);
373056
 	}
373056
-	return mdmon(devname, devnum, do_fork(), takeover);
373056
+	return mdmon(devname, devnum, dofork && do_fork(), takeover);
373056
 }
373056
 
373056
 static int mdmon(char *devname, int devnum, int must_fork, int takeover)
373056
diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
373056
index ddb475f..809f527 100644
373056
--- a/systemd/mdmon@.service
373056
+++ b/systemd/mdmon@.service
373056
@@ -11,7 +11,7 @@ DefaultDependencies=no
373056
 Before=initrd-switch-root.target
373056
 
373056
 [Service]
373056
-ExecStart=/sbin/mdmon %I
373056
+ExecStart=/sbin/mdmon --foreground %I
373056
 StandardInput=null
373056
 StandardOutput=null
373056
 StandardError=null
373056
-- 
373056
1.7.11.7
373056