1SG_OPCODES(8) SG3_UTILS SG_OPCODES(8)
2
3
4
6 sg_opcodes - report supported SCSI commands or task management func‐
7 tions
8
10 sg_opcodes [--alpha] [--compact] [--help] [--hex] [--no-inquiry]
11 [--opcode=OP] [--raw] [--rctd] [--repd] [--sa=SA] [--tmf] [--unsorted]
12 [--verbose] [--version] DEVICE
13
14 sg_opcodes [-a] [-c] [-n] [-o=OP] [-q] [-R] [-s=SA] [-t] [-u] [-v] [-V]
15 [-?] DEVICE
16
18 This utility sends a SCSI REPORT SUPPORTED OPERATION CODES or a REPORT
19 SUPPORTED TASK MANAGEMENT FUNCTIONS command to the DEVICE and then out‐
20 puts the response. The default action is to report supported operation
21 codes. In this mode it will either list all supported commands or give
22 detailed information on a specific command identified by the
23 --opcode=OP option (perhaps with additional information from the
24 --sa=SA option).
25
26 The name of a SCSI command depends on its peripheral device type (e.g.
27 a disk). The REPORT SUPPORTED OPERATION CODES and REPORT SUPPORTED TASK
28 MANAGEMENT FUNCTIONS commands are not supported in the MMC command set
29 for CD and DVD devices. This utility does an INQUIRY to obtain the
30 peripheral device type and prints out the vendor, product and revision
31 strings.
32
33 A similar facility to query supported operation codes previously was
34 available via the CmdDt bit in the SCSI INQUIRY command (see
35 sg_inq(8)). However that facility was made obsolete and replaced by the
36 REPORT SUPPORTED OPERATION CODES command in SPC-3 (revision 4) during
37 February 2002.
38
39 This utility supports two command line syntaxes, the preferred one is
40 shown first in the synopsis and explained in this section. A later sec‐
41 tion on the old command line syntax outlines the second group of
42 options.
43
45 Arguments to long options are mandatory for short options as well.
46
47 -a, --alpha
48 when all supported commands are being listed there is no
49 requirement for the device server (i.e. the DEVICE) to sort the
50 list of commands. When this option is given the list of sup‐
51 ported commands is sorted by name (alphabetically). When this
52 option and the --unsorted option are both _not_ given then the
53 list of supported commands is sorted numerically (first by oper‐
54 ation code and then by service action).
55
56 -c, --compact
57 some command names, especially those associated with some ser‐
58 vice actions, are getting longer. This may cause line wrap in
59 the one line per command mode on some terminals. When this
60 option is given the opcode and service action fields are com‐
61 bined into a single field with the service action, prefixed by a
62 comma shown directly after the opcode. If there is no service
63 action associated with the command, then the comma and the ser‐
64 vice action are not shown after the opcode. The CDB size field
65 is not shown when this option is given.
66
67 -h, --help
68 outputs the usage message summarizing command line options then
69 exits. Ignores DEVICE if given.
70
71 -H, --hex
72 outputs the response in ASCII hexadecimal to stdout.
73
74 -n, --no-inquiry
75 Prior to calling a SCSI REPORT SUPPORTED OPERATION CODES or a
76 REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command, a SCSI
77 INQUIRY command is performed. The reason is to determine the
78 peripheral device type (pdt) of the DEVICE as this is helpful in
79 translating operation codes to the command names. By default
80 this utility prints a summary of INQUIRY command response on
81 stdout. If this option (or the --raw option) is given then that
82 summary is not printed on stdout.
83
84 -O, --old
85 switch to older style options.
86
87 -o, --opcode=OP
88 the DEVICE will be queried for the given operation code ( i.e.
89 the OP value) which is the first byte of a SCSI command. OP is
90 decimal unless prefixed by "0x" or it has a trailing "h". OP
91 should be in the range 0 to 255 (0xff) inclusive. When this
92 option is not given then all available SCSI commands supported
93 by the DEVICE are listed.
94
95 -r, --raw
96 output the response in binary to stdout. Error messages and
97 warnings, if any, are sent to stderr.
98
99 -R, --rctd
100 set report command timeout descriptor (RCTD) bit in the cdb. The
101 response may or may not contain command timeout descriptors. If
102 available they are output. If supported there are two values: a
103 nominal command timeout and a recommended command timeout. Both
104 have units of seconds. A value of zero means that no timeout is
105 indicated and this is shown in the corresponding decoded output
106 as "-".
107
108 -q, --repd
109 set read extended parameter data (REPD) bit in the report task
110 management functions cdb. 16 bytes rather than the default 4
111 bytes expected in the response. This was added in SPC-4 (revi‐
112 sion 26).
113
114 -s, --sa=SA
115 the DEVICE will be queried for a command with the given service
116 action (i.e. the SA value). Used in conjunction with the
117 --opcode=OP option. If this option is not given, --opcode=OP is
118 given and the command in question does have a service action
119 then a value of 0 will be assumed. SA is decimal and expected to
120 be in the range 0 to 65535 (0xffff) inclusive.
121
122 -t, --tmf
123 list supported task management functions. This is done with the
124 SCSI REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command. When
125 this option is chosen the --alpha, --opcode=OP, --rctd, --sa=SA
126 and --unsorted options are ignored.
127
128 -u, --unsorted
129 when all supported commands are being listed there is no
130 requirement for the device server (i.e. the DEVICE) to sort the
131 list of commands. When this option is given the list of sup‐
132 ported commands is in the order given by the DEVICE. When this
133 option is not given the supported commands are sorted numeri‐
134 cally (first by operation code and then by service action).
135
136 -v, --verbose
137 increase level of verbosity. Can be used multiple times.
138
139 -V, --version
140 print out version string then exit.
141
143 As of SPC-4 revision 7a the recognized task management functions are:
144 abort set, abort task set, clear ACA, clear task set, I_T nexus reset,
145 logical unit reset, query task, target reset and wakeup. As of SPC-4
146 revision 26 target reset and wakeup have been made obsolete while query
147 task set and query asynchronous event notification have been added.
148
149 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
150 (sg) device. In the 2.6 series block devices (e.g. SCSI disks and DVD
151 drives) can also be specified. For example "sg_opcodes /dev/sda" will
152 work in the 2.6 series kernels.
153
155 The exit status of sg_opcodes is 0 when it is successful. Otherwise see
156 the sg3_utils(8) man page.
157
159 The options in this section were the only ones available prior to
160 sg3_utils version 1.23 . In sg3_utils version 1.23 and later these
161 older options can be selected by either setting the SG3_UTILS_OLD_OPTS
162 environment variable or using '--old' (or '-O) as the first option.
163
164 -a sort command alphabetically. Equivalent to --alpha in main
165 description.
166
167 -n don't print a summary of the SCSI INQUIRY response on stdout.
168
169 -N switch to the newer style options.
170
171 -o=OP the DEVICE will be queried for the given operation code (i.e.
172 OP) which is the first byte of a SCSI command. OP is hexadecimal
173 and expected to be in the range 0 to ff inclusive. When this
174 option is not given then all available SCSI commands supported
175 by the DEVICE are listed.
176
177 -q set the read extended parameter data (REPD) bit in report TMF
178 cdb. Equivalent to --repd in main description.
179
180 -R set the report command timeout descriptor (RCTD) bit in cdb.
181 Equivalent to --rctd in main description.
182
183 -s=SA the DEVICE will be queried for a command with the given service
184 action (i.e. SA). Used in conjunction with the -o=OP option. If
185 this option is not given, -o=OP is given and the command in
186 question does have a service action then a value of 0 will be
187 assumed. SA is hexadecimal and expected to be in the range 0 to
188 ffff inclusive.
189
190 -t list supported task management functions. Equivalent to --tmf in
191 the main description.
192
193 -u output all supported commands in the order given by DEVICE.
194 Equivalent to --unsorted in main description.
195
196 -v increase level of verbosity. Can be used multiple times.
197
198 -V print out version string then exit.
199
200 -? output usage message. Ignore all other parameters.
201
203 The examples in this page use Linux device names. For suitable device
204 names in other supported Operating Systems see the sg3_utils(8) man
205 page.
206
207 To see the information about a specific command give its operation code
208 to the '--op=' option. A command line invocation is shown first fol‐
209 lowed by a typical response:
210
211 # sg_opcodes --op=93h /dev/sdb
212
213 Opcode=0x93
214 Command_name: Write same(16)
215 Command supported [conforming to SCSI standard]
216 Usage data: 93 e2 00 00 00 00 ff ff ff ff 00 00 ff ff 00 00
217
218 The next example shows the supported task management functions:
219
220 # sg_opcodes --tmf -n /dev/sdb
221
222 Task Management Functions supported by device:
223 Abort task
224 Abort task set
225 Clear ACA
226 Clear task set
227 Logical unit reset
228 Query task
229
231 Written by Douglas Gilbert
232
234 Report bugs to <dgilbert at interlog dot com>.
235
237 Copyright © 2004-2012 Douglas Gilbert
238 This software is distributed under the GPL version 2. There is NO war‐
239 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
240 POSE.
241
243 sg_inq(sg3_utils)
244
245
246
247sg3_utils-1.35 December 2012 SG_OPCODES(8)