hreinecke / sg3_utils

Deprecated git-svn mirror for sg3_utils
http://sg.danny.cz/sg/sg3_utils.html
Other
154 stars 91 forks source link

In the rescan-scsi-bus.sh script version 1.46, the output data format is incorrect #76

Closed insistxc closed 2 years ago

insistxc commented 2 years ago

In the rescan-scsi-bus.sh script version 1.46, the output data format is incorrect

The error format is as follows: Scanning host 6 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 7 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 8 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 9 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs 0 new or changed device(s) found.
0 remapped or resized device(s) found. 0 device(s) removed.

Version 1.42 is normal Scanning host 19 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 20 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 21 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 22 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 23 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 24 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 25 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 26 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 27 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 28 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 29 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 30 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 31 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 32 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 4 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs

I'm not sure if this is a bug

doug-gilbert commented 2 years ago

I'm consulting with others to find out if this is a regression that needs to be fixed. My upstream version of this script outputs what is shown in the OP for sg3_utils 1.46 (i.e. staggered, multi-line output).

mwilck commented 2 years ago

This looks like a minor bug, introduced by 8c86fe26 ("library: add to '.so' name; rescan-scsi-bus: multiple patches to sync with Suse", and originally by the SUSE commit f9773b31 ("scripts/rescan-scsi-bus.sh: Fixup globbing and replace 'test' with '[]'").

The problem is caused by this hunk:

@@ -1311,12 +1337,12 @@ else
   [ -n "$channelsearch" ] && echo -n "channels $channelsearch "
   echo -n "for "
   if [ -n "$idsearch" ] ; then
-    echo -n " SCSI target IDs " $idsearch
+    echo -n " SCSI target IDs $idsearch"
   else
     echo -n " all SCSI target IDs"
   fi
   if [ -n "$lunsearch" ] ; then
-    echo ", LUNs " $lunsearch
+    echo ", LUNs $lunsearch"
   else
     echo ", all LUNs"

The target list was created by the seq command, which separates numbers by newlines by default. By using "$idsearch" rather than $idsearch, the newlines are preserved in the output. The simplest fix is probably to just revert this hunk. Another option, probably safer, option would be to use seq -s ' ' instead of just seq to generate the sequences.

I was wondering whether seq -s is portable, but I discovered that seq is a GNU extension anyway, so I'm guessing the script doesn't see much use on non-GNU systems..

mwilck commented 2 years ago

@insistxc , please test the fix in https://github.com/doug-gilbert/sg3_utils/pull/13

doug-gilbert commented 2 years ago

This regression has been fixed upstream by applying a patch proposed by Martin Wilck. The fix is mirrored in https://github.com/doug-gilbert/sg3_utils . Thanks.