aboutsummaryrefslogtreecommitdiff
path: root/sg_inq.8
blob: 6e1b3b3a316291663fb7a7ea4f5b38e912e92b5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
.TH SG_INQ "8" "September 2006" "sg3_utils-1.22" SG3_UTILS
.SH NAME
sg_inq \- outputs data retrieved from the SCSI INQUIRY or
ATA IDENTIFY (PACKET) DEVICE command
.SH SYNOPSIS
.B sg_inq
[\fI-a\fR] [\fI-A\fR] [\fI-b\fR] [\fI-c\fR] [\fI-cl\fR] [\fI-d\fR]
[\fI-e\fR] [\fI-h\fR] [\fI-H\fR] [\fI-i\fR] [\fI-m\fR] [\fI-m\fR]
[\fI-o=<opcode_page>\fR] [\fI-p=<vpd_page>\fR] [\fI-P\fR] [\fI-r\fR]
[\fI-s\fR] [\fI-v\fR] [\fI-V\fR] [\fI-x\fR] [\fI-36\fR] [\fI-?\fR]
\fI<device>\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
This utility by default sends an INQUIRY SCSI command to the given
device and then outputs the response. All SCSI devices are meant
to respond to a "standard" INQUIRY command with at least a 36 byte
response (in SCSI 2 and higher). An INQUIRY is termed as "standard"
when both the EVPD and CmdDt bits are clear. 
.PP
An important "non-standard" INQUIRY page is the Device Identification
Vital Product Data (VPD) page (page number: 0x83). Since SPC-3,
support for this page has been flagged as mandatory. The '-i'
option decodes this page.
.PP
If <device> exists and the SCSI INQUIRY fails (because the SG_IO
ioctl is unknown) then an ATA IDENTIFY (PACKET) DEVICE is tried. If it
succeeds then device identification strings are output. If the "-r" option
is given then the 512 byte IDENTIFY response is output in binary. If
the "-H" (or "-h") option is given then the 512 byte response is
output in ASCII hex, grouped as 256 16 bit words, 8 words per line.
If the "-A" option is given then the SCSI INQUIRY is not performed
and the device is assumed to be ATA (or ATAPI). This allows ATAPI
transport information to be found for ATAPI cd/dvd drives; since
without this option such drives respond to a SCSI INQUIRY command.
.PP
The reference document used for interpreting an INQUIRY is T10/1713-D
Revision 6 (SPC-4, 18 July 2006) found at http://www.t10.org .
Obsolete items in the standard INQUIRY response are displayed in
brackets. The reference document for the ATA IDENTIFY (PACKET) DEVICE
command is ATA8-ACS found at http://www.t13.org .
.PP
ATA or ATAPI devices that use a SCSI to ATA Translation layer (see
SAT at www.t10.org) may support the ATA Information VPD page. This
returns the IDENTIFY (PACKET) DEVICE response amongst other things.
See the '-a' option.
.TP
-a
decodes the ATA Information Vital Product Data (VPD) page [0x89].
If '-H' is given then the whole page as ASCII hex bytes; with '-HH'
the IDENTIFY (PACKET) DEVICE response is output in ASCII hex bytes;
and without either the IDENTIFY (PACKET) DEVICE response is output
in 16 bit ASCII hex words. This page is defined in SAT (revision 5)
at www.t10.org .
.TP
-A
Assume given <device> is an ATA or ATAPI device which can receive
ATA passthrough commands from the host operating system. Skip
the SCSI INQUIRY command and use either the ATA IDENTIFY DEVICE
command (for nonpacket devices) or the ATA IDENTIFY PACKET DEVICE
command. This option is not available in the FreeBSD port.
.TP
-b
decodes the Block Limits Vital Product Data (VPD) page [0xb0].
This page is defined in SBC-2 (revision 16) at www.t10.org .
.TP
-c
set the Command Support Data (CmdDt) bit (defaults to clear(0)). Used
in conjunction with the '-o=<opcode>' option to specify the SCSI command
opcode to supply the support data for. The command support data is a mask of
the same length as the command with bits set in positions that are
modifiable. For example, '12 03 ff 00 ff 01' shows the device 
supports the EVPD and CmdDt bits [byte 1, bits 0 and 1] in an INQUIRY command.
The CmdDt bit is now obsolete. It has been replaced by the REPORT SUPPORTED
OPERATION CODES command which is accessed via the sg_opcodes utility.
.TP
-cl
lists the command data for all supported commands (followed by the command
name) by looping through all 256 opcodes. This option uses the CmdDt bit
which is now obsolete. See the sg_opcodes utility.
.TP
-d
decodes depending on context. If '-e' option is given, or any option that
implies '-e' (e.g. '-i' or '-p=80'), then this utility attempts to
decode the indicated VPD page.  Otherwise the version descriptors (if any)
are listed following a standard INQUIRY response. There are up to 8 version
descriptors in the response of a standard INQUIRY, If the version descriptor
code is recognised then the corresponding string is output.
Version descriptors are versions of standards and drafts that the device
claims to comply with (e.g. SAM, SPC, SBC, SPI, FCP, SAS etc).
.TP
-e
enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults to clear(0)).
Used in conjunction with the '-p=<vpd_page>' option to specify the VPD page
to fetch. If '-p' is not given then VPD page 0 (list supported VPD pages)
is assumed. Support for VPD page 0 and page 0x83 (device identification)
have been made mandatory in SPC-3 .
.TP
-h
outputs INQUIRY response in hex rather than trying to decode it. When
used with '-i' outputs partially decoded device identification descriptors
with the identifier itself output in hex. When selected, ATA IDENTIFY (PACKET)
DEVICE responses are output in 16 bit words if '-h' is given; they are output in
bytes when '-hh' (or '-HH') is given. The '-hh' option has a similar effect
on the ATA information VPD page decoding (i.e. when the '-a' option is given).
When used three times ('-hhh' or '-HHH'), the response is output in a form
acceptable for 'hdparm --Istdin' to decode. 
.TP
-H
same action as '-h'. For compatibility with many other sg3_utils programs
in which '-H' is for hex output.
.TP
-i
decodes the Device Identification Vital Product Data (VPD) page [0x83].
This page is made up of several "identification descriptors". If '-h' is
given then each descriptor header is decoded and the identifier itself
is output in hex. To see the whole VPD 0x83 page response in hex
use '-p=83 -h'. Since SPC-3, support for the device identification VPD
page is mandatory.
.TP
-m
decodes the Management network addresses Vital Product Data (VPD)
page [0x85]. This page is made up of several "network service descriptors".
If '-h' is given then each descriptor payload is output in hex.
.TP
-M
decodes the Mode page policy Vital Product Data (VPD) page [0x87].
This page is made up of several "mode page policy descriptors".
If '-h' is given then each descriptor payload is output in hex.
.TP
-o=<opcode_page>
used in conjunction with the '-e' or '-c' option. If neither given then
the '-e' option assumed. When the '-e' option is also given (or assumed)
then the argument to this option is the VPD page number. The argument
is interpreted as hexadecimal and is expected to be in the range 0 to ff 
inclusive. Only VPD page 0 is decoded and lists supported VPD pages and
their names (if known). To decode the mandatory device identification
page (0x83) use the '-i' option.
A now obsolete usage is when the '-c' option is given in which
case the argument to this option is assumed to be a command opcode number. 
Recent SCSI draft standards have moved this facility (see sg_opcodes).
Defaults to 0 so if '-e' is given without '-o=' then VPD page 0 is output.
.TP
-p=<vpd_page>
same action as '-o=<opcode_page>' option described above. Since the
opcode value with the CmdDt is now obsolete, the main use of this
option is to specify the VPD page number. The argument is interpreted as
hexadecimal and is expected to be in the range 0 to ff inclusive.
Defaults to 0 so if '-e' is given without '-p=' then VPD page 0 is output.
.TP
-P
decodes the Unit Path Report Vital Product Data (VPD) page [0xc0],
which is specific to selected EMC devices. To see the whole VPD 0xc0
page response in hex use '-p=c0 -h'.
.TP
-r
outputs the INQUIRY response in binary. If the SCSI INQUIRY has failed
and an ATA IDENTIFY succeeds then the 512 bytes of the IDENTIFY response
is output in binary. Overrides the various VPD decoding options. Standard
output should be redirected to a file or some other program that can
process binary data. Can be used twice (i.e. '-rr' (and '-HHH' has same
effect)) and if used with the '-A' or '-a' option yields output with the
same format as "cat /proc/ide/hd<x>/identify" so that it can then be
piped to "hdparm --Istdin".
.TP
-s
decodes the SCSI Ports Vital Product Data (VPD) page [0x88]. The response
contains information about the target (or rarely the initiator) ports
associated with the addressed device server (i.e. the target). In practice
this is a way to find all target port addresses of a dual ported disk.
If '-h' is given then each target (and/or initiator) descriptor is output
in hex. To see the whole VPD 0x88 page response in hex use '-p=88 -h'.
.TP
-v
verbose: print out cdb of issued commands prior to execution. '-vv'
and '-vvv' are also accepted yielding greater verbosity. For ATA disks
the identity response (256 16 bit words) is output when this option
is given.
.TP
-V
print out version string
.TP
-x
decodes the Extended INQUIRY data Vital Product Data (VPD) [0x86] page.
If '-h' is given then prints out VPD page in hex which is similar to
using '-p=86 -h'.
.TP
-36
only requests 36 bytes of response data for an INQUIRY. Furthermore even
if the device indicates in its response it can supply more data, a
second (longer) INQUIRY is not performed. This is a paranoid setting.
.TP
-?
output usage message and exit. Ignore all other parameters.
.PP
Some devices with weak SCSI command set implementations lock up when
they receive commands they don't understand (or even response lengths
that they don't expect). Such devices need to be treated carefully,
hence the '-36' option. Without this option this utility will issue
an initial standard INQUIRY requesting 36 bytes of response data. If
the device indicates it could have supplied more data then a second
INQUIRY is issued to fetch the longer response. That second command may
lock up faulty devices.
.PP
In the INQUIRY standard response there is a 'MultiP' flag which is set
when the device has 2 or more ports. Some vendors use the preceding
vendor specific ('VS') bit to indicate which port is being accessed by
the INQUIRY command (0 -> relative port 1 (port "a"), 1 -> relative
port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor
specific bit is shown in parentheses. SPC-3 compliant devices should
use the device identification VPD page (0x83) to show which port is
being used for access and the SCSI ports VPD page (0x88) to show all
available ports on the device.
.PP
In the 2.4 series of Linux kernels the given device must be
a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks
and ATAPI DVDs) can also be specified. For example "sg_inq /dev/sda"
will work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char"
device names may be used as well (e.g. "/dev/st0m").
.SH ATA DEVICES
There are two major types of ATA devices: non-packet devices (e.g. ATA
disks) and packet devices (ATAPI). The majority of ATAPI devices are
CD/DVD drives in which the ATAPI transport carries the MMC set (i.e.
a SCSI command set). Further, both types of ATA devices can be connected
to a host computer via a "SCSI" (or some other) transport. When an
ATA disk is controlled via a SCSI (or non-ATA) transport then two
approaches are commonly used: tunnelling (e.g. STP in Serial Attached
SCSI (SAS)) or by emulating a SCSI device (typically via a SCSI to
ATA translation layer, see SAT at www.t10.org ). Even when the
physical transport to the host computer is ATA (especially in the
case of SATA) the linux operating system may choose to put a SAT
layer in the driver "stack" (e.g. libata).
.PP
The main identifying command for any SCSI device is an INQUIRY. The
corresponding command for an ATA non-packet device is IDENTIFY DEVICE
while for an ATA packet device it is IDENTIFY PACKET DEVICE.
.PP
When this utility is invoked for an ATAPI device (e.g. a CD/DVD
drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the
device and if it responds then the response to decoded and output and
this utility exits. To see the response for an ATA IDENTIFY PACKET
DEVICE command add the '-A' option (e.g. "sg_inq -A /dev/hdc) and to
see the response in hex add the "-H" option as
well (e.g. "sg_inq -A -H /dev/hdc").
.PP
This utility doesn't decode the response to an ATA IDENTIFY (PACKET)
DEVICE command, hdparm does a good job at that. The '-rr'
option (or '-HHH') has been added for use with either the '-A' or '-a'
option to produce a format acceptable to "hdparm --Istdin". See hdparm.
.SH EXIT STATUS
The exit status of sg_inq is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
.SH AUTHOR
Written by Doug Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2001-2006 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
.B sgdiag(scsirastools), sg_opcodes(sg3_utils), sg_modes(sg3_utils),
.B sg_logs(sg3_utils), hdparm(hdparm), sg_vpd(sg_vpd)