* Wed Mar 25 2026 Paul Evans <pevans@redhat.com> - 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
This commit is contained in:
Paul Evans 2026-03-25 14:40:19 +00:00
parent 6bf0dcde62
commit bdc11156e6
7 changed files with 339 additions and 1 deletions

View File

@ -0,0 +1,121 @@
From 330aec139233fbec93966e68b46a8633b9efd41f Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
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 <mwilck@suse.com>
---
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

View File

@ -0,0 +1,52 @@
From e67d186ad6aec8dede8eaec79e4b8366ebc0ad50 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
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 <mwilck@suse.com>
---
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

View File

@ -0,0 +1,25 @@
From da138e7b28a7c5e8ea2bb1ae099245d65e23ec5e Mon Sep 17 00:00:00 2001
From: Fan <ffan@redhat.com>
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 <ffan@redhat.com>
---
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");
}

View File

@ -0,0 +1,46 @@
From b705f0105606520ca13f920a88756fbaa4355252 Mon Sep 17 00:00:00 2001
From: Paul Evans <pevans@redhat.com>
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 <pevans@redhat.com>
---
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

View File

@ -0,0 +1,38 @@
From 6450fb311edc28df015c977197bea5da7702ab80 Mon Sep 17 00:00:00 2001
From: Fan Fan <ffan@redhat.com>
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);

View File

@ -0,0 +1,34 @@
From 236875888f1c427fcc890842a9df0de8b768951d Mon Sep 17 00:00:00 2001
From: Paul Evans <pevans@redhat.com>
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 <pevans@redhat.com>
---
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

View File

@ -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 <pevans@redhat.com> - 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 <tbzatek@redhat.com> - 1.48-7
- udev rules: avoid spurious warning for non-SCSI devices (RHEL-40861,RHEL-54607)
- Install missing 00-scsi-sg3_config.rules