From bdc11156e632f593e4abfb3b04418e334a4ab9ce Mon Sep 17 00:00:00 2001 From: Paul Evans Date: Wed, 25 Mar 2026 14:40:19 +0000 Subject: [PATCH] * Wed Mar 25 2026 Paul Evans - 1.48-8 - rescan-scsi-bus.sh: Correctly read RMB bit on enquiry (RHEL-153277) - rescan-scsi-bus.sh: Replace 'which' with build in 'command -v' (RHEL-70693) - sg_safte: update short option of version (RHEL-125869) - sg_rdac: accept --help or -h without error (RHEL-69439) - sg_inq: fix issing output fields in --export format (RHEL-119246, RHEL-123748) - sg_inq: re-add Unit serial number field (RHEL-119246, RHEL-123748) Resolves: RHEL-153277, RHEL-70693, RHEL-125869, RHEL-69439, RHEL-119246, RHEL-123748 --- ...sing-output-fields-in--export-format.patch | 121 ++++++++++++++++++ ..._inq-re-add-Unit-serial-number-field.patch | 52 ++++++++ ....c-to-update-short-option-of-version.patch | 25 ++++ ...sh-Correctly-read-RMB-bit-on-enquiry.patch | 46 +++++++ ...c-to-accept--help-or--h-without-erro.patch | 38 ++++++ ...sh-Replace-which-with-build-in-comma.patch | 34 +++++ sg3_utils.spec | 24 +++- 7 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 RHEL-119246-1-sg_inq-fix-missing-output-fields-in--export-format.patch create mode 100644 RHEL-119246-2-sg_inq-re-add-Unit-serial-number-field.patch create mode 100644 RHEL-125869-Update-sg_safte.c-to-update-short-option-of-version.patch create mode 100644 RHEL-153277-rescan-scsi-bus.sh-Correctly-read-RMB-bit-on-enquiry.patch create mode 100644 RHEL-69439-Update-sg_rdac.c-to-accept--help-or--h-without-erro.patch create mode 100644 RHEL-70693-rescan-scsi-bus.sh-Replace-which-with-build-in-comma.patch diff --git a/RHEL-119246-1-sg_inq-fix-missing-output-fields-in--export-format.patch b/RHEL-119246-1-sg_inq-fix-missing-output-fields-in--export-format.patch new file mode 100644 index 0000000..5b31ab8 --- /dev/null +++ b/RHEL-119246-1-sg_inq-fix-missing-output-fields-in--export-format.patch @@ -0,0 +1,121 @@ +From 330aec139233fbec93966e68b46a8633b9efd41f Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Tue, 13 Feb 2024 18:09:34 +0100 +Subject: [PATCH] sg_inq: fix missing output fields in --export format + +The SCSI_MODEL, SCSI_MODEL_ENC, SCSI_REVISION, and other fields are +missing in the output of sg_inq with --export: + +$ sg_inq /dev/sda +standard INQUIRY: + PQual=0 PDT=0 RMB=0 LU_CONG=0 hot_pluggable=0 version=0x05 [SPC-3] + [AERC=0] [TrmTsk=0] NormACA=0 HiSUP=0 Resp_data_format=2 + SCCS=0 ACC=0 TPGS=0 3PC=0 Protect=0 [BQue=0] + EncServ=0 MultiP=0 [MChngr=0] [ACKREQQ=0] Addr16=0 + [RelAdr=0] WBus16=0 Sync=0 [Linked=0] [TranDis=0] CmdQue=1 + [SPI: Clocking=0x0 QAS=0 IUS=0] + length=96 (0x60) Peripheral device type: disk + Vendor identification: ATA + Product identification: SK hynix SC300 M + Product revision level: 0P00 + +$ sg_inq --export /dev/sda +SCSI_TPGS=0 +SCSI_TYPE=disk +SCSI_VENDOR=ATA +SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 + +The reason is that the parameter "len" is overwritten in std_inq_decode(). +Fix it by using block-local variables for calculating field lengths. + +Output after applying this patch: + +$ sg_inq --export /dev/sda +SCSI_TPGS=0 +SCSI_TYPE=disk +SCSI_VENDOR=ATA +SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 +SCSI_MODEL=SK_hynix_SC300_M +SCSI_MODEL_ENC=SK\x20hynix\x20SC300\x20M +SCSI_REVISION=0P00 + +Fixes: 0f1230a ("sg_readcap+sg_luns: add --inhex= and json") +Signed-off-by: Martin Wilck +--- + src/sg_inq.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/src/sg_inq.c b/src/sg_inq.c +index b3b8127f..8e6b269d 100644 +--- a/src/sg_inq.c ++++ b/src/sg_inq.c +@@ -2349,8 +2349,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + if (xtra_buff[i] == 0x09) + xtra_buff[i] = ' '; + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, 8); +- if (len > 0) { ++ int vlen = encode_whitespaces((uint8_t *)xtra_buff, 8); ++ if (vlen > 0) { + printf("SCSI_VENDOR=%s\n", xtra_buff); + encode_string(xtra_buff, &rp[8], 8); + printf("SCSI_VENDOR_ENC=%s\n", xtra_buff); +@@ -2364,8 +2364,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + memcpy(xtra_buff, &rp[16], 16); + xtra_buff[16] = '\0'; + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, 16); +- if (len > 0) { ++ int mlen = encode_whitespaces((uint8_t *)xtra_buff, 16); ++ if (mlen > 0) { + printf("SCSI_MODEL=%s\n", xtra_buff); + encode_string(xtra_buff, &rp[16], 16); + printf("SCSI_MODEL_ENC=%s\n", xtra_buff); +@@ -2380,8 +2380,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + memcpy(xtra_buff, &rp[32], 4); + xtra_buff[4] = '\0'; + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, 4); +- if (len > 0) ++ int rlen = encode_whitespaces((uint8_t *)xtra_buff, 4); ++ if (rlen > 0) + printf("SCSI_REVISION=%s\n", xtra_buff); + } else + sgj_pr_hr(jsp, " Product revision level: %s\n", xtra_buff); +@@ -2390,8 +2390,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + (' ' != rp[36])) { + memcpy(xtra_buff, &rp[36], len < 56 ? len - 36 : 20); + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, 20); +- if (len > 0) ++ int vlen = encode_whitespaces((uint8_t *)xtra_buff, 20); ++ if (vlen > 0) + printf("VENDOR_SPECIFIC=%s\n", xtra_buff); + } else + sgj_pr_hr(jsp, " Vendor specific: %s\n", xtra_buff); +@@ -2404,9 +2404,9 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + if ((op->do_vendor > 1) && (len > 96)) { + memcpy(xtra_buff, &rp[96], len - 96); + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, ++ int vlen = encode_whitespaces((uint8_t *)xtra_buff, + len - 96); +- if (len > 0) ++ if (vlen > 0) + printf("VENDOR_SPECIFIC=%s\n", xtra_buff); + } else + sgj_pr_hr(jsp, " Vendor specific: %s\n", xtra_buff); +@@ -2415,8 +2415,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + (0 == strncmp("OPEN-V", (const char *)&rp[16], 6))) { + memcpy(xtra_buff, &rp[212], 32); + if (op->do_export) { +- len = encode_whitespaces((uint8_t *)xtra_buff, 32); +- if (len > 0) ++ int vlen = encode_whitespaces((uint8_t *)xtra_buff, 32); ++ if (vlen > 0) + printf("VENDOR_SPECIFIC_OPEN-V_LDEV_NAME=%s\n", xtra_buff); + } else + sgj_pr_hr(jsp, " Vendor specific OPEN-V LDEV Name: %s\n", +-- +2.53.0 + diff --git a/RHEL-119246-2-sg_inq-re-add-Unit-serial-number-field.patch b/RHEL-119246-2-sg_inq-re-add-Unit-serial-number-field.patch new file mode 100644 index 0000000..02de75c --- /dev/null +++ b/RHEL-119246-2-sg_inq-re-add-Unit-serial-number-field.patch @@ -0,0 +1,52 @@ +From e67d186ad6aec8dede8eaec79e4b8366ebc0ad50 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Fri, 19 Apr 2024 23:03:14 +0200 +Subject: [PATCH] sg_inq: re-add Unit serial number field + +After 0f1230a ("sg_readcap+sg_luns: add --inhex= and json"), the +"Unit serial number" output field is missing from sg_inq output: + +> ./sg_inq /dev/sda +standard INQUIRY: + PQual=0 PDT=0 RMB=0 LU_CONG=0 hot_pluggable=0 version=0x05 [SPC-3] + [AERC=0] [TrmTsk=0] NormACA=0 HiSUP=0 Resp_data_format=2 + SCCS=0 ACC=0 TPGS=0 3PC=0 Protect=0 [BQue=0] + EncServ=0 MultiP=0 [MChngr=0] [ACKREQQ=0] Addr16=0 + [RelAdr=0] WBus16=0 Sync=0 [Linked=0] [TranDis=0] CmdQue=1 + [SPI: Clocking=0x0 QAS=0 IUS=0] + length=96 (0x60) Peripheral device type: disk + Vendor identification: ATA + Product identification: SK hynix SC300 M + Product revision level: 0P00 + +Previously, the command would also print + + Unit serial number: FJ63N456110303C1E + +The problem is caused by checking "len" rather than op->maxlen +in the condition that's evaluated for printing the unit serial numnber. + +Fixes: 0f1230a ("sg_readcap+sg_luns: add --inhex= and json") +Signed-off-by: Martin Wilck +--- + src/sg_inq.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/sg_inq.c b/src/sg_inq.c +index 8e6b269d..5d77d908 100644 +--- a/src/sg_inq.c ++++ b/src/sg_inq.c +@@ -2428,8 +2428,8 @@ std_inq_decode(const uint8_t * rp, int len, struct opts_t * op, + + if (as_json) + jo2p = std_inq_decode_js(rp, len, op, jop); +- if ((0 == len) && usn_buff[0]) +- sgj_pr_hr(jsp, " Unit serial number: %s\n", usn_buff); ++ if ((0 == op->maxlen) && usn_buff[0]) ++ sgj_pr_hr(jsp, " Unit serial number: %s\n", usn_buff); + if (op->do_descriptors) { + sgj_opaque_p jap = sgj_named_subarray_r(jsp, jo2p, + "version_descriptor_list"); +-- +2.53.0 + diff --git a/RHEL-125869-Update-sg_safte.c-to-update-short-option-of-version.patch b/RHEL-125869-Update-sg_safte.c-to-update-short-option-of-version.patch new file mode 100644 index 0000000..0724515 --- /dev/null +++ b/RHEL-125869-Update-sg_safte.c-to-update-short-option-of-version.patch @@ -0,0 +1,25 @@ +From da138e7b28a7c5e8ea2bb1ae099245d65e23ec5e Mon Sep 17 00:00:00 2001 +From: Fan +Date: Mon, 3 Nov 2025 19:54:03 +0800 +Subject: [PATCH] Update sg_safte.c to update short option of version + +Update sg_safte.c to update short oprtion of version from -v to -V. + +Signed-off-by: Fan Fan +--- + src/sg_safte.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sg_safte.c b/src/sg_safte.c +index 26d34169..2319ee83 100644 +--- a/src/sg_safte.c ++++ b/src/sg_safte.c +@@ -492,7 +492,7 @@ usage() + "to stdout\n" + " --usage|-u output usage statistics\n" + " --verbose|-v increase verbosity\n" +- " --version|-v output version then exit\n\n" ++ " --version|-V output version then exit\n\n" + "Queries a SAF-TE processor device\n"); + } + diff --git a/RHEL-153277-rescan-scsi-bus.sh-Correctly-read-RMB-bit-on-enquiry.patch b/RHEL-153277-rescan-scsi-bus.sh-Correctly-read-RMB-bit-on-enquiry.patch new file mode 100644 index 0000000..409b9ba --- /dev/null +++ b/RHEL-153277-rescan-scsi-bus.sh-Correctly-read-RMB-bit-on-enquiry.patch @@ -0,0 +1,46 @@ +From b705f0105606520ca13f920a88756fbaa4355252 Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Wed, 28 Jan 2026 14:42:02 +0000 +Subject: [PATCH] rescan-scsi-bus.sh Correctly read RMB bit on enquiry + +Make changes to is_removable() in rescan-scsi-bus.sh to correctly +read the RMB byte on its hexedit enquiry response. + +As things stand the script incorrectly reads the first byte of the +repsonse the "Peripheral Qualifier" and will always return a device +as non-removable. + +Signed-off-by: Paul Evans +--- + scripts/rescan-scsi-bus.sh | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 0c25dbb1..81348cf8 100755 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -4,7 +4,7 @@ + # (c) 2006--2022 Hannes Reinecke, GNU GPL v2 or later + # $Id: rescan-scsi-bus.sh,v 1.57 2012/03/31 14:08:48 garloff Exp $ + +-VERSION="20230413" ++VERSION="20260126" + SCAN_WILD_CARD=4294967295 + + TMPLUNINFOFILE="/tmp/rescan-scsi-mpath-info.txt" +@@ -247,9 +247,10 @@ is_removable () + + p=/sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/inquiry + # Extract the second byte of the INQUIRY response and check bit 7 (mask 0x80). +- b=$(hexdump -n1 -e '/1 "%02X"' "$p" 2>/dev/null) ++ b=$(od -j1 -N1 -An -t x1 "$p" 2>/dev/null) + if [ -n "$b" ]; then +- echo $(((0x$b & 0x80) != 0)) ++ # Handle od leading space with parameter substitution. ++ echo $(((0x${b// /} & 0x80) != 0)) + else + sg_inq "$sg_len_arg" /dev/$SGDEV 2>/dev/null | sed -n 's/^.*RMB=\([0-9]*\).*$/\1/p' + fi +-- +2.53.0 + diff --git a/RHEL-69439-Update-sg_rdac.c-to-accept--help-or--h-without-erro.patch b/RHEL-69439-Update-sg_rdac.c-to-accept--help-or--h-without-erro.patch new file mode 100644 index 0000000..272e78e --- /dev/null +++ b/RHEL-69439-Update-sg_rdac.c-to-accept--help-or--h-without-erro.patch @@ -0,0 +1,38 @@ +From 6450fb311edc28df015c977197bea5da7702ab80 Mon Sep 17 00:00:00 2001 +From: Fan Fan +Date: Thu, 28 Nov 2024 21:35:14 +0800 +Subject: [PATCH] Update sg_rdac.c to accept --help or -h without error , + update the version number. + +--- + src/sg_rdac.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/sg_rdac.c b/src/sg_rdac.c +index a5476daa..50b4207c 100644 +--- a/src/sg_rdac.c ++++ b/src/sg_rdac.c +@@ -32,7 +32,7 @@ + #include "sg_pr2serr.h" + + +-static const char * version_str = "1.18 20230622"; ++static const char * version_str = "1.19 20241128"; + + static const uint8_t mode6_hdr[] = { + 0x75, /* Length */ +@@ -405,8 +405,13 @@ int main(int argc, char * argv[]) + + for (k = 1; k < argc; ++k) { + argptr = argv + k; +- if (!strcmp (*argptr, "-v")) ++ if (strcmp(argv[k], "--help") == 0 || strcmp(argv[k], "-h") == 0) { ++ usage (); ++ return 0; ++ } ++ else if (!strcmp (*argptr, "-v")) { + ++do_verbose; ++ } + else if (!strncmp(*argptr, "-f=",3)) { + fail_path = true; + lun = strtoul(*argptr + 3, NULL, 0); diff --git a/RHEL-70693-rescan-scsi-bus.sh-Replace-which-with-build-in-comma.patch b/RHEL-70693-rescan-scsi-bus.sh-Replace-which-with-build-in-comma.patch new file mode 100644 index 0000000..119e0cd --- /dev/null +++ b/RHEL-70693-rescan-scsi-bus.sh-Replace-which-with-build-in-comma.patch @@ -0,0 +1,34 @@ +From 236875888f1c427fcc890842a9df0de8b768951d Mon Sep 17 00:00:00 2001 +From: Paul Evans +Date: Mon, 9 Feb 2026 15:21:53 +0000 +Subject: [PATCH] rescan-scsi-bus.sh Replace 'which' with build in 'command -v' + +Replace use of 'which' command to determine the existence of an +executable and replace with the built in 'command -v' to achieve +the same result. And to also remove the package dependency for +minimal environments where 'which' might not be available. + +Signed-off-by: Paul Evans +--- + scripts/rescan-scsi-bus.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 52991e1e..2c8560ad 100755 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -1350,9 +1350,9 @@ if [ -w /sys/module/scsi_mod/parameters/default_dev_flags ] && [ $scan_flags != + unset OLD_SCANFLAGS + fi + fi +-DMSETUP=$(which dmsetup) ++DMSETUP=$(version -s dmsetup) + [ -z "$DMSETUP" ] && flush= && mp_enable= +-MULTIPATH=$(which multipath) ++MULTIPATH=$(version -s multipath) + [ -z "$MULTIPATH" ] && flush= && mp_enable= + + echo -n "Scanning SCSI subsystem for new devices" +-- +2.53.0 + diff --git a/sg3_utils.spec b/sg3_utils.spec index e36aa38..1508510 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -4,7 +4,7 @@ Summary: Utilities for devices that use SCSI command sets Name: sg3_utils Version: 1.48 -Release: 7%{?dist} +Release: 8%{?dist} License: GPL-2.0-or-later AND BSD-2-Clause URL: https://sg.danny.cz/sg/sg3_utils.html Source0: https://sg.danny.cz/sg/p/sg3_utils-%{version}.tar.xz @@ -12,6 +12,20 @@ Source1: scsi-rescan.8 # https://github.com/doug-gilbert/sg3_utils/pull/47 Patch0: udev_rules-avoid_spurious_warning_for_non-SCSI_devices.patch +# https://redhat.atlassian.net/browse/RHEL-153277 +Patch1: RHEL-153277-rescan-scsi-bus.sh-Correctly-read-RMB-bit-on-enquiry.patch +# https://redhat.atlassian.net/browse/RHEL-70693 +Patch2: RHEL-70693-rescan-scsi-bus.sh-Replace-which-with-build-in-comma.patch +# https://redhat.atlassian.net/browse/RHEL-125869 +Patch3: RHEL-125869-Update-sg_safte.c-to-update-short-option-of-version.patch +# https://redhat.atlassian.net/browse/RHEL-69439 +Patch4: RHEL-69439-Update-sg_rdac.c-to-accept--help-or--h-without-erro.patch +# https://redhat.atlassian.net/browse/RHEL-119246 +# https://redhat.aslassian.net/browse/RHEL-123748 +Patch5: RHEL-119246-1-sg_inq-fix-missing-output-fields-in--export-format.patch +# https://redhat.atlassian.net/browse/RHEL-119246 +# https://redhat.aslassian.net/browse/RHEL-123748 +Patch6: RHEL-119246-2-sg_inq-re-add-Unit-serial-number-field.patch Requires: %{name}-libs%{?_isa} = %{version}-%{release} BuildRequires: make @@ -128,6 +142,14 @@ install -p -m 755 scripts/fc_wwpn_id %{buildroot}%{_udevlibdir} %changelog +* Wed Mar 25 2026 Paul Evans - 1.48-8 +- rescan-scsi-bus.sh: Correctly read RMB bit on enquiry (RHEL-153277) +- rescan-scsi-bus.sh: Replace 'which' with build in 'command -v' (RHEL-70693) +- sg_safte: update short option of version (RHEL-125869) +- sg_rdac: accept --help or -h without error (RHEL-69439) +- sg_inq: fix issing output fields in --export format (RHEL-119246, RHEL-123748) +- sg_inq: re-add Unit serial number field (RHEL-119246, RHEL-123748) + * Mon Nov 04 2024 Tomas Bzatek - 1.48-7 - udev rules: avoid spurious warning for non-SCSI devices (RHEL-40861,RHEL-54607) - Install missing 00-scsi-sg3_config.rules