Blame SOURCES/0146-UPBZ-1299651-raw-output.patch

4ae388
---
4ae388
 libmultipath/print.c      |   42 ++++++++++++++++++++++++----------------
4ae388
 libmultipath/print.h      |    4 +--
4ae388
 multipathd/cli.c          |    5 +++-
4ae388
 multipathd/cli.h          |    6 +++--
4ae388
 multipathd/cli_handlers.c |   48 ++++++++++++++++++++++++++++++++++------------
4ae388
 multipathd/cli_handlers.h |    2 +
4ae388
 multipathd/main.c         |    2 +
4ae388
 7 files changed, 76 insertions(+), 33 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222/libmultipath/print.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.c
4ae388
+++ multipath-tools-130222/libmultipath/print.c
4ae388
@@ -32,14 +32,21 @@
4ae388
 #define MAX(x,y) (x > y) ? x : y
4ae388
 #define TAIL     (line + len - 1 - c)
4ae388
 #define NOPAD    s = c
4ae388
-#define PAD(x)   while ((int)(c - s) < (x) && (c < (line + len - 1))) \
4ae388
-			*c++ = ' '; s = c
4ae388
+#define PAD(x) \
4ae388
+do { \
4ae388
+	while ((int)(c - s) < (x) && (c < (line + len - 1))) \
4ae388
+		*c++ = ' '; \
4ae388
+		s = c; \
4ae388
+} while (0)
4ae388
+
4ae388
 #define ENDLINE \
4ae388
 		if (c > line) \
4ae388
 			line[c - line - 1] = '\n'
