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]  [--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
24       --opcode=OP  option  (perhaps  with  additional  information  from  the
25       --sa=SA 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
31       peripheral 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
43       options.
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
50              requirement  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
61              option  is  given  the opcode and service action fields are com‐
62              bined into a single field with the service action, prefixed by a
63              comma  shown  directly  after the opcode. If there is no service
64              action associated with the command, then the comma and the  ser‐
65              vice  action  are not shown after the opcode. The CDB size field
66              is not 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
72              device  type  and  service  action default to zero if not given.
73              Thus if this option is the only option  given  then  "Test  Unit
74              ready" is output since its opcode is 0, it has no service action
75              and it is common to all peripheral  device  types  since  it  is
76              defined in 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
88              expanded (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
93              request".
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
106              INQUIRY command is performed. The reason  is  to  determine  the
107              peripheral 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
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.  OP  is
119              decimal  unless  prefixed  by  "0x" or it has a trailing "h". OP
120              should be in the range 0 to  255  (0xff)  inclusive.  When  this
121              option  is  not given then all available SCSI commands supported
122              by the DEVICE are listed.
123
124       -p, --pdt=DT
125              where DT is the peripheral device type. This  is  used  together
126              with the --enumerate to differentiate when a command opcode (and
127              perhaps service action) is shared by multiple device types.
128              This option may also be used with  the  --no-inquiry  option  to
129              suppress  this  utility  doing an INQUIRY command since the main
130              reason for doing that is to find the peripheral device  type  of
131              the DEVICE.
132
133       -r, --raw
134              output  the  response  in  binary  to stdout. Error messages and
135              warnings, if any, are sent to stderr.
136
137       -R, --rctd
138              set report command timeout descriptor (RCTD) bit in the cdb. The
139              response  may or may not contain command timeout descriptors. If
140              available they are output. If supported there are two values:  a
141              nominal  command timeout and a recommended command timeout. Both
142              have units of seconds. A value of zero means that no timeout  is
143              indicated  and this is shown in the corresponding decoded output
144              as "-".
145
146       -q, --repd
147              set read extended parameter data (REPD) bit in the  report  task
148              management  functions  cdb.  16  bytes rather than the default 4
149              bytes expected in the response. This was added in  SPC-4  (revi‐
150              sion 26).
151
152       -s, --sa=SA
153              the  DEVICE will be queried for a command with the given service
154              action (i.e.  the  SA  value).  Used  in  conjunction  with  the
155              --opcode=OP  option. If this option is not given, --opcode=OP is
156              given and the command in question does  have  a  service  action
157              then a value of 0 will be assumed. SA is decimal and expected to
158              be in the range 0 to 65535 (0xffff) inclusive.
159
160       -t, --tmf
161              list supported task management functions. This is done with  the
162              SCSI  REPORT  SUPPORTED TASK MANAGEMENT FUNCTIONS command.  When
163              this option is chosen the --alpha, --opcode=OP, --rctd,  --sa=SA
164              and --unsorted options are ignored.
165
166       -u, --unsorted
167              when  all  supported  commands  are  being  listed  there  is no
168              requirement for the device server (i.e. the DEVICE) to sort  the
169              list  of  commands.  When  this option is given the list of sup‐
170              ported commands is in the order given by the DEVICE.  When  this
171              option  is  not  given the supported commands are sorted numeri‐
172              cally (first by operation code and then by service action).
173
174       -v, --verbose
175              increase level of verbosity. Can be used multiple times.
176
177       -V, --version
178              print out version string then exit.
179

NOTES

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

EXIT STATUS

193       The exit status of sg_opcodes is 0 when it is successful. Otherwise see
194       the sg3_utils(8) man page.
195

OLDER COMMAND LINE OPTIONS

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

EXAMPLES

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

ENVIRONMENT VARIABLES

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

AUTHOR

297       Written by Douglas Gilbert
298

REPORTING BUGS

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

SEE ALSO

309       sg_inq(sg3_utils)
310
311
312
313sg3_utils-1.43                     June 2018                     SG_OPCODES(8)
Impressum