diff --git a/RHEL-155569-lsscsi-Transport-type-FC-and-FCOE-output-inconsisten.patch b/RHEL-155569-lsscsi-Transport-type-FC-and-FCOE-output-inconsisten.patch new file mode 100644 index 0000000..bc1eda1 --- /dev/null +++ b/RHEL-155569-lsscsi-Transport-type-FC-and-FCOE-output-inconsisten.patch @@ -0,0 +1,39 @@ +From ab8e09745bdaf09313ed548b05ba52d31b85146a Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Fri, 20 Mar 2026 13:37:11 +0000 +Subject: [PATCH] lsscsi: Transport type FC and FCOE output inconsistencies + +Change the output for transport types "FC" and "FCOE" so that there is no +trailing colon ":" when listing with the "--list -t", bringing in-line with +the output for other transport types. + +Signed-off-by: Paul Evans +--- + src/lsscsi.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/lsscsi.c b/src/lsscsi.c +index 5e8ff8e..beaa2b9 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -2265,7 +2265,7 @@ transport_init_longer(const char * path_name, const struct lsscsi_opts * op) + case TRANSPORT_FC: + case TRANSPORT_FCOE: + printf(" transport=%s\n", +- transport_id == TRANSPORT_FC ? "fc:" : "fcoe:"); ++ transport_id == TRANSPORT_FC ? "fc" : "fcoe"); + snprintf(buff, sizeof(buff), "%s%s%s", path_name, + "/device/fc_host/", cp); + if (stat(buff, &a_stat) < 0) { +@@ -2758,7 +2758,7 @@ transport_tport_longer(const char * devname, const struct lsscsi_opts * op) + case TRANSPORT_FC: + case TRANSPORT_FCOE: + printf(" transport=%s\n", +- transport_id == TRANSPORT_FC ? "fc:" : "fcoe:"); ++ transport_id == TRANSPORT_FC ? "fc" : "fcoe"); + if (! if_directory_chdir(path_name, "device")) + return; + if (NULL == getcwd(wd, wdlen)) +-- +2.53.0 + diff --git a/RHEL-157252-lsscsi-Device-name-spacing-before-major-minor-when-d.patch b/RHEL-157252-lsscsi-Device-name-spacing-before-major-minor-when-d.patch new file mode 100644 index 0000000..2a03629 --- /dev/null +++ b/RHEL-157252-lsscsi-Device-name-spacing-before-major-minor-when-d.patch @@ -0,0 +1,122 @@ +From 60644c81edc568416051acb82a16e6e20a9fcd6a Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Fri, 20 Mar 2026 13:55:50 +0000 +Subject: [PATCH] lsscsi: Device name spacing before major:minor when dev name + exceeds 9 chars + +When using -d flag to display the device major:minor number, device +names longer than 9 characters (e.g. /dev/sdaa) had no space before +the major:minor field. + +This is inconsistent with shorter device names. + +Add further conditional to the output format only when using the -d +flag to remove device name padding. This ensures consistent single +space before device major:minor regardless of the device name +length. + +Before: + - dev/sda [8:0] + - dev/sdaa[8:1] + +Output now displays as: + - /dev/sda [8:0] + - /dev/sdaa [8:1] + +When -d flag is not used formatting remaining unchanged and will +continue to use the padding for proper column alignment. + +Signed-off-by: Paul Evans +--- + src/lsscsi.c | 31 ++++++++++++++++++++----------- + 1 file changed, 20 insertions(+), 11 deletions(-) + +diff --git a/src/lsscsi.c b/src/lsscsi.c +index beaa2b9..e012425 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -3490,19 +3490,23 @@ one_sdev_entry(const char * dir_name, const char * devname, + on whether we are using default output or additional + fields (via command line arguments). + ++ A further condition when printing dev_maj_min (-d) ++ where we would like to keep a consistent single space ++ before major:minor regardless of block dev name length. ++ + Keeping the fixed field size for every other case + except the default output where there would now not + be a trailing space at the end of each device line. + */ +- printf((op->dev_maj_min || op->scsi_id || op->generic || ++ printf((op->scsi_id || op->generic || + op->protection || op->protmode || op->ssize) + ? "%-9s" : "%s", dev_node); + + if (op->dev_maj_min) { + if (get_value(wd, "dev", value, vlen)) +- printf("[%s]", value); ++ printf(" [%s]", value); + else +- printf("[dev?]"); ++ printf(" [dev?]"); + } + + if (op->scsi_id) { +@@ -3552,19 +3556,22 @@ one_sdev_entry(const char * dir_name, const char * devname, + on whether we are using default output or additional + fields (via command line arguments). + ++ A further condition when printing dev_maj_min (-d) ++ where we would like to keep a consistent single space ++ before major:minor regardless of block dev name length. ++ + Keeping the fixed field size for every other case + except the default output where there would now not + be a trailing space at the end of each device line. + */ +- printf((op->dev_maj_min || op->protection || +- op->protmode || op->ssize) ++ printf((op->protection || op->protmode || op->ssize) + ? " %-9s" : " %s", dev_node); + if (op->dev_maj_min) { + if (get_value(wd, "dev", value, + sizeof(value))) +- printf("[%s]", value); ++ printf(" [%s]", value); + else +- printf("[dev?]"); ++ printf(" [dev?]"); + } + } + } +@@ -3577,8 +3584,7 @@ one_sdev_entry(const char * dir_name, const char * devname, + except the default output where there would now not + be a trailing space at the end of each device line. + */ +- printf((op->dev_maj_min || op->protection || +- op->protmode || op->ssize) ++ printf((op->protection || op->protmode || op->ssize) + ? " %-9s" : " %s", "-"); + } + } +@@ -3877,12 +3883,15 @@ one_ndev_entry(const char * nvme_ctl_abs, const char * nvme_ns_rel, + on whether we are using default output or additional + fields (via command line arguments). + ++ A further condition when printing dev_maj_min (-d) ++ where we would like to keep a consistent single space ++ before major:minor regardless of block dev name length. ++ + Keeping the fixed field size for every other case + except the default output where there would now not + be a trailing space at the end of each device line. + */ +- printf((op->dev_maj_min || op->generic || +- op->protmode || op->ssize) ++ printf((op->generic || op->protmode || op->ssize) + ? "%-9s" : "%s", dev_node); + if (op->dev_maj_min) { + if (get_value(buff, "dev", value, vlen)) +-- +2.53.0 + diff --git a/RHEL-48228-lsscsi-Fixes-for-SBP-Firewire-host-in-transport_h_in.patch b/RHEL-48228-lsscsi-Fixes-for-SBP-Firewire-host-in-transport_h_in.patch new file mode 100644 index 0000000..3114a63 --- /dev/null +++ b/RHEL-48228-lsscsi-Fixes-for-SBP-Firewire-host-in-transport_h_in.patch @@ -0,0 +1,49 @@ +From 340454dfa186e472eb613c8b760d8758f3e878f1 Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Mon, 23 Feb 2026 16:59:32 +0000 +Subject: [PATCH] lsscsi: Fixes for SBP (Firewire) host in transport_h_init() + +Correct two potential overruns in transport_h_init() in the SBP (Firewire) +host section. + +1. Missing null terminator after readlink() for buff2 before strstr() call. To +protect against potential overrun as strstr() expects a properly terminated +string. + +2. Wrong size passed to my_strcopy() call. We are copying buff2 into buff, but +buff already has data within. Original code passed bufflen (total buff size), +not the remaining free space. Change to avoid potential overrun. + +Signed-off-by: Paul Evans +--- + src/lsscsi.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/lsscsi.c b/src/lsscsi.c +index 6f6953f..147017a 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -2162,8 +2162,10 @@ transport_init(const char * devname, /* const struct lsscsi_opts * op, */ + /* resolve SCSI host device */ + snprintf(buff, sizeof(buff), "%s%s%s%s", sysfsroot, scsi_host, + devname, "/device"); +- if (readlink(buff, buff2, sizeof(buff2)) <= 0) ++ ssize_t len = readlink(buff, buff2, sizeof(buff2)-1); ++ if (len <= 0) + break; ++ buff2[len] = '\0'; // NULL termination after readlink() + + /* check if the SCSI host has a FireWire host as ancestor */ + if (!(t = strstr(buff2, "/fw-host"))) +@@ -2180,7 +2182,7 @@ transport_init(const char * devname, /* const struct lsscsi_opts * op, */ + if (strlen(buff) + strlen(buff2) + strlen("host_id/guid") + 2 + > sizeof(buff)) + break; +- my_strcopy(buff + strlen(buff), buff2, sizeof(buff)); ++ my_strcopy(buff + strlen(buff), buff2, sizeof(buff) - strlen(buff)); + + /* read the FireWire host's EUI-64 */ + if (!get_value(buff, "host_id/guid", buff2, sizeof(buff2)) || +-- +2.53.0 + diff --git a/RHEL-70371-lsscsi-Change-default-output-trailing-space-after-ea.patch b/RHEL-70371-lsscsi-Change-default-output-trailing-space-after-ea.patch new file mode 100644 index 0000000..96c1d84 --- /dev/null +++ b/RHEL-70371-lsscsi-Change-default-output-trailing-space-after-ea.patch @@ -0,0 +1,129 @@ +From 011ed49407609f0e7dc12c60bf032e0d83fb6df8 Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Fri, 20 Mar 2026 13:29:55 +0000 +Subject: [PATCH] lsscsi: Change default output trailing psace after each + device entry + +In the default output case (using lsscsi without any command line +arguments) there is a trailing space after the device node for each +device due to using a fixed field size. + +Conditionally use the full length of dev_node when calling +printf() for the device node instead of the fixed 9 caracter width +when not using any other "op" modes (command line arguments) avoiding +the trailing space. + +Signed-off-by: Paul Evans +--- + src/lsscsi.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 60 insertions(+), 7 deletions(-) + +diff --git a/src/lsscsi.c b/src/lsscsi.c +index 147017a..5e8ff8e 100644 +--- a/src/lsscsi.c ++++ b/src/lsscsi.c +@@ -3486,7 +3486,18 @@ one_sdev_entry(const char * dir_name, const char * devname, + snprintf(dev_node, sizeof(dev_node), + "- "); + +- printf("%-9s", dev_node); ++ /* Conditionally format the output for dev_node depending ++ on whether we are using default output or additional ++ fields (via command line arguments). ++ ++ Keeping the fixed field size for every other case ++ except the default output where there would now not ++ be a trailing space at the end of each device line. ++ */ ++ printf((op->dev_maj_min || op->scsi_id || op->generic || ++ op->protection || op->protmode || op->ssize) ++ ? "%-9s" : "%s", dev_node); ++ + if (op->dev_maj_min) { + if (get_value(wd, "dev", value, vlen)) + printf("[%s]", value); +@@ -3507,8 +3518,19 @@ one_sdev_entry(const char * dir_name, const char * devname, + printf(" "); + if (op->scsi_id) + printf("%-9s -", "-"); +- else +- printf("%-9s", "-"); ++ else { ++ /* Conditionally format the output for dev_node depending ++ on whether we are using default output or additional ++ fields (via command line arguments). ++ ++ Keeping the fixed field size for every other case ++ except the default output where there would now not ++ be a trailing space at the end of each device line. ++ */ ++ printf((op->dev_maj_min || op->scsi_id || op->generic || ++ op->protection || op->protmode || op->ssize) ++ ? "%-9s" : "%s", "-"); ++ } + } + + if (op->generic) { +@@ -3526,7 +3548,17 @@ one_sdev_entry(const char * dir_name, const char * devname, + CHR_DEV)) + snprintf(dev_node, sizeof(dev_node), + "-"); +- printf(" %-9s", dev_node); ++ /* Conditionally format the output for dev_node depending ++ on whether we are using default output or additional ++ fields (via command line arguments). ++ ++ Keeping the fixed field size for every other case ++ except the default output where there would now not ++ be a trailing space at the end of each device line. ++ */ ++ printf((op->dev_maj_min || op->protection || ++ op->protmode || op->ssize) ++ ? " %-9s" : " %s", dev_node); + if (op->dev_maj_min) { + if (get_value(wd, "dev", value, + sizeof(value))) +@@ -3536,8 +3568,19 @@ one_sdev_entry(const char * dir_name, const char * devname, + } + } + } +- else +- printf(" %-9s", "-"); ++ else { ++ /* Conditionally format the output for dev_node depending ++ on whether we are using default output or additional ++ fields (via command line arguments). ++ ++ Keeping the fixed field size for every other case ++ except the default output where there would now not ++ be a trailing space at the end of each device line. ++ */ ++ printf((op->dev_maj_min || op->protection || ++ op->protmode || op->ssize) ++ ? " %-9s" : " %s", "-"); ++ } + } + + if (op->protection) { +@@ -3830,7 +3873,17 @@ one_ndev_entry(const char * nvme_ctl_abs, const char * nvme_ns_rel, + else if (! get_dev_node(buff, dev_node, BLK_DEV)) + snprintf(dev_node, sizeof(dev_node), "- "); + +- printf("%-9s", dev_node); ++ /* Conditionally format the output for dev_node depending ++ on whether we are using default output or additional ++ fields (via command line arguments). ++ ++ Keeping the fixed field size for every other case ++ except the default output where there would now not ++ be a trailing space at the end of each device line. ++ */ ++ printf((op->dev_maj_min || op->generic || ++ op->protmode || op->ssize) ++ ? "%-9s" : "%s", dev_node); + if (op->dev_maj_min) { + if (get_value(buff, "dev", value, vlen)) + printf(" [%s]", value); +-- +2.53.0 + diff --git a/lsscsi.spec b/lsscsi.spec index c18e84a..7bb31bd 100644 --- a/lsscsi.spec +++ b/lsscsi.spec @@ -1,7 +1,7 @@ Summary: List SCSI devices (or hosts) and associated information Name: lsscsi Version: 0.32 -Release: 15%{?dist} +Release: 16%{?dist} License: GPL-2.0-or-later # official git repository: https://github.com/doug-gilbert/lsscsi Source0: http://sg.danny.cz/scsi/%{name}-%{version}.tgz @@ -9,6 +9,15 @@ URL: http://sg.danny.cz/scsi/lsscsi.html BuildRequires: gcc BuildRequires: make +# https://redhat.atlassian.net/browse/RHEL-48228 +Patch0: RHEL-48228-lsscsi-Fixes-for-SBP-Firewire-host-in-transport_h_in.patch +# https://redhat.atlassian.net/browse/RHEL-70371 +Patch1: RHEL-70371-lsscsi-Change-default-output-trailing-space-after-ea.patch +# https://redhat.atlassian.net/browse/RHEL-155569 +Patch2: RHEL-155569-lsscsi-Transport-type-FC-and-FCOE-output-inconsisten.patch +# https://redhat.atlassian.net/browse/RHEL-157252 +Patch3: RHEL-157252-lsscsi-Device-name-spacing-before-major-minor-when-d.patch + %description Uses information provided by the sysfs pseudo file system in Linux kernel 2.6 series to list SCSI devices or all SCSI hosts. Includes a "classic" @@ -39,6 +48,12 @@ Author: %changelog +* Thu Apr 02 2026 Paul Evans - 0.32-16 +- lsscsi: Fixes for SBP (Firewire) host in transport_h_init() (RHEL-48228) +- lsscsi: Change default output trailing space after each device entry (RHEL-70371) +- lsscsi: Transport type FC and FCOE output inconsistencies (RHEL-155569) +- lsscsi: Device name spacing before major:minor dev dev names exceeds 9 chars (RHEL-157252) + * Tue Oct 29 2024 Troy Dawson - 0.32-15 - Bump release for October 2024 mass rebuild: Resolves: RHEL-64018