diff --git a/SOURCES/0002-Fix-truncation-of-128-bit-wwn.patch b/SOURCES/0002-Fix-truncation-of-128-bit-wwn.patch new file mode 100644 index 0000000..312d59e --- /dev/null +++ b/SOURCES/0002-Fix-truncation-of-128-bit-wwn.patch @@ -0,0 +1,59 @@ +From c54aff2e062194057f21a5fd922e53a491913bd8 Mon Sep 17 00:00:00 2001 +From: Vaibhav Jain +Date: Thu, 20 Oct 2016 17:19:44 +0530 +Subject: [PATCH] Fix truncation of 128-bit wwn + +Currently with '--wwn' flag 128-bit wwns are getting truncated with +their last 3 hex-digit missing. Below is a comparison of wwn reported +by lspsci compared to wwn listed at /dev/disk/by-id directory. + +% lsscsi -w 0:0:5:0 +[0:0:5:0] disk 0x60050764008181941000000000000 /dev/sdad + +% ls -l /dev/disk/by-id/wwn-* +lrwxrwxrwx. 1 root root 10 Oct 19 01:08 /dev/disk/by-id/wwn-0x600507640081819410000000000001b1 -> ../../sdad + +To fix this the patch increases the size of member wwn of struct +disk_wwn_node_entry to 35 chars to accommodate the extra '0x' prefix and +null terminator. Also the size of the buffer wwn_str thats used to +output wwn to the std-out is also increased to match the corresponding +member of disk_wwn_node_entry. + +Reported-by: Ping Tian Han +Signed-off-by: Vaibhav Jain +--- + src/lsscsi.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/lsscsi.c b/src/lsscsi.c +index 974b3f1..7d71a3b 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -210,8 +210,8 @@ struct dev_node_list { + static struct dev_node_list* dev_node_listhead = NULL; + + struct disk_wwn_node_entry { +- char wwn[32]; +- char disk_bname[12]; ++ char wwn[35]; /* '0x' + wwn<128-bit> + */ ++ char disk_bname[12]; + }; + + #define DISK_WWN_NODE_LIST_ENTRIES 16 +@@ -2939,14 +2939,14 @@ one_sdev_entry(const char * dir_name, const char * devname, + } + if (wd[0]) { + char dev_node[LMAX_NAME] = ""; +- char wwn_str[34]; ++ char wwn_str[35]; + enum dev_type typ; + + typ = (FT_BLOCK == non_sg.ft) ? BLK_DEV : CHR_DEV; + if (get_wwn) { + if ((BLK_DEV == typ) && + get_disk_wwn(wd, wwn_str, sizeof(wwn_str))) +- printf("%-30s ", wwn_str); ++ printf("%-34s ", wwn_str); + else + printf(" " + " "); diff --git a/SOURCES/BZ_1429361-if-very-long-h-c-t-l-then-append-space-rather-than-l.patch b/SOURCES/BZ_1429361-if-very-long-h-c-t-l-then-append-space-rather-than-l.patch new file mode 100644 index 0000000..d5667df --- /dev/null +++ b/SOURCES/BZ_1429361-if-very-long-h-c-t-l-then-append-space-rather-than-l.patch @@ -0,0 +1,23 @@ +diff -Nur lsscsi-0.27_old/src/lsscsi.c lsscsi-0.27/src/lsscsi.c +--- lsscsi-0.27_old/src/lsscsi.c 2017-03-15 19:59:47.642500506 +0800 ++++ lsscsi-0.27/src/lsscsi.c 2017-03-15 20:08:51.446308385 +0800 +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -2504,7 +2505,10 @@ + } else + snprintf(value, sizeof(value), "[%s]", devname); + +- printf("%-*s", devname_len, value); ++ if ((int)strlen(value) >= devname_len) ++ printf("%s ", value); /* if very long, append a space */ ++ else /* left justified with field length of devname_len */ ++ printf("%-*s", devname_len, value); + if (! get_value(buff, "type", value, sizeof(value))) { + printf("type? "); + } else if (1 != sscanf(value, "%d", &type)) { diff --git a/SPECS/lsscsi.spec b/SPECS/lsscsi.spec index 1b17529..2678acd 100644 --- a/SPECS/lsscsi.spec +++ b/SPECS/lsscsi.spec @@ -1,7 +1,7 @@ Summary: List SCSI devices (or hosts) and associated information Name: lsscsi Version: 0.27 -Release: 4%{?dist} +Release: 6%{?dist} License: GPLv2+ Group: Applications/System Source0: http://sg.danny.cz/scsi/%{name}-%{version}.tgz @@ -9,6 +9,8 @@ URL: http://sg.danny.cz/scsi/lsscsi.html BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Patch0: 0001-Remove-enclosure-information-for-FCP-FCoE.patch +Patch1: 0002-Fix-truncation-of-128-bit-wwn.patch +Patch2: BZ_1429361-if-very-long-h-c-t-l-then-append-space-rather-than-l.patch %description Uses information provided by the sysfs pseudo file system in Linux kernel @@ -24,6 +26,8 @@ Author: %prep %setup -q %patch0 -p1 +%patch1 -p1 +%patch2 -p1 -b .long_scsi_id %build %configure @@ -47,6 +51,12 @@ rm -rf %{buildroot} %changelog +* Wed Mar 15 2017 Gris Ge - 0.27-6 +- Append a space if [hctl] is too long. (RHBZ #1429361) + +* Tue Feb 28 2017 Gris Ge 0.27-5 +- Fix truncation of 128-bit wwn of disk. + * Fri Jun 19 2015 David Sommerseth - 0.27-4 - Remove enclosure queries for FCP/FCoE (#1062322)