4ae388
-#define PRINT(var, size, format, args...)      \
4ae388
-		fwd = snprintf(var, size, format, ##args); \
4ae388
-		 c += (fwd >= size) ? size : fwd;
4ae388
+#define PRINT(var, size, format, args...) \
4ae388
+do { \
4ae388
+	fwd = snprintf(var, size, format, ##args); \
4ae388
+	c += (fwd >= size) ? size : fwd; \
4ae388
+} while (0)
4ae388
 
4ae388
 /*
4ae388
  * information printing helpers
4ae388
@@ -720,7 +727,7 @@ snprint_multipath_header (char * line, i
4ae388
 
4ae388
 int
4ae388
 snprint_multipath (char * line, int len, char * format,
4ae388
-	     struct multipath * mpp)
4ae388
+	     struct multipath * mpp, int pad)
4ae388
 {
4ae388
 	char * c = line;   /* line cursor */
4ae388
 	char * s = line;   /* for padding */
4ae388
@@ -747,7 +754,8 @@ snprint_multipath (char * line, int len,
4ae388
 
4ae388
 		data->snprint(buff, MAX_FIELD_LEN, mpp);
4ae388
 		PRINT(c, TAIL, "%s", buff);
4ae388
-		PAD(data->width);
4ae388
+		if (pad)
4ae388
+			PAD(data->width);
4ae388
 		buff[0] = '\0';
4ae388
 	} while (*f++);
4ae388
 
4ae388
@@ -790,7 +798,7 @@ snprint_path_header (char * line, int le
4ae388
 
4ae388
 int
4ae388
 snprint_path (char * line, int len, char * format,
4ae388
-	     struct path * pp)
4ae388
+	     struct path * pp, int pad)
4ae388
 {
4ae388
 	char * c = line;   /* line cursor */
4ae388
 	char * s = line;   /* for padding */
4ae388
@@ -817,7 +825,8 @@ snprint_path (char * line, int len, char
4ae388
 
4ae388
 		data->snprint(buff, MAX_FIELD_LEN, pp);
4ae388
 		PRINT(c, TAIL, "%s", buff);
4ae388
-		PAD(data->width);
4ae388
+		if (pad)
4ae388
+			PAD(data->width);
4ae388
 	} while (*f++);
4ae388
 
4ae388
 	ENDLINE;
4ae388
@@ -909,7 +918,7 @@ snprint_multipath_topology (char * buff,
4ae388
 	reset_multipath_layout();
4ae388
 
4ae388
 	if (verbosity == 1)
4ae388
-		return snprint_multipath(buff, len, "%n", mpp);
4ae388
+		return snprint_multipath(buff, len, "%n", mpp, 1);
4ae388
 
4ae388
 	if(isatty(1))
4ae388
 		c += sprintf(c, "%c[%dm", 0x1B, 1); /* bold on */
4ae388
@@ -928,10 +937,11 @@ snprint_multipath_topology (char * buff,
4ae388
 	if(isatty(1))
4ae388
 		c += sprintf(c, "%c[%dm", 0x1B, 0); /* bold off */
4ae388
 
4ae388
-	fwd += snprint_multipath(buff + fwd, len - fwd, style, mpp);
4ae388
+	fwd += snprint_multipath(buff + fwd, len - fwd, style, mpp, 1);
4ae388
 	if (fwd > len)
4ae388
 		return len;
4ae388
-	fwd += snprint_multipath(buff + fwd, len - fwd, PRINT_MAP_PROPS, mpp);
4ae388
+	fwd += snprint_multipath(buff + fwd, len - fwd, PRINT_MAP_PROPS, mpp,
4ae388
+				 1);
4ae388
 	if (fwd > len)
4ae388
 		return len;
4ae388
 
4ae388
@@ -958,7 +968,7 @@ snprint_multipath_topology (char * buff,
4ae388
 				strcpy(f, " |- " PRINT_PATH_INDENT);
4ae388
 			else
4ae388
 				strcpy(f, " `- " PRINT_PATH_INDENT);
4ae388
-			fwd += snprint_path(buff + fwd, len - fwd, fmt, pp);
4ae388
+			fwd += snprint_path(buff + fwd, len - fwd, fmt, pp, 1);
4ae388
 			if (fwd > len)
4ae388
 				return len;
4ae388
 		}
4ae388
@@ -1425,7 +1435,7 @@ snprint_devices (char * buff, int len, s
4ae388
 			if (r > 0)
4ae388
 				fwd += snprintf(buff + fwd, len - fwd,
4ae388
 						" devnode blacklisted, unmonitored");
4ae388
-			else if (r < 0)
4ae388
+			else if (r <= 0)
4ae388
 				fwd += snprintf(buff + fwd, len - fwd,
4ae388
 						" devnode whitelisted, unmonitored");
4ae388
 		} else
4ae388
@@ -1455,7 +1465,7 @@ print_path (struct path * pp, char * sty
4ae388
 	char line[MAX_LINE_LEN];
4ae388
 
4ae388
 	memset(&line[0], 0, MAX_LINE_LEN);
4ae388
-	snprint_path(&line[0], MAX_LINE_LEN, style, pp);
4ae388
+	snprint_path(&line[0], MAX_LINE_LEN, style, pp, 1);
4ae388
 	printf("%s", line);
4ae388
 }
4ae388
 
4ae388
@@ -1465,7 +1475,7 @@ print_multipath (struct multipath * mpp,
4ae388
 	char line[MAX_LINE_LEN];
4ae388
 
4ae388
 	memset(&line[0], 0, MAX_LINE_LEN);
4ae388
-	snprint_multipath(&line[0], MAX_LINE_LEN, style, mpp);
4ae388
+	snprint_multipath(&line[0], MAX_LINE_LEN, style, mpp, 1);
4ae388
 	printf("%s", line);
4ae388
 }
4ae388
 
4ae388
Index: multipath-tools-130222/libmultipath/print.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.h
4ae388
+++ multipath-tools-130222/libmultipath/print.h
4ae388
@@ -37,8 +37,8 @@ void get_path_layout (vector pathvec, in
4ae388
 void get_multipath_layout (vector mpvec, int header);
4ae388
 int snprint_path_header (char *, int, char *);
4ae388
 int snprint_multipath_header (char *, int, char *);
4ae388
-int snprint_path (char *, int, char *, struct path *);
4ae388
-int snprint_multipath (char *, int, char *, struct multipath *);
4ae388
+int snprint_path (char *, int, char *, struct path *, int);
4ae388
+int snprint_multipath (char *, int, char *, struct multipath *, int);
4ae388
 int snprint_multipath_topology (char *, int, struct multipath * mpp,
4ae388
 				int verbosity);
4ae388
 int snprint_defaults (char *, int);
4ae388
Index: multipath-tools-130222/multipathd/cli.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli.c
4ae388
+++ multipath-tools-130222/multipathd/cli.c
4ae388
@@ -180,7 +180,7 @@ load_keys (void)
4ae388
 	r += add_key(keys, "config", CONFIG, 0);
4ae388
 	r += add_key(keys, "blacklist", BLACKLIST, 0);
4ae388
 	r += add_key(keys, "devices", DEVICES, 0);
4ae388
-	r += add_key(keys, "format", FMT, 1);
4ae388
+	r += add_key(keys, "raw", RAW, 0);
4ae388
 	r += add_key(keys, "wildcards", WILDCARDS, 0);
4ae388
 	r += add_key(keys, "quit", QUIT, 0);
4ae388
 	r += add_key(keys, "exit", QUIT, 0);
4ae388
@@ -188,6 +188,7 @@ load_keys (void)
4ae388
 	r += add_key(keys, "getprstatus", GETPRSTATUS, 0);
4ae388
 	r += add_key(keys, "setprstatus", SETPRSTATUS, 0);
4ae388
 	r += add_key(keys, "unsetprstatus", UNSETPRSTATUS, 0);
4ae388
+	r += add_key(keys, "format", FMT, 1);
4ae388
 
4ae388
 	if (r) {
4ae388
 		free_keys(keys);
4ae388
@@ -463,12 +464,14 @@ cli_init (void) {
4ae388
 
4ae388
 	add_handler(LIST+PATHS, NULL);
4ae388
 	add_handler(LIST+PATHS+FMT, NULL);
4ae388
+	add_handler(LIST+PATHS+RAW+FMT, NULL);
4ae388
 	add_handler(LIST+STATUS, NULL);
4ae388
 	add_handler(LIST+DAEMON, NULL);
4ae388
 	add_handler(LIST+MAPS, NULL);
4ae388
 	add_handler(LIST+MAPS+STATUS, NULL);
4ae388
 	add_handler(LIST+MAPS+STATS, NULL);
4ae388
 	add_handler(LIST+MAPS+FMT, NULL);
4ae388
+	add_handler(LIST+MAPS+RAW+FMT, NULL);
4ae388
 	add_handler(LIST+MAPS+TOPOLOGY, NULL);
4ae388
 	add_handler(LIST+TOPOLOGY, NULL);
4ae388
 	add_handler(LIST+MAP+TOPOLOGY, NULL);
4ae388
Index: multipath-tools-130222/multipathd/cli.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli.h
4ae388
+++ multipath-tools-130222/multipathd/cli.h
4ae388
@@ -26,13 +26,14 @@ enum {
4ae388
 	__CONFIG,
4ae388
 	__BLACKLIST,
4ae388
 	__DEVICES,
4ae388
-	__FMT,
4ae388
+	__RAW,
4ae388
 	__WILDCARDS,
4ae388
 	__QUIT,
4ae388
 	__SHUTDOWN,
4ae388
 	__GETPRSTATUS,
4ae388
 	__SETPRSTATUS,
4ae388
 	__UNSETPRSTATUS,
4ae388
+	__FMT,
4ae388
 };
4ae388
 
4ae388
 #define LIST		(1 << __LIST)
4ae388
@@ -62,7 +63,7 @@ enum {
4ae388
 #define CONFIG		(1 << __CONFIG)
4ae388
 #define BLACKLIST	(1 << __BLACKLIST)
4ae388
 #define DEVICES		(1 << __DEVICES)
4ae388
-#define FMT		(1 << __FMT)
4ae388
+#define RAW		(1 << __RAW)
4ae388
 #define COUNT		(1 << __COUNT)
4ae388
 #define WILDCARDS	(1 << __WILDCARDS)
4ae388
 #define QUIT		(1 << __QUIT)
4ae388
@@ -70,6 +71,7 @@ enum {
4ae388
 #define GETPRSTATUS	(1UL << __GETPRSTATUS)
4ae388
 #define SETPRSTATUS	(1UL << __SETPRSTATUS)
4ae388
 #define UNSETPRSTATUS	(1UL << __UNSETPRSTATUS)
4ae388
+#define FMT		(1UL << __FMT)
4ae388
 
4ae388
 #define INITIAL_REPLY_LEN	1200
4ae388
 
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.c
4ae388
@@ -24,7 +24,8 @@
4ae388
 #include "uevent.h"
4ae388
 
4ae388
 int
4ae388
-show_paths (char ** r, int * len, struct vectors * vecs, char * style)
4ae388
+show_paths (char ** r, int * len, struct vectors * vecs, char * style,
4ae388
+	    int pretty)
4ae388
 {
4ae388
 	int i;
4ae388
 	struct path * pp;
4ae388
@@ -42,13 +43,13 @@ show_paths (char ** r, int * len, struct
4ae388
 
4ae388
 		c = reply;
4ae388
 
4ae388
-		if (VECTOR_SIZE(vecs->pathvec) > 0)
4ae388
+		if (pretty && VECTOR_SIZE(vecs->pathvec) > 0)
4ae388
 			c += snprint_path_header(c, reply + maxlen - c,
4ae388
 						 style);
4ae388
 
4ae388
 		vector_foreach_slot(vecs->pathvec, pp, i)
4ae388
 			c += snprint_path(c, reply + maxlen - c,
4ae388
-					  style, pp);
4ae388
+					  style, pp, pretty);
4ae388
 
4ae388
 		again = ((c - reply) == (maxlen - 1));
4ae388
 
4ae388
@@ -183,7 +184,7 @@ cli_list_paths (void * v, char ** reply,
4ae388
 
4ae388
 	condlog(3, "list paths (operator)");
4ae388
 
4ae388
-	return show_paths(reply, len, vecs, PRINT_PATH_CHECKER);
4ae388
+	return show_paths(reply, len, vecs, PRINT_PATH_CHECKER, 1);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
@@ -194,7 +195,18 @@ cli_list_paths_fmt (void * v, char ** re
4ae388
 
4ae388
 	condlog(3, "list paths (operator)");
4ae388
 
4ae388
-	return show_paths(reply, len, vecs, fmt);
4ae388
+	return show_paths(reply, len, vecs, fmt, 1);
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+cli_list_paths_raw (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+	char * fmt = get_keyparam(v, FMT);
4ae388
+
4ae388
+	condlog(3, "list paths (operator)");
4ae388
+
4ae388
+	return show_paths(reply, len, vecs, fmt, 0);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
@@ -285,7 +297,8 @@ show_daemon (char ** r, int *len)
4ae388
 }
4ae388
 
4ae388
 int
4ae388
-show_maps (char ** r, int *len, struct vectors * vecs, char * style)
4ae388
+show_maps (char ** r, int *len, struct vectors * vecs, char * style,
4ae388
+	   int pretty)
4ae388
 {
4ae388
 	int i;
4ae388
 	struct multipath * mpp;
4ae388
@@ -302,13 +315,13 @@ show_maps (char ** r, int *len, struct v
4ae388
 			return 1;
4ae388
 
4ae388
 		c = reply;
4ae388
-		if (VECTOR_SIZE(vecs->mpvec) > 0)
4ae388
+		if (pretty && VECTOR_SIZE(vecs->mpvec) > 0)
4ae388
 			c += snprint_multipath_header(c, reply + maxlen - c,
4ae388
 						      style);
4ae388
 
4ae388
 		vector_foreach_slot(vecs->mpvec, mpp, i)
4ae388
 			c += snprint_multipath(c, reply + maxlen - c,
4ae388
-					       style, mpp);
4ae388
+					       style, mpp, pretty);
4ae388
 
4ae388
 		again = ((c - reply) == (maxlen - 1));
4ae388
 
4ae388
@@ -327,7 +340,18 @@ cli_list_maps_fmt (void * v, char ** rep
4ae388
 
4ae388
 	condlog(3, "list maps (operator)");
4ae388
 
4ae388
-	return show_maps(reply, len, vecs, fmt);
4ae388
+	return show_maps(reply, len, vecs, fmt, 1);
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+cli_list_maps_raw (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+	char * fmt = get_keyparam(v, FMT);
4ae388
+
4ae388
+	condlog(3, "list maps (operator)");
4ae388
+
4ae388
+	return show_maps(reply, len, vecs, fmt, 0);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
@@ -337,7 +361,7 @@ cli_list_maps (void * v, char ** reply,
4ae388
 
4ae388
 	condlog(3, "list maps (operator)");
4ae388
 
4ae388
-	return show_maps(reply, len, vecs, PRINT_MAP_NAMES);
4ae388
+	return show_maps(reply, len, vecs, PRINT_MAP_NAMES, 1);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
@@ -357,7 +381,7 @@ cli_list_maps_status (void * v, char **
4ae388
 
4ae388
 	condlog(3, "list maps status (operator)");
4ae388
 
4ae388
-	return show_maps(reply, len, vecs, PRINT_MAP_STATUS);
4ae388
+	return show_maps(reply, len, vecs, PRINT_MAP_STATUS, 1);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
@@ -367,7 +391,7 @@ cli_list_maps_stats (void * v, char ** r
4ae388
 
4ae388
 	condlog(3, "list maps stats (operator)");
4ae388
 
4ae388
-	return show_maps(reply, len, vecs, PRINT_MAP_STATS);
4ae388
+	return show_maps(reply, len, vecs, PRINT_MAP_STATS, 1);
4ae388
 }
4ae388
 
4ae388
 int
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.h
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.h
4ae388
@@ -1,9 +1,11 @@
4ae388
 int cli_list_paths (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_paths_fmt (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_list_paths_raw (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_status (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_daemon (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_maps (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_maps_fmt (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_list_maps_raw (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_maps_status (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_maps_stats (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_map_topology (void * v, char ** reply, int * len, void * data);
4ae388
Index: multipath-tools-130222/multipathd/main.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/main.c
4ae388
+++ multipath-tools-130222/multipathd/main.c
4ae388
@@ -967,12 +967,14 @@ uxlsnrloop (void * ap)
4ae388
 
4ae388
 	set_handler_callback(LIST+PATHS, cli_list_paths);
4ae388
 	set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt);
4ae388
+	set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw);
4ae388
 	set_handler_callback(LIST+MAPS, cli_list_maps);
4ae388
 	set_handler_callback(LIST+STATUS, cli_list_status);
4ae388
 	set_handler_callback(LIST+DAEMON, cli_list_daemon);
4ae388
 	set_handler_callback(LIST+MAPS+STATUS, cli_list_maps_status);
4ae388
 	set_handler_callback(LIST+MAPS+STATS, cli_list_maps_stats);
4ae388
 	set_handler_callback(LIST+MAPS+FMT, cli_list_maps_fmt);
4ae388
+	set_handler_callback(LIST+MAPS+RAW+FMT, cli_list_maps_raw);
4ae388
 	set_handler_callback(LIST+MAPS+TOPOLOGY, cli_list_maps_topology);
4ae388
 	set_handler_callback(LIST+TOPOLOGY, cli_list_maps_topology);
4ae388
 	set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology);