SG_READ_BUFFER(8)
β¨ SG_READ_BUFFER(8) β¨
okay bestie, welcome to the sg_read_buffer(8) manual π it's part of the SG3_UTILS crew π
πΈ NAME πΈ
sg_read_buffer - send SCSI READ BUFFER command
π¦ SYNOPSIS π¦
sg_read_buffer [--eh_code=EHC] [--help] [--hex] [--id=ID] [--inhex=FN]
[--length=LEN] [--mode=MO] [--no_output] [--offset=OFF] [--raw]
[--readonly] [--specific=MS] [--verbose] [--version] DEVICE
π DESCRIPTION π
okay so this tool sends a SCSI READ BUFFER command to the DEVICE π₯ if the device actually answers, you get to pick how it shows up: decoded, hexadecimal, or raw binary sent to stdout. ngl that's a whole vibe π
if the response comes from a "descriptor" mode, it gets decoded unless you pass --hex or --raw π non-descriptor modes print in hexadecimal by default, unless you use --raw.
the responses for the Read microcode status ('rd_microc_st' [0xf]) and Error history ('err_hist' [0x1c]) modes are decoded as described in spc6r06.pdf and earlier T10 documents π§
and literally the best part: you can skip DEVICE entirely and use --inhex=FN instead β¨ FN is a file name (or - for stdin). the contents get treated as hexadecimal (or binary) data representing a SCSI READ BUFFER command response, and then it gets decoded like usual π«Ά
π OPTIONS π
ok so the rule is: arguments to long options are mandatory for short options as well π same energy, different outfit.
-e,--eh_code=EHCβ this is the error history code that goes into the Buffer ID field of the cdb π the Mode field gets set to err_hist [0x1c]. it's basically the same as'--mode=eh --id=EHC'. if you give this plus another option and they contradict each other, it throws an error, so no drama allowed π the default (maximum) response length goes up to 64 bytes when it might need to, and if that happens the output will note it if it gets truncated β¨ for example, setting EHC to 0 decodes the error history directory (unless you use--hexor--raw) π-h,--helpβ prints the usage message and exits π use it multiple times and it also shows the mode names and their acronyms π«Ά-H,--hexβ outputs the response in hexadecimal π₯ give it twice and you get hex with the matching ASCII on the right side of each line π give it three times and the hex prints without the addresses (indexes) at the start of each line π that format is perfect for feeding into--inhex=FNon a later run β¨-i,--id=IDβ sets the Buffer ID field in the cdb π¦IDcan be anything from 0 (default) up to 255 inclusive πΈ what it means depends on the value in the Mode field of the cdb π-I,--inhex=FNβFNis a file name (or-for stdin) containing ASCII hexadecimal or binary that represents a READ BUFFER response π if it's known, this tool decodes that response for you π§ it's really better to also give--mode=MO,--id=IDand maybe--specific=MS, because those aren't stored in the response itself π check the "HEX, BINARY AND JSON FORMATS" section in the sg3_utils manpage for more deets π if you also give--raw, thenFNis treated as binary π₯-l,--length=LENβLENis the length in bytes that goes into the "allocation length" field of the cdb β¨ the default is 4 bytes, but it bumps up to 64 if the'err_hist'mode [0x1c] is given or implied π the device might respond with fewer bytes than you asked for, so don't panic π if you use--inhex=FN, the default length jumps to 8192 bytes, and then it can get reduced to match the number of bytes decoded from the contents ofFNπ-m,--mode=MOβ sets the mode field in the cdb πMOis a value between 0 (default) and 31 inclusive π you can also use an abbreviation instead, see the MODES section below π¦ to list the available mode abbreviations, just use an invalid one (e.g.'--mode=xxx') π for example, to fetch the read buffer descriptor, give'--mode=desc'π-N,--no_outputβ when you give this, the response still gets sent and processed looking for any errors, and then the tool exits π any data read by the READ BUFFER command gets ignored π this one might be useful for timing bigger reads from the DEVICE buffer in'data'mode [0x2] β±οΈ-o,--offset=OFFβ sets the buffer offset field in the cdb π§OFFis a byte offset, anywhere from 0 (default) to 2**24-1 β¨-r,--rawβ if a response comes back, it gets sent to stdout in binary π when you combine this with--inhex=FN, the contents ofFNare assumed to be binary, and the output of this tool is normal ASCII (so _not_ binary) π-R,--readonlyβ opens theDEVICEread-only (like with theO_RDONLYflag on Unix) π the default is read-write, so this is the move if you want to be extra safe π«Ά-S,--specific=MSβ sets the mode specific field in the cdb πΈMSis a value between 0 and 7, since it's a 3 bit field π-v,--verboseβ cranks up the verbosity, aka more debug output π main character energy for debugging π-V,--versionβ prints the version string and then exits π
π§ MODES π§
okay so here's the full list of READ BUFFER command settings for the MODE field π each one starts with an acronym that the MO argument of this utility accepts β¨ right after the acronym, in square brackets, are the matching decimal and hex values that you can also give for MO π¦ they're listed in numerical order, so no guessing needed π
hd[0, 0x0]β combined header and data π₯ (obsolete in SPC-4)vendor[1, 0x1]β vendor specific πdata[2, 0x2]β data πdesc[3, 0x3]β descriptor π this one yields 4 bytes that contain an offset boundary field (1 byte) and a buffer capacity (3 bytes) β¨echo[10, 0xa]β reads data from the echo buffer π«Ά (this was called "Echo buffer" in SPC-3)echo_desc[11, 0xb]β echo buffer descriptor π₯ yields 4 bytes, and the last (lowest) 13 bits represent the echo buffer capacity π the maximum echo buffer size is 4096 bytes πrd_microc_st[15, 0xf]β read microcode status π§ added in spc5r20 β¨en_ex[26, 0x1a]β enables the expander communications protocol and the Echo buffer πΈ made obsolete in SPC-4 π₯err_hist|eh[28, 0x1c]β error history π you can use either'err_hist'or the short'eh'abbreviation for this mode π introduced in SPC-4 π
π NOTES π
all numbers given with options are assumed to be decimal, bestie π but if you want hex, you can write it with either a "0x" or "0X" prefix (or put a trailing "h" or "H" on it) β¨
πͺ EXIT STATUS πͺ
the exit status of sg_read_buffer is 0 when it's successful π
otherwise, check the sg3_utils(8) man page π
π©βπ» AUTHORS π©βπ»
written by Luben Tuikov and Douglas Gilbert π«Ά
π REPORTING BUGS π
report bugs to <dgilbert at interlog dot com> π
βοΈ COPYRIGHT βοΈ
Copyright Β© 2006-2023 Luben Tuikov and 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_write_buffer(sg3_utils) π
that's the whole tea βπ this is sg3_utils-1.48 from June 2023, and it's giving SG_READ_BUFFER(8) realness forever πβ¨
π¦ where this page comes from
- alpine 3.24: sg3_utils-doc 1.48-r0 Β· BSD-2-Clause AND GPL-2.0-or-later
- arch rolling: sg3_utils 1.49-1 Β· GPL-2.0-or-later AND BSD-2-Clause
- centos-stream 10: sg3_utils 1.48-11.el10 Β· GPL-2.0-or-later AND BSD-2-Clause
- debian trixie: sg3-utils 1.48-3~deb13u1
- fedora 43: sg3_utils 1.48-10.fc43 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 43: sg3_utils 1.48-6.fc43 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-10.fc44 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-8.fc44 Β· GPL-2.0-or-later AND BSD-2-Clause
- nixos 26.05: sg3_utils 1.48
- nixpkgs unstable: sg3_utils 1.49
- ubuntu questing: sg3-utils 1.48-2ubuntu1
- ubuntu resolute: sg3-utils 1.48-3ubuntu3
- ubuntu resolute: sg3-utils 1.48-3ubuntu3.2
- ubuntu stonking: sg3-utils 1.48-3ubuntu5
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms