Blame SOURCES/0002-Fix-truncation-of-128-bit-wwn.patch

9298dc
From c54aff2e062194057f21a5fd922e53a491913bd8 Mon Sep 17 00:00:00 2001
9298dc
From: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
9298dc
Date: Thu, 20 Oct 2016 17:19:44 +0530
9298dc
Subject: [PATCH] Fix truncation of 128-bit wwn
9298dc
9298dc
Currently with '--wwn' flag 128-bit wwns are getting truncated with
9298dc
their last 3 hex-digit missing. Below is a comparison of wwn reported
9298dc
by lspsci compared to wwn listed at /dev/disk/by-id directory.
9298dc
9298dc
% lsscsi -w 0:0:5:0
9298dc
[0:0:5:0]    disk    0x60050764008181941000000000000  /dev/sdad
9298dc
9298dc
% ls -l /dev/disk/by-id/wwn-*
9298dc
lrwxrwxrwx. 1 root root 10 Oct 19 01:08 /dev/disk/by-id/wwn-0x600507640081819410000000000001b1 -> ../../sdad
9298dc
9298dc
To fix this the patch increases the size of member wwn of struct
9298dc
disk_wwn_node_entry to 35 chars to accommodate the extra '0x' prefix and
9298dc
null terminator. Also the size of the buffer wwn_str thats used to
9298dc
output wwn to the std-out is also increased to match the corresponding
9298dc
member of disk_wwn_node_entry.
9298dc
9298dc
Reported-by: Ping Tian Han <pthan@cn.ibm.com>
9298dc
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
9298dc
---
9298dc
 src/lsscsi.c | 8 ++++----
9298dc
 1 file changed, 4 insertions(+), 4 deletions(-)
9298dc
9298dc
diff --git a/src/lsscsi.c b/src/lsscsi.c
9298dc
index 974b3f1..7d71a3b 100644
9298dc
--- a/src/lsscsi.c
9298dc
+++ b/src/lsscsi.c
9298dc
@@ -210,8 +210,8 @@ struct dev_node_list {
9298dc
 static struct dev_node_list* dev_node_listhead = NULL;
9298dc
 
9298dc
 struct disk_wwn_node_entry {
9298dc
-       char wwn[32];
9298dc
-       char disk_bname[12];
9298dc
+	char wwn[35]; /* '0x' + wwn<128-bit> + <null-terminator> */
9298dc
+	char disk_bname[12];
9298dc
 };
9298dc
 
9298dc
 #define DISK_WWN_NODE_LIST_ENTRIES 16
9298dc
@@ -2939,14 +2939,14 @@ one_sdev_entry(const char * dir_name, const char * devname,
9298dc
                 }
9298dc
                 if (wd[0]) {
9298dc
                         char dev_node[LMAX_NAME] = "";
9298dc
-                        char wwn_str[34];
9298dc
+                        char wwn_str[35];
9298dc
                         enum dev_type typ;
9298dc
 
9298dc
                         typ = (FT_BLOCK == non_sg.ft) ? BLK_DEV : CHR_DEV;
9298dc
                         if (get_wwn) {
9298dc
                                 if ((BLK_DEV == typ) &&
9298dc
                                     get_disk_wwn(wd, wwn_str, sizeof(wwn_str)))
9298dc
-                                        printf("%-30s  ", wwn_str);
9298dc
+                                        printf("%-34s  ", wwn_str);
9298dc
                                 else
9298dc
                                         printf("                          "
9298dc
                                                "      ");