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

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