1SG_OPCODES(8)                      SG3_UTILS                     SG_OPCODES(8)
2
3
4

NAME

6       sg_opcodes  -  report  supported SCSI commands or task management func‐
7       tions
8

SYNOPSIS

10       sg_opcodes  [--alpha]  [--compact]   [--enumerate]   [--help]   [--hex]
11       [--mask]  [--mlu]  [--no-inquiry] [--opcode=OP[,SA]] [--pdt=DT] [--raw]
12       [--rctd] [--repd] [--sa=SA] [--tmf]  [--unsorted]  [--verbose]  [--ver‐
13       sion] DEVICE
14
15       sg_opcodes [-a] [-c] [-e] [-H] [-m] [-M] [-n] [-o=OP] [-p=DT] [-q] [-R]
16       [-s=SA] [-t] [-u] [-v] [-V] [-?]  DEVICE
17

DESCRIPTION

19       This utility sends a SCSI REPORT SUPPORTED OPERATION CODES or a  REPORT
20       SUPPORTED TASK MANAGEMENT FUNCTIONS command to the DEVICE and then out‐
21       puts the response. The default action is to report supported  operation
22       codes.  In this mode it will either list all supported commands or give
23       detailed information on a specific  command  identified  by  the  --op‐
24       code=OP  option  (perhaps  with additional information from the --sa=SA
25       option).
26
27       The name of a SCSI command depends on its peripheral device type  (e.g.
28       a disk). The REPORT SUPPORTED OPERATION CODES and REPORT SUPPORTED TASK
29       MANAGEMENT FUNCTIONS commands are not supported in the MMC command  set
30       for  CD and DVD devices. This utility does an INQUIRY to obtain the pe‐
31       ripheral device type and prints out the vendor,  product  and  revision
32       strings.
33
34       A  similar  facility  to query supported operation codes previously was
35       available  via  the  CmdDt  bit  in  the  SCSI  INQUIRY  command   (see
36       sg_inq(8)). However that facility was made obsolete and replaced by the
37       REPORT SUPPORTED OPERATION CODES command in SPC-3 (revision  4)  during
38       February 2002.
39
40       This  utility  supports two command line syntaxes, the preferred one is
41       shown first in the synopsis and explained in this section. A later sec‐
42       tion  on  the  old command line syntax outlines the second group of op‐
43       tions.
44

OPTIONS

