Blame SOURCES/0096-RHBZ-979474-new-wildcards.patch

f20720
---
f20720
 libmultipath/print.c |   84 ++++++++++++++++++++++++++++++++++++++++++++++++++-
f20720
 1 file changed, 83 insertions(+), 1 deletion(-)
f20720
f20720
Index: multipath-tools-130222/libmultipath/print.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/print.c
f20720
+++ multipath-tools-130222/libmultipath/print.c
f20720
@@ -10,6 +10,7 @@
f20720
 #include <unistd.h>
f20720
 #include <string.h>
f20720
 #include <errno.h>
f20720
+#include <libudev.h>
f20720
 
f20720
 #include "checkers.h"
f20720
 #include "vector.h"
f20720
@@ -44,7 +45,7 @@
f20720
  * information printing helpers
f20720
  */
f20720
 static int
f20720
-snprint_str (char * buff, size_t len, char * str)
f20720
+snprint_str (char * buff, size_t len, const char * str)
f20720
 {
f20720
 	return snprintf(buff, len, "%s", str);
f20720
 }
f20720
@@ -432,6 +433,83 @@ snprint_path_mpp (char * buff, size_t le
f20720
 }
f20720
 
f20720
 static int
f20720
+snprint_host_attr (char * buff, size_t len, struct path * pp, char *attr)
f20720
+{
f20720
+	struct udev_device *host_dev = NULL;
f20720
+	char host_id[32];
f20720
+	const char *value = NULL;
f20720
+	int ret;
f20720
+
f20720
+	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
f20720
+		return snprintf(buff, len, "[undef]");
f20720
+	sprintf(host_id, "host%d", pp->sg_id.host_no);
f20720
+	host_dev = udev_device_new_from_subsystem_sysname(conf->udev, "fc_host",
f20720
+							  host_id);
f20720
+	if (!host_dev) {
f20720
+		condlog(1, "%s: No fc_host device for '%s'", pp->dev, host_id);
f20720
+		goto out;
f20720
+	}
f20720
+	value = udev_device_get_sysattr_value(host_dev, attr);
f20720
+	if (value)
f20720
+		ret = snprint_str(buff, len, value);
f20720
+	udev_device_unref(host_dev);
f20720
+out:
f20720
+	if (!value)
f20720
+		ret = snprintf(buff, len, "[unknown]");
f20720
+	return ret;
f20720
+}
f20720
+
f20720
+static int
f20720
+snprint_host_wwnn (char * buff, size_t len, struct path * pp)
f20720
+{
f20720
+	return snprint_host_attr(buff, len, pp, "node_name");
f20720
+}
f20720
+
f20720
+static int
f20720
+snprint_host_wwpn (char * buff, size_t len, struct path * pp)
f20720
+{
f20720
+	return snprint_host_attr(buff, len, pp, "port_name");
f20720
+}
f20720
+
f20720
+static int
f20720
+snprint_tgt_wwpn (char * buff, size_t len, struct path * pp)
f20720
+{
f20720
+	struct udev_device *rport_dev = NULL;
f20720
+	char rport_id[32];
f20720
+	const char *value = NULL;
f20720
+	int ret;
f20720
+
f20720
+	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
f20720
+		return snprintf(buff, len, "[undef]");
f20720
+	sprintf(rport_id, "rport-%d:%d-%d",
f20720
+		pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.transport_id);
f20720
+	rport_dev = udev_device_new_from_subsystem_sysname(conf->udev,
f20720
+				"fc_remote_ports", rport_id);
f20720
+	if (!rport_dev) {
f20720
+		condlog(1, "%s: No fc_remote_port device for '%s'", pp->dev,
f20720
+			rport_id);
f20720
+		goto out;
f20720
+	}
f20720
+	value = udev_device_get_sysattr_value(rport_dev, "port_name");
f20720
+	if (value)
f20720
+		ret = snprint_str(buff, len, value);
f20720
+	udev_device_unref(rport_dev);
f20720
+out:
f20720
+	if (!value)
f20720
+		ret = snprintf(buff, len, "[unknown]");
f20720
+	return ret;
f20720
+}
f20720
+
f20720
+
f20720
+static int
f20720
+snprint_tgt_wwnn (char * buff, size_t len, struct path * pp)
f20720
+{
f20720
+	if (pp->tgt_node_name[0] == '\0')
f20720
+		return snprintf(buff, len, "[undef]");
f20720
+	return snprint_str(buff, len, pp->tgt_node_name);
f20720
+}
f20720
+
f20720
+static int
f20720
 snprint_path_checker (char * buff, size_t len, struct path * pp)
f20720
 {
f20720
 	struct checker * c = &pp->checker;
f20720
@@ -475,6 +553,10 @@ struct path_data pd[] = {
f20720
 	{'S', "size",          0, snprint_path_size},
f20720
 	{'z', "serial",        0, snprint_path_serial},
f20720
 	{'m', "multipath",     0, snprint_path_mpp},
f20720
+	{'N', "host WWNN",     0, snprint_host_wwnn},
f20720
+	{'n', "target WWNN",   0, snprint_tgt_wwnn},
f20720
+	{'R', "host WWPN",     0, snprint_host_wwpn},
f20720
+	{'r', "target WWPN",   0, snprint_tgt_wwpn},
f20720
 	{0, NULL, 0 , NULL}
f20720
 };
f20720