Blame SOURCES/0080-RHBZ-1075796-cmdline-wwid.patch

e41771
---
e41771
 libmultipath/wwids.c          |   44 ++++++++++++++++++++++++++++++++++++++++++
e41771
 libmultipath/wwids.h          |    1 
e41771
 multipath/main.c              |   12 ++++++++---
e41771
 multipath/multipath.8         |    5 +++-
e41771
 multipathd/multipathd.service |    1 
e41771
 5 files changed, 59 insertions(+), 4 deletions(-)
e41771
e41771
Index: multipath-tools-130222/libmultipath/wwids.c
e41771
===================================================================
e41771
--- multipath-tools-130222.orig/libmultipath/wwids.c
e41771
+++ multipath-tools-130222/libmultipath/wwids.c
e41771
@@ -305,3 +305,47 @@ remember_wwid(char *wwid)
e41771
 		condlog(4, "wwid %s already in wwids file", wwid);
e41771
 	return 0;
e41771
 }
e41771
+
e41771
+int remember_cmdline_wwid(void)
e41771
+{
e41771
+	FILE *f = NULL;
e41771
+	char buf[LINE_MAX], *next, *ptr;
e41771
+	int ret = 0;
e41771
+
e41771
+	f = fopen("/proc/cmdline", "re");
e41771
+	if (!f) {
e41771
+		condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
e41771
+		return -1;
e41771
+	}
e41771
+
e41771
+	if (!fgets(buf, sizeof(buf), f)) {
e41771
+		if (ferror(f))
e41771
+			condlog(0, "read of /proc/cmdline failed : %s",
e41771
+				strerror(errno));
e41771
+		else
e41771
+			condlog(0, "couldn't read /proc/cmdline");
e41771
+		fclose(f);
e41771
+		return -1;
e41771
+	}
e41771
+	fclose(f);
e41771
+	next = buf;
e41771
+	while((ptr = strstr(next, "mpath.wwid="))) {
e41771
+		ptr += 11;
e41771
+		next = strpbrk(ptr, " \t\n");
e41771
+		if (next) {
e41771
+			*next = '\0';
e41771
+			next++;
e41771
+		}
e41771
+		if (strlen(ptr)) {
e41771
+			if (remember_wwid(ptr) != 0)
e41771
+				ret = -1;
e41771
+		}
e41771
+		else {
e41771
+			condlog(0, "empty mpath.wwid kernel command line option");
e41771
+			ret = -1;
e41771
+		}
e41771
+		if (!next)
e41771
+			break;
e41771
+	}
e41771
+	return ret;
e41771
+}
e41771
Index: multipath-tools-130222/libmultipath/wwids.h
e41771
===================================================================
e41771
--- multipath-tools-130222.orig/libmultipath/wwids.h
e41771
+++ multipath-tools-130222/libmultipath/wwids.h
e41771
@@ -17,5 +17,6 @@ int remember_wwid(char *wwid);
e41771
 int check_wwids_file(char *wwid, int write_wwid);
e41771
 int remove_wwid(char *wwid);
e41771
 int replace_wwids(vector mp);
e41771
+int remember_cmdline_wwid(void);
e41771
 
e41771
 #endif /* _WWIDS_H */
e41771
Index: multipath-tools-130222/multipath/main.c
e41771
===================================================================
e41771
--- multipath-tools-130222.orig/multipath/main.c
e41771
+++ multipath-tools-130222/multipath/main.c
e41771
@@ -85,7 +85,7 @@ usage (char * progname)
e41771
 {
e41771
 	fprintf (stderr, VERSION_STRING);
e41771
 	fprintf (stderr, "Usage:\n");
e41771
-	fprintf (stderr, "  %s [-a|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
e41771
+	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
e41771
 	fprintf (stderr, "  %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
e41771
 	fprintf (stderr, "  %s -F [-v lvl]\n", progname);
e41771
 	fprintf (stderr, "  %s -t\n", progname);
e41771
@@ -99,6 +99,8 @@ usage (char * progname)
e41771
 		"  -f      flush a multipath device map\n" \
e41771
 		"  -F      flush all multipath device maps\n" \
e41771
 		"  -a      add a device wwid to the wwids file\n" \
e41771
+		"  -A      add devices from kernel command line mpath.wwids\n"
e41771
+		"          parameters to wwids file\n" \
e41771
 		"  -c      check if a device should be a path in a multipath device\n" \
e41771
 		"  -T tm:val\n" \
e41771
 		"          check if tm matches the multipathd timestamp. If so val is\n" \
e41771
@@ -438,7 +440,7 @@ main (int argc, char *argv[])
e41771
 	int r = 1;
e41771
 	long int timestamp = -1;
e41771
 	int valid = -1;
e41771
-	while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
e41771
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
e41771
 		switch(arg) {
e41771
 		case 'T':
e41771
 			if (optarg[0] == ':')
e41771
@@ -474,7 +476,7 @@ main (int argc, char *argv[])
e41771
 	if (dm_prereq())
e41771
 		exit(1);
e41771
 
e41771
-	while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
e41771
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
e41771
 		switch(arg) {
e41771
 		case 1: printf("optarg : %s\n",optarg);
e41771
 			break;
e41771
@@ -538,6 +540,10 @@ main (int argc, char *argv[])
e41771
 			goto out;
e41771
 		case 'T':
e41771
 			break;
e41771
+		case 'A':
e41771
+			if (remember_cmdline_wwid() != 0)
e41771
+				exit(1);
e41771
+			exit(0);
e41771
 		case 'h':
e41771
 			usage(argv[0]);
e41771
 			exit(0);
e41771
Index: multipath-tools-130222/multipathd/multipathd.service
e41771
===================================================================
e41771
--- multipath-tools-130222.orig/multipathd/multipathd.service
e41771
+++ multipath-tools-130222/multipathd/multipathd.service
e41771
@@ -11,6 +11,7 @@ Conflicts=shutdown.target
e41771
 Type=forking
e41771
 PIDFile=/var/run/multipathd/multipathd.pid
e41771
 ExecStartPre=/sbin/modprobe dm-multipath
e41771
+ExecStartPre=-/sbin/multipath -A
e41771
 ExecStart=/sbin/multipathd
e41771
 ExecReload=/sbin/multipathd reconfigure
e41771
 #ExecStop=/path/to/scrip delete-me if not necessary
e41771
Index: multipath-tools-130222/multipath/multipath.8
e41771
===================================================================
e41771
--- multipath-tools-130222.orig/multipath/multipath.8
e41771
+++ multipath-tools-130222/multipath/multipath.8
e41771
@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco
e41771
 .RB [\| \-b\ \c
e41771
 .IR bindings_file \|]
e41771
 .RB [\| \-d \|]
e41771
-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-w | \-W \|]
e41771
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-A | \-w | \-W \|]
e41771
 .RB [\| \-p\ \c
e41771
 .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
e41771
 .RB [\| device \|]
e41771
@@ -71,6 +71,9 @@ allow device tables with queue_if_no_pat
e41771
 .B \-a
e41771
 add the wwid for the specified device to the wwids file
e41771
 .TP
e41771
+.B \-A
e41771
+add wwids from any kernel command line mpath.wwid parameters to the wwids file
e41771
+.TP
e41771
 .B \-w
e41771
 remove the wwid for the specified device from the wwids file
e41771
 .TP