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