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

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