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