aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2023-12-03 05:04:19 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2023-12-03 05:04:19 +0000
commit939a5afde84030b7f3e0a2aa9a451edd5fe82211 (patch)
tree818ac0a6a51d74a9333a77e89821447fb34942a2
parent38737e4e0cf4873a51f521600735acd52144cf52 (diff)
downloadsg3_utils-939a5afde84030b7f3e0a2aa9a451edd5fe82211.tar.gz
sg_stream_ctl: fix handling of GET STREAM STATUS descriptor fields (sbc5r06.pdf)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@1070 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog5
-rw-r--r--doc/sg_stream_ctl.820
-rw-r--r--src/sg_stream_ctl.c20
3 files changed, 20 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index d6cdf7b9..71c7bd1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for pre-release sg3_utils-1.49 [20231201] [svn: r1069]
+Changelog for pre-release sg3_utils-1.49 [20231202] [svn: r1070]
- JSON: make output more consistent so most command
responses have a *_paramter_data or similar sub-object
- apply https://github.com/doug-gilbert/sg3_utils/pull/39
@@ -23,7 +23,8 @@ Changelog for pre-release sg3_utils-1.49 [20231201] [svn: r1069]
https://github.com/doug-gilbert/sg3_utils/issues/45
- sg_get_elem_status: various improvements
- sg_stream_ctl: add --hex, --inhex=, --json= and --raw
- options; additions in sbc5r05
+ options; additions in sbc5r05 (perm and relative_lifetime
+ fields).
- rescan-scsi-bus.sh: fix multipath resize without update
https://github.com/doug-gilbert/sg3_utils/pull/43.diff
and 44.diff
diff --git a/doc/sg_stream_ctl.8 b/doc/sg_stream_ctl.8
index 850d6c7f..fd964ffb 100644
--- a/doc/sg_stream_ctl.8
+++ b/doc/sg_stream_ctl.8
@@ -1,4 +1,4 @@
-.TH SG_STREAM_CTL "8" "October 2023" "sg3_utils\-1.49" SG3_UTILS
+.TH SG_STREAM_CTL "8" "December 2023" "sg3_utils\-1.49" SG3_UTILS
.SH NAME
sg_stream_ctl \- send SCSI GET STREAM STATUS or STREAM CONTROL command
.SH SYNOPSIS
@@ -50,14 +50,16 @@ command (cdb). It is a two bit field so has 4 variants: 0 and 3 are reserved;
equivalent to '\-\-open' while '\-\-ctl=2' is equivalent to '\-\-close'.
.TP
\fB\-g\fR, \fB\-\-get\fR
-selects the GET STREAM STATUS command. If the \fI\-\-id=SID\fR option is
-also given the the response starts lists open stream ids from and including
+selects the GET STREAM STATUS command. If the \fI\-\-id=SID\fR option is also
+given then the response starts listing open stream ids from and including
\fISID\fR. If the \fI\-\-id=SID\fR option is not given (or \fISID\fR is 0)
-then all open stream id will be returned in the response (data\-in) as long
-as the allocation length (defaults to 248 bytes which can be overridden by
-the \fI\-\-maxlen=LEN\fR option) is long enough. This is the default action
-of this utility (i.e. GET STREAM STATUS command) if no "selecting" options
-are given.
+then all open stream ids will be returned in the response (data\-in) as long
+as the allocation length is long enough. The allocation length defaults to
+248 bytes which can be overridden by the \fI\-\-maxlen=LEN\fR option.
+.IP
+This option usually does not need to be given as calling the GET STREAM
+STATUS command is the default action of this utility in the absence of any
+other "selecting" option.
.TP
\fB\-h\fR, \fB\-\-help\fR
output the usage message then exit.
@@ -79,7 +81,7 @@ CONTROL (close) to identify the stream to close. It is used by the GET
STREAM STATUS command as the starting stream id (from and including); so
stream ids that are less than \fISID\fR will not appear in the response.
.TP
-\fB\-i\fR, \fB\-\-inhex\fR=\fIFN\fR
+\fB\-I\fR, \fB\-\-inhex\fR=\fIFN\fR
where \fIFN\fR is a file name whose contents are assumed to be ASCII
hexadecimal. If \fIDEVICE\fR is also given then \fIDEVICE\fR is ignored,
a warning is issued and the utility continues, decoding the file named
diff --git a/src/sg_stream_ctl.c b/src/sg_stream_ctl.c
index d8c08bdc..afb98a35 100644
--- a/src/sg_stream_ctl.c
+++ b/src/sg_stream_ctl.c
@@ -36,7 +36,7 @@
* to the given SCSI device. Based on sbc4r15.pdf .
*/
-static const char * version_str = "1.16 20231020";
+static const char * version_str = "1.17 20231202";
#define MY_NAME "sg_stream_ctl"
#define STREAM_CONTROL_SA 0x14
@@ -703,14 +703,6 @@ start_get_response:
goto fini;
}
}
-#if 0
-sgj_haj_vi(jsp, jo2p, 0, "Parameter data length",
- SGJ_SEP_COLON_1_SPACE, param_dl, false);
-sgj_pr_hr(jsp, "No complete physical element status descriptors "
- "available\n");
-sgj_js_nv_ihex(jsp, jo2p, "element_identifier",
- (int64_t)a_ped.elem_id);
-#endif
num_streams = sg_get_unaligned_be16(arr + 6);
if (! op->do_brief) {
if (op->stream_id > 0)
@@ -724,22 +716,22 @@ sgj_js_nv_ihex(jsp, jo2p, "element_identifier",
jap = sgj_named_subarray_r(jsp, jo2p, "stream_status_descriptor");
for (k = 8; k < op->maxlen; k += 8) {
- uint8_t perm = (0x1 & arr[k]);
+ bool perm = !! (0x80 & arr[k]);
uint8_t rel_lt = (0x7f & arr[k + 4]);
uint16_t strm_id = sg_get_unaligned_be16(arr + k + 2);
if (jsp->pr_as_json) {
jo3p = sgj_new_unattached_object_r(jsp);
- sgj_js_nv_ihex_nex(jsp, jo3p, "perm", perm, false,
+ sgj_js_nv_ihex_nex(jsp, jo3p, "perm", (int)perm, false,
"permanent stream");
- sgj_js_nv_ihex(jsp, jo3p, "element_identifier", strm_id);
+ sgj_js_nv_ihex(jsp, jo3p, "stream_identifier", strm_id);
sgj_js_nv_ihex(jsp, jo3p, "relative_lifetime", rel_lt);
}
if (op->do_brief)
sgj_pr_hr(jsp, " %u\n", strm_id);
else {
- sgj_pr_hr(jsp, " PERM: %u\n", perm);
- sgj_pr_hr(jsp, " Open stream id: %u\n", strm_id);
+ sgj_pr_hr(jsp, " PERM: %u\n", (int)perm);
+ sgj_pr_hr(jsp, " Stream identifier: %u\n", strm_id);
sgj_pr_hr(jsp, " Relative lifetime: %u\n", rel_lt);
}
if (jsp->pr_as_json)