f20720
---
f20720
 libmultipath/config.h    |   15 ++++++++-
f20720
 libmultipath/configure.c |    2 -
f20720
 libmultipath/discovery.c |    5 +--
f20720
 multipath/main.c         |   75 +++++++++++++++++++++++++----------------------
f20720
 multipath/multipath.8    |    5 ++-
f20720
 5 files changed, 61 insertions(+), 41 deletions(-)
f20720
f20720
Index: multipath-tools-130222/libmultipath/config.h
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/config.h
f20720
+++ multipath-tools-130222/libmultipath/config.h
f20720
@@ -23,6 +23,17 @@ enum devtypes {
f20720
 	DEV_DEVMAP
f20720
 };
f20720
 
f20720
+enum mpath_cmds {
f20720
+	CMD_CREATE,
f20720
+	CMD_DRY_RUN,
f20720
+	CMD_LIST_SHORT,
f20720
+	CMD_LIST_LONG,
f20720
+	CMD_VALID_PATH,
f20720
+	CMD_REMOVE_WWID,
f20720
+	CMD_RESET_WWIDS,
f20720
+	CMD_ADD_WWID,
f20720
+};
f20720
+
f20720
 struct hwentry {
f20720
 	char * vendor;
f20720
 	char * product;
f20720
@@ -79,8 +90,7 @@ struct mpentry {
f20720
 
f20720
 struct config {
f20720
 	int verbosity;
f20720
-	int dry_run;
f20720
-	int list;
f20720
+	enum mpath_cmds cmd;
f20720
 	int pgpolicy_flag;
f20720
 	int pgpolicy;
f20720
 	enum devtypes dev_type;
f20720
@@ -98,6 +108,7 @@ struct config {
f20720
 	int max_fds;
f20720
 	int force_reload;
f20720
 	int queue_without_daemon;
f20720
+	int ignore_wwids;
f20720
 	int checker_timeout;
f20720
 	int daemon;
f20720
 	int flush_on_last_del;
f20720
Index: multipath-tools-130222/multipath/main.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipath/main.c
f20720
+++ multipath-tools-130222/multipath/main.c
f20720
@@ -85,7 +85,7 @@ usage (char * progname)
f20720
 {
f20720
 	fprintf (stderr, VERSION_STRING);
f20720
 	fprintf (stderr, "Usage:\n");
f20720
-	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
f20720
+	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-i] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
f20720
 	fprintf (stderr, "  %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
f20720
 	fprintf (stderr, "  %s -F [-v lvl]\n", progname);
f20720
 	fprintf (stderr, "  %s -t\n", progname);
f20720
@@ -109,6 +109,7 @@ usage (char * progname)
f20720
 		"  -d      dry run, do not create or update devmaps\n" \
f20720
 		"  -t      dump internal hardware table\n" \
f20720
 		"  -r      force devmap reload\n" \
f20720
+		"  -i      ignore wwids file\n" \
f20720
 		"  -B      treat the bindings file as read only\n" \
f20720
 		"  -p      policy failover|multibus|group_by_serial|group_by_prio\n" \
f20720
 		"  -b fil  bindings file location\n" \
f20720
@@ -209,18 +210,19 @@ get_dm_mpvec (vector curmp, vector pathv
f20720
 		 * If not in "fast list mode", we need to fetch information
f20720
 		 * about them
f20720
 		 */
f20720
-		if (conf->list != 1)
f20720
+		if (conf->cmd != CMD_LIST_SHORT)
f20720
 			update_paths(mpp);
f20720
 
f20720
-		if (conf->list > 1)
f20720
+		if (conf->cmd == CMD_LIST_LONG)
f20720
 			mpp->bestpg = select_path_group(mpp);
f20720
 
f20720
 		disassemble_status(status, mpp);
f20720
 
f20720
-		if (conf->list)
f20720
+		if (conf->cmd == CMD_LIST_SHORT ||
f20720
+		    conf->cmd == CMD_LIST_LONG)
f20720
 			print_multipath_topology(mpp, conf->verbosity);
f20720
 
f20720
-		if (!conf->dry_run)
f20720
+		if (conf->cmd == CMD_CREATE)
f20720
 			reinstate_paths(mpp);
f20720
 	}
f20720
 	return 0;
f20720
@@ -262,10 +264,11 @@ configure (void)
f20720
 	/*
f20720
 	 * if we have a blacklisted device parameter, exit early
f20720
 	 */
f20720
-	if (dev && conf->dev_type == DEV_DEVNODE && conf->dry_run != 3 &&
f20720
+	if (dev && conf->dev_type == DEV_DEVNODE &&
f20720
+	    conf->cmd != CMD_REMOVE_WWID &&
f20720
 	    (filter_devnode(conf->blist_devnode,
f20720
 			    conf->elist_devnode, dev) > 0)) {
f20720
-		if (conf->dry_run == 2)
f20720
+		if (conf->cmd == CMD_VALID_PATH)
f20720
 			printf("%s is not a valid multipath device path\n",
f20720
 			       conf->dev);
f20720
 		goto out;
f20720
@@ -278,13 +281,13 @@ configure (void)
f20720
 		int failed = get_refwwid(conf->dev, conf->dev_type, pathvec,
f20720
 					 &refwwid);
f20720
 		if (!refwwid) {
f20720
-			if (failed == 2 && conf->dry_run == 2)
f20720
+			if (failed == 2 && conf->cmd == CMD_VALID_PATH)
f20720
 				printf("%s is not a valid multipath device path\n", conf->dev);
f20720
 			else
f20720
 				condlog(3, "scope is nul");
f20720
 			goto out;
f20720
 		}
f20720
-		if (conf->dry_run == 3) {
f20720
+		if (conf->cmd == CMD_REMOVE_WWID) {
f20720
 			r = remove_wwid(refwwid);
f20720
 			if (r == 0)
f20720
 				printf("wwid '%s' removed\n", refwwid);
f20720
@@ -295,7 +298,7 @@ configure (void)
f20720
 			}
f20720
 			goto out;
f20720
 		}
f20720
-		if (conf->dry_run == 5) {
f20720
+		if (conf->cmd == CMD_ADD_WWID) {
f20720
 			r = remember_wwid(refwwid);
f20720
 			if (r == 0)
f20720
 				printf("wwid '%s' added\n", refwwid);
f20720
@@ -305,13 +308,13 @@ configure (void)
f20720
 			goto out;
f20720
 		}
f20720
 		condlog(3, "scope limited to %s", refwwid);
f20720
-		if (conf->dry_run == 2) {
f20720
-			if (check_wwids_file(refwwid, 0) == 0){
f20720
-				printf("%s is a valid multipath device path\n", conf->dev);
f20720
+		if (conf->cmd == CMD_VALID_PATH) {
f20720
+			if (conf->ignore_wwids ||
f20720
+			    check_wwids_file(refwwid, 0) == 0)
f20720
 				r = 0;
f20720
-			}
f20720
-			else
f20720
-				printf("%s is not a valid multipath device path\n", conf->dev);
f20720
+
f20720
+			printf("%s %s a valid multipath device path\n",
f20720
+			       conf->dev, r == 0 ? "is" : "is not");
f20720
 			goto out;
f20720
 		}
f20720
 	}
f20720
@@ -319,13 +322,13 @@ configure (void)
f20720
 	/*
f20720
 	 * get a path list
f20720
 	 */
f20720
-	if (conf->dev && !conf->list)
f20720
+	if (conf->dev)
f20720
 		di_flag = DI_WWID;
f20720
 
f20720
-	if (conf->list > 1)
f20720
+	if (conf->cmd == CMD_LIST_LONG)
f20720
 		/* extended path info '-ll' */
f20720
 		di_flag |= DI_SYSFS | DI_CHECKER;
f20720
-	else if (conf->list)
f20720
+	else if (conf->cmd == CMD_LIST_SHORT)
f20720
 		/* minimum path info '-l' */
f20720
 		di_flag |= DI_SYSFS;
f20720
 	else
f20720
@@ -345,7 +348,7 @@ configure (void)
f20720
 
f20720
 	filter_pathvec(pathvec, refwwid);
f20720
 
f20720
-	if (conf->list) {
f20720
+	if (conf->cmd != CMD_CREATE && conf->cmd != CMD_DRY_RUN) {
f20720
 		r = 0;
f20720
 		goto out;
f20720
 	}
f20720
@@ -440,7 +443,7 @@ main (int argc, char *argv[])
f20720
 	int r = 1;
f20720
 	long int timestamp = -1;
f20720
 	int valid = -1;
f20720
-	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BritT:qwW")) != EOF ) {
f20720
 		switch(arg) {
f20720
 		case 'T':
f20720
 			if (optarg[0] == ':')
f20720
@@ -476,7 +479,7 @@ main (int argc, char *argv[])
f20720
 	if (dm_prereq())
f20720
 		exit(1);
f20720
 
f20720
-	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BritT:qwW")) != EOF ) {
f20720
 		switch(arg) {
f20720
 		case 1: printf("optarg : %s\n",optarg);
f20720
 			break;
f20720
@@ -499,11 +502,11 @@ main (int argc, char *argv[])
f20720
 			conf->allow_queueing = 1;
f20720
 			break;
f20720
 		case 'c':
f20720
-			conf->dry_run = 2;
f20720
+			conf->cmd = CMD_VALID_PATH;
f20720
 			break;
f20720
 		case 'd':
f20720
-			if (!conf->dry_run)
f20720
-				conf->dry_run = 1;
f20720
+			if (conf->cmd == CMD_CREATE)
f20720
+				conf->cmd = CMD_DRY_RUN;
f20720
 			break;
f20720
 		case 'f':
f20720
 			conf->remove = FLUSH_ONE;
f20720
@@ -512,11 +515,10 @@ main (int argc, char *argv[])
f20720
 			conf->remove = FLUSH_ALL;
f20720
 			break;
f20720
 		case 'l':
f20720
-			conf->list = 1;
f20720
-			conf->dry_run = 1;
f20720
-
f20720
 			if (optarg && !strncmp(optarg, "l", 1))
f20720
-				conf->list++;
f20720
+				conf->cmd = CMD_LIST_LONG;
f20720
+			else
f20720
+				conf->cmd = CMD_LIST_SHORT;
f20720
 
f20720
 			break;
f20720
 		case 'M':
f20720
@@ -535,6 +537,9 @@ main (int argc, char *argv[])
f20720
 		case 'r':
f20720
 			conf->force_reload = 1;
f20720
 			break;
f20720
+		case 'i':
f20720
+			conf->ignore_wwids = 1;
f20720
+			break;
f20720
 		case 't':
f20720
 			r = dump_config();
f20720
 			goto out;
f20720
@@ -548,13 +553,13 @@ main (int argc, char *argv[])
f20720
 			usage(argv[0]);
f20720
 			exit(0);
f20720
 		case 'w':
f20720
-			conf->dry_run = 3;
f20720
+			conf->cmd = CMD_REMOVE_WWID;
f20720
 			break;
f20720
 		case 'W':
f20720
-			conf->dry_run = 4;
f20720
+			conf->cmd = CMD_RESET_WWIDS;
f20720
 			break;
f20720
 		case 'a':
f20720
-			conf->dry_run = 5;
f20720
+			conf->cmd = CMD_ADD_WWID;
f20720
 			break;
f20720
 		case ':':
f20720
 			fprintf(stderr, "Missing option argument\n");
f20720
@@ -600,16 +605,16 @@ main (int argc, char *argv[])
f20720
 	}
f20720
 	dm_init();
f20720
 
f20720
-	if (conf->dry_run == 2 &&
f20720
+	if (conf->cmd == CMD_VALID_PATH &&
f20720
 	    (!conf->dev || conf->dev_type == DEV_DEVMAP)) {
f20720
 		condlog(0, "the -c option requires a path to check");
f20720
 		goto out;
f20720
 	}
f20720
-	if (conf->dry_run == 3 && !conf->dev) {
f20720
+	if (conf->cmd == CMD_REMOVE_WWID && !conf->dev) {
f20720
 		condlog(0, "the -w option requires a device");
f20720
 		goto out;
f20720
 	}
f20720
-	if (conf->dry_run == 4) {
f20720
+	if (conf->cmd == CMD_RESET_WWIDS) {
f20720
 		struct multipath * mpp;
f20720
 		int i;
f20720
 		vector curmp;
f20720
Index: multipath-tools-130222/multipath/multipath.8
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipath/multipath.8
f20720
+++ multipath-tools-130222/multipath/multipath.8
f20720
@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco
f20720
 .RB [\| \-b\ \c
f20720
 .IR bindings_file \|]
f20720
 .RB [\| \-d \|]
f20720
-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-A | \-w | \-W \|]
f20720
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-r | \-a | \-A | \-w | \-W \|]
f20720
 .RB [\| \-p\ \c
f20720
 .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
f20720
 .RB [\| device \|]
f20720
@@ -55,6 +55,9 @@ print internal hardware table to stdout
f20720
 .B \-r
f20720
 force devmap reload
f20720
 .TP
f20720
+.B \-i
f20720
+ignore wwids file when processing devices
f20720
+.TP
f20720
 .B \-B
f20720
 treat the bindings file as read only
f20720
 .TP
f20720
Index: multipath-tools-130222/libmultipath/configure.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/configure.c
f20720
+++ multipath-tools-130222/libmultipath/configure.c
f20720
@@ -580,7 +580,7 @@ domap (struct multipath * mpp, char * pa
f20720
 	/*
f20720
 	 * last chance to quit before touching the devmaps
f20720
 	 */
f20720
-	if (conf->dry_run && mpp->action != ACT_NOTHING) {
f20720
+	if (conf->cmd == CMD_DRY_RUN && mpp->action != ACT_NOTHING) {
f20720
 		print_multipath_topology(mpp, conf->verbosity);
f20720
 		return DOMAP_DRY;
f20720
 	}
f20720
Index: multipath-tools-130222/libmultipath/discovery.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/discovery.c
f20720
+++ multipath-tools-130222/libmultipath/discovery.c
f20720
@@ -54,7 +54,8 @@ store_pathinfo (vector pathvec, vector h
f20720
 	}
f20720
 	pp->udev = udev_device_ref(udevice);
f20720
 	err = pathinfo(pp, hwtable,
f20720
-		       (conf->dry_run == 3)? flag : (flag | DI_BLACKLIST));
f20720
+		       (conf->cmd == CMD_REMOVE_WWID)? flag :
f20720
+						       (flag | DI_BLACKLIST));
f20720
 	if (err)
f20720
 		goto out;
f20720
 
f20720
@@ -1101,7 +1102,7 @@ get_uid (struct path * pp)
f20720
 
f20720
 	memset(pp->wwid, 0, WWID_SIZE);
f20720
 	value = udev_device_get_property_value(pp->udev, pp->uid_attribute);
f20720
-	if ((!value || strlen(value) == 0) && conf->dry_run == 2)
f20720
+	if ((!value || strlen(value) == 0) && conf->cmd == CMD_VALID_PATH)
f20720
 		value = getenv(pp->uid_attribute);
f20720
 	if (value && strlen(value)) {
f20720
 		size_t len = WWID_SIZE;