46       Arguments to long options are mandatory for short options as well.
47
48       -a, --alpha
49              when all supported commands are being listed  there  is  no  re‐
50              quirement  for  the  device server (i.e. the DEVICE) to sort the
51              list of commands. When this option is given  the  list  of  sup‐
52              ported  commands  is  sorted by name (alphabetically). When this
53              option and the --unsorted option are both _not_ given  then  the
54              list of supported commands is sorted numerically (first by oper‐
55              ation code and then by service action).
56
57       -c, --compact
58              some command names, especially those associated with  some  ser‐
59              vice  actions,  are  getting longer. This may cause line wrap in
60              the one line per command mode on some terminals. When  this  op‐
61              tion  is given the opcode and service action fields are combined
62              into a single field with the service action, prefixed by a comma
63              shown  directly  after the opcode. If there is no service action
64              associated with the command, then the comma and the service  ac‐
65              tion  are  not shown after the opcode. The CDB size field is not
66              shown when this option is given.
67
68       -e, --enumerate
69              this option prints the name of the SCSI  command  based  on  the
70              given  opcode, peripheral device type and optionally the service
71              action. If given, DEVICE is ignored. The opcode, peripheral  de‐
72              vice  type and service action default to zero if not given. Thus
73              if this option is the only option given then "Test  Unit  ready"
74              is output since its opcode is 0, it has no service action and it
75              is common to all peripheral device types since it is defined  in
76              the SCSI Primary Commands (SPC) standard(s).
77
78       -h, --help
79              outputs  the usage message summarizing command line options then
80              exits. Ignores DEVICE if given.
81
82       -H, --hex
83              outputs the response in ASCII hexadecimal to stdout.
84
85       -m, --mask
86              additionally prints out the cdb mask in hex. So a  12  byte  cdb
87              will  have a 12 byte hexadecimal mask. If the hexadecimal is ex‐
88              panded (mentally) to binary then a "1" means  the  corresponding
89              position  in the cdb may be set. And "0" means the corresponding
90              position in the cdb must not be set. For "0" mask positions that
91              a user tries to set in a cdb, the device may either ignore it or
92              report an error, typically with a  sense  key  of  "illegal  re‐
93              quest".
94
95       -M, --mlu
96              additionally  prints out an indication (0 or 1) whether the com‐
97              mand effects all logical units in  the  containing  target.  MLU
98              (Multiple Logical Units) is a bit in the REPORT SUPPORTED OPERA‐
99              TION CODES response introduced by proposal 18-045r1 (and  possi‐
100              bly  in  spc5r20). Without the option, the default output format
101              which lists all opcodes, does not include a MLU indication.
102
103       -n, --no-inquiry
104              Prior to calling a SCSI REPORT SUPPORTED OPERATION  CODES  or  a
105              REPORT  SUPPORTED  TASK MANAGEMENT FUNCTIONS command, a SCSI IN‐
106              QUIRY command is performed. The reason is to determine  the  pe‐
107              ripheral  device  type (pdt) of the DEVICE as this is helpful in
108              translating operation codes to the  command  names.  By  default
109              this  utility  prints  a  summary of INQUIRY command response on
110              stdout. If this option (or the --raw option) is given then  that
111              summary is not printed on stdout.
112
113       -O, --old
114              Switch to older style options. Please use as first option.
115
116       -o, --opcode=OP[,SA]
117              the  DEVICE  will  be queried for the given operation code (i.e.
118              the OP value) which is the first byte of a SCSI command. Option‐
119              ally,  if a SA value is given, it will be used as that SCSI com‐
120              mand's service action. Note that OP and OP,0 are  not  the  same
121              thing,  as SCSI does allow the service action to be 0 (but it is
122              not comman). OP and SA are decimal unless prefixed  by  "0x"  or
123              they  have  a  trailing "h".  OP should be in the range 0 to 255
124              (0xff) inclusive. SA should be in the range 0 to 65535  (0xffff)
125              inclusive. When this option is not given then all available SCSI
126              commands supported by the DEVICE are listed.
127
128       -p, --pdt=DT
129              where DT is the peripheral device type. This  is  used  together
130              with the --enumerate to differentiate when a command opcode (and
131              perhaps service action) is shared by multiple device types.
132              This option may also be used with  the  --no-inquiry  option  to
133              suppress  this  utility  doing an INQUIRY command since the main
134              reason for doing that is to find the peripheral device  type  of
135              the DEVICE.
136
137       -r, --raw
138              output  the  response  in  binary  to stdout. Error messages and
139              warnings, if any, are sent to stderr.
140
141       -R, --rctd
142              set report command timeout descriptor (RCTD) bit in the cdb. The
143              response  may or may not contain command timeout descriptors. If
144              available they are output. If supported there are two values:  a
145              nominal  command timeout and a recommended command timeout. Both
146              have units of seconds. A value of zero means that no timeout  is
147              indicated  and this is shown in the corresponding decoded output
148              as "-".
149
150       -q, --repd
151              set read extended parameter data (REPD) bit in the  report  task
152              management  functions  cdb.  16  bytes rather than the default 4
153              bytes expected in the response. This was added in  SPC-4  (revi‐
154              sion 26).
155
156       -s, --sa=SA
157              the  DEVICE will be queried for a command with the given service
158              action (i.e. the SA value). Used in conjunction with  the  --op‐
159              code=OP  option.  If  this  option  is not given, --opcode=OP is
160              given and the command in question does  have  a  service  action
161              then a value of 0 will be assumed. SA is decimal and expected to
162              be in the range 0 to 65535 (0xffff) inclusive.
163
164       -t, --tmf
165              list supported task management functions. This is done with  the
166              SCSI  REPORT  SUPPORTED TASK MANAGEMENT FUNCTIONS command.  When
167              this option is chosen the --alpha, --opcode=OP, --rctd,  --sa=SA
168              and --unsorted options are ignored.
169
170       -u, --unsorted
171              when  all  supported  commands  are being listed there is no re‐
172              quirement for the device server (i.e. the DEVICE)  to  sort  the
173              list  of  commands.  When  this option is given the list of sup‐
174              ported commands is in the order given by the DEVICE.  When  this
175              option  is  not  given the supported commands are sorted numeri‐
176              cally (first by operation code and then by service action).
177
178       -v, --verbose
179              increase level of verbosity. Can be used multiple times.
180
181       -V, --version
182              print out version string then exit.
183

NOTES

185       As of SPC-5 revision 8 the recognized task  management  functions  are:
186       abort  set, abort task set, clear ACA, clear task set, logical unit re‐
187       set, query task, query asynchronous event,  query  task  set,  and  I_T
188       nexus reset.  In SPC-4 revision 26 target reset and wakeup task manage‐
189       ment functions were made obsolete.
190
191       In the 2.4 series of Linux kernels the DEVICE must be  a  SCSI  generic
192       (sg)  device.  In the 2.6 series block devices (e.g. SCSI disks and DVD
193       drives) can also be specified. For example "sg_opcodes  /dev/sda"  will
194       work in the 2.6 series kernels.
195

EXIT STATUS

197       The exit status of sg_opcodes is 0 when it is successful. Otherwise see
198       the sg3_utils(8) man page.
199

OLDER COMMAND LINE OPTIONS

201       The options in this section were  the  only  ones  available  prior  to
202       sg3_utils  version 1.23 . Since then this utility defaults to the newer
203       command line options which can be overridden by using --old (or -O)  as
204       the first option. See the ENVIRONMENT VARIABLES section for another way
205       to force the use of these older command line options.
206
207       -a     sort command alphabetically. Equivalent to --alpha in  main  de‐
208              scription.
209
210       -c     see the --compact option above.
211
212       -e     see the --enumerate option above.
213
214       -H     see the --hex option above.
215
216       -m     see the --mask option above.
217
218       -n     don't print a summary of the SCSI INQUIRY response on stdout.
219
220       -N, --new
221              Switch to the newer style options.
222
223       -o=OP  the  DEVICE  will  be queried for the given operation code (i.e.
224              OP) which is the first byte of a SCSI command. OP is hexadecimal
225              and  expected  to  be in the range 0 to ff inclusive.  When this
226              option is not given then all available SCSI  commands  supported
227              by the DEVICE are listed.
228
229       -p=DT  see the --pdt=DT option above.
230
231       -q     set  the  read  extended parameter data (REPD) bit in report TMF
232              cdb.  Equivalent to --repd in main description.
233
234       -R     set the report command timeout descriptor  (RCTD)  bit  in  cdb.
235              Equivalent to --rctd in main description.
236
237       -s=SA  the  DEVICE will be queried for a command with the given service
238              action (i.e. SA). Used in conjunction with the -o=OP option.  If
239              this  option  is  not  given,  -o=OP is given and the command in
240              question does have a service action then a value of  0  will  be
241              assumed.  SA is hexadecimal and expected to be in the range 0 to
242              ffff inclusive.
243
244       -t     list supported task management functions. Equivalent to --tmf in
245              the main description.
246
247       -u     output  all  supported  commands  in  the order given by DEVICE.
248              Equivalent to --unsorted in main description.
249
250       -v     increase level of verbosity. Can be used multiple times.
251
252       -V     print out version string then exit.
253
254       -?     output usage message. Ignore all other parameters.
255

EXAMPLES

257       The examples in this page use Linux device names. For  suitable  device
258       names  in  other  supported  Operating Systems see the sg3_utils(8) man
259       page.
260
261       To see the information about a specific command give its operation code
262       to  the  '--op='  option. A command line invocation is shown first fol‐
263       lowed by a typical response:
264
265          # sg_opcodes --op=93h /dev/sdb
266
267         Opcode=0x93
268         Command_name: Write same(16)
269         Command supported [conforming to SCSI standard]
270         Usage data: 93 e2 00 00 00 00 ff ff ff ff 00 00 ff ff 00 00
271
272       The next example shows the supported task management functions:
273
274          # sg_opcodes --tmf -n /dev/sdb
275
276       Task Management Functions supported by device:
277           Abort task
278           Abort task set
279           Clear ACA
280           Clear task set
281           Logical unit reset
282           Query task
283
284       Enumerate can be used to look up a SCSI command name in the absence  of
285       a  device that supports that command. The opcode and service action (if
286       required) should be supplied:
287
288          # sg_opcodes --enumerate --op=0x9b,0xa
289
290         SCSI command:
291           Read buffer(16), read data from echo buffer
292

ENVIRONMENT VARIABLES

294       Since    sg3_utils    version    1.23    the    environment    variable
295       SG3_UTILS_OLD_OPTS  can  be given. When it is present this utility will
296       expect the older command line options. So the presence of this environ‐
297       ment variable is equivalent to using --old (or -O) as the first command
298       line option.
299

AUTHOR

301       Written by Douglas Gilbert
302

REPORTING BUGS

304       Report bugs to <dgilbert at interlog dot com>.
305
307       Copyright © 2004-2021 Douglas Gilbert
308       This software is distributed under the GPL version 2. There is NO  war‐
309       ranty;  not  even  for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
310       POSE.
311

SEE ALSO

313       sg_inq(sg3_utils)
314
315
316
317sg3_utils-1.46                    March 2020                     SG_OPCODES(8)
Impressum