SG_STREAM_CTL(8)
π NAME π
okay so bestie, this is sg_stream_ctl, an sg3_utils manual page in section 8, and its whole main-character job is to send a SCSI GET STREAM STATUS or STREAM CONTROL command. periodt π
β¨ SYNOPSIS β¨
sg_stream_ctl [--brief] [--close] [--ctl=CTL] [--get] [--help] [--hex]
[--id=SID] [--inhex=FN] [--json[=JO]] [--js-file=JFN] [--maxlen=LEN]
[--open] [--raw] [--readonly] [--verbose] [--version] DEVICE
π DESCRIPTION π
This utility sends a SCSI GET STREAM STATUS or STREAM CONTROL command to the DEVICE. π«Ά These commands, together with WRITE STREAM(16 and 32) and several fields in the Block Limits Extension VPD page [0xb7], support the streams concept. There is also the IO advice hints grouping mode page [0xa,0x4]. Amongst other things, that mode page indicates whether a stream identifier does double duty as a group number found in most SCSI media access commands (e.g. READ, WRITE and VERIFY). iykyk π
The stream commands were added in SBC-4 draft 8 (September 2015). The stream commands were extended in SBC-5 draft 5 (October 2023).
Both the GET STREAM STATUS and STREAM CONTROL commands expect data from the DEVICE (referred to as "data-in"). In the case of STREAM CONTROL only the "open" (STR_CTL<--0x1) actually needs the data-in as it contains the "Assigned stream id" if the open was successful. The assigned stream id should be used by subsequent WRITE STREAM commands and ultimately by the STREAM CONTROL close (STR_CTL<--0x2). Valid stream ids are between 1 and 65535 inclusive. no cap β¨
π OPTIONS π
Arguments to long options are mandatory for short options as well.
-b,--briefβ this option reduces the output of theGET STREAM STATUScommand to just one number (in decimal) per line sent to stdout. Those numbers are the currently open stream ids. If an error occurs then-1is sent to stdout and error related messages are sent to stderr. The default is to print more words (and fields) from theGET STREAM STATUSresponse.-c,--closeβ selects theSTREAM CONTROLcommand and setsSTR_CTL<--0x2(i.e. "close"). The--id=SIDoption should also be given because it defaults to0which is not a valid stream id. π«Ά-C,--ctl=CTLβCTLis the value placed in theSTR_CTLfield of theSTREAM CONTROLcommand (cdb). It is a two bit field so has 4 variants:0and3are reserved;1opens a new stream and2closes the given stream id.--ctl=1is equivalent to--openwhile--ctl=2is equivalent to--close.-g,--getβ selects theGET STREAM STATUScommand. If the--id=SIDoption is also given then the response starts listing open stream ids from and includingSID. If the--id=SIDoption is not given (orSIDis0) 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 to248bytes which can be overridden by the--maxlen=LENoption.
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.
-h,--helpβ output the usage message then exit.-H,--hexβ (yes, the raw page literally lists this same-H,--hexheader twice; it's still just this one option, bestie π«Ά) output response to this command in ASCII hex. Each line of 16 bytes is preceded by an address or index, starting at0and the address is also in hex. If given twice then an ASCII rendering of each byte is appended to the line output. If given three or more times then only the ASCII hex of each byte is output, 16 bytes per line (i.e. so no leading address nor trailing ASCII rendering). This latter form is suitable for placing in a file and being used with the--inhex=FNoption in a later invocation.-i,--id=SIDβSIDis a stream id, a value between1and65535. It is used bySTREAM CONTROL(close) to identify the stream to close. It is used by theGET STREAM STATUScommand as the starting stream id (from and including); so stream ids that are less thanSIDwill not appear in the response.-I,--inhex=FNβ whereFNis a file name whose contents are assumed to be ASCII hexadecimal. IfDEVICEis also given thenDEVICEis ignored, a warning is issued and the utility continues, decoding the file namedFN. See the "HEX, BINARY AND JSON FORMATS" section in thesg3_utilsmanpage for more information. If the--rawoption is also given then the contents ofFNare treated as binary.FNmay either contain data representing the response to a SCSIGET STREAM STATUSor aSTREAM CONTROLcommand. This utility defaults to expecting the former. WhenFNcontains data from aSTREAM CONTROLcommand response then an additional option (other than this option) needs to be given: either--close,--ctl=CTL, or--open. π¦-j[=JO],--json[=JO]β output is in JSON format instead of plain text form. Note that arguments to the short and long form are themselves optional and if present start with=and no whitespace is permitted around that=. Seesg3_utils_jsonmanpage or use?forJOto get a summary.-J,--js-file=JFNβ output is in JSON format and it is sent to a file namedJFN. If that file exists then it is truncated. By default, the JSON output is sent to stdout. When this option is given, the--json[=JO]option is implied and need not be given. The--json[=JO]option may still be needed to set theJOparameter to non-default values.-m,--maxlen=LENβLENis the maximum length the response can be. It becomes theALLOCATION LENGTHfield in both commands. The default (in the absence of this option) is8bytes forSTREAM CONTROLand248bytes forGET STREAM STATUS.-o,--openβ selects theSTREAM CONTROLcommand and setsSTR_CTL<--0x1(i.e. "open"). If the--id=SIDoption is given then it is ignored. The user should observe the response as the "Assigned stream id" is printed on stdout if the open is successful, if not-1is sent to stdout and error messages are sent to stderr. If the--briefoption is also given then the only thing sent to stdout is a number of the assigned stream id (1to65535inclusive) or-1if there is an error.-r,--readonlyβ this option sets a "read-only" flag when the underlying operating system opens the givenDEVICE. This may not work since operating systems can not easily determine whether a pass-through command is a logical read or write operation on the media (or its metadata) so they take a risk averse stance and require read-write type permissions on theDEVICEopen irrespective of what is performed by the pass-through.-R,--rawβ output response in binary (to stdout) unless the--inhex=FNoption is also given. In that case the input file name (FN) is decoded as binary (and the output is not in binary). To relax that final restriction this option can be given multiple times. If this option is given once or three times,FNis assumed to be binary. If this option is given two or three times, the (undecoded) output is in binary. These actions only apply when the--inhex=FNoption is given (the original page typo saysia, but it's giving "is" energy π).-v,--verboseβ increase the level of verbosity, (i.e. debug output).-V,--versionβ print the version string and then exit.
πΈ NOTES πΈ
There are no special read commands for streams. This implies that "normal" READs (6, 10, 12, 16 or 32) can be used. Note that when a stream is closed, all resources associated with that stream id are removed, apart from the data in the written LBAs. To make sure the reading back data is not delayed too much by error recovery (in the presence of media errors) the user may set the RECOVERY TIME LIMIT field (RTL, units for non-zero values: milliseconds) in the "Read-write error recovery" mode page. This can be done with the sdparm utility. π§
The SCSI WRITE STREAM (16 and 32) commands can be found in the sg_write_x utility in this package.
β EXIT STATUS β
The exit status of sg_stream_ctl is 0 when it is successful. Otherwise see the sg3_utils(8) man page.
π¦ AUTHORS π¦
Written by Douglas Gilbert.
π REPORTING BUGS π
Report bugs to <dgilbert at interlog dot com>.
π COPYRIGHT π
Copyright Β© 2018-2023 Douglas Gilbert
This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
π SEE ALSO π
sg_vpd,sg_write_x(sg3_utils); sdparm(sdparm)
mwah π β this page is from sg3_utils-1.49, dated December 2023, and it's chillin' in the SG_STREAM_CTL(8) section. bye bestie, go slay your streams! ππ
π¦ where this page comes from
- arch rolling: sg3_utils 1.49-1 Β· GPL-2.0-or-later AND BSD-2-Clause
- nixpkgs unstable: sg3_utils 1.49
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms