Skip to content

Commit

Permalink
sg_stream_ctl: fix handling of GET STREAM STATUS
Browse files Browse the repository at this point in the history
Full message: sg_stream_ctl: fix handling of GET STREAM STATUS descriptor
fields (sbc5r06.pdf).

Merge branch 'svn_sync':
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@1070 6180dd3e-e324-4e3e-922d-17de1ae2f315
  • Loading branch information
doug-gilbert committed Dec 3, 2023
2 parents 93d3da1 + 939a5af commit 9e46d85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
5 changes: 3 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 11 additions & 9 deletions doc/sg_stream_ctl.8
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
20 changes: 6 additions & 14 deletions src/sg_stream_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -703,14 +703,6 @@ main(int argc, char * argv[])
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)
Expand All @@ -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)
Expand Down

0 comments on commit 9e46d85

Please sign in to comment.