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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
.\" $OpenBSD: scsi.8,v 1.24 2004/06/26 03:27:36 robert Exp $
.\" $FreeBSD: scsi.8,v 1.5 1995/05/05 20:41:58 dufault Exp $
.\"
.\" Written By Julian ELischer
.\" Copyright julian Elischer 1993.
.\" Permission is granted to use or redistribute this file in any way as long
.\" as this notice remains. Julian Elischer does not guarantee that this file
.\" is totally correct for any given task and users of this file must
.\" accept responsibility for any damage that occurs from the application of
.\" this file.
.\"
.\" (julian@tfs.com julian@dialix.oz.au)
.\" User SCSI hooks added by Peter Dufault:
.\"
.\" Copyright (c) 1994 HD Associates
.\" (contact: dufault@hda.com)
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. The name of HD Associates
.\" may not be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 11, 1993
.Dt SCSI 8
.Os
.Sh NAME
.Nm scsi
.Nd program to assist with SCSI devices
.Sh SYNOPSIS
.Nm scsi
.Fl f Ar device
.Fl d Ar debug_level
.Nm scsi
.Fl f Ar device
.Op Fl v
.Fl z Ar seconds
.Nm scsi
.Fl f Ar device
.Fl m Ar page
.Op Fl P Ar pc
.Op Fl e
.Nm scsi
.Fl f Ar device
.Fl p
.Op Fl b Ar bus
.Op Fl l Ar lun
.Nm scsi
.Fl f Ar device
.Fl r
.Op Fl b Ar bus
.Op Fl t Ar targ
.Op Fl l Ar lun
.Nm scsi
.Fl f Ar device
.Op Fl v
.Op Fl s Ar seconds
.Fl c Ar cmd_fmt
.Op Ar arg ...
.Fl o Ar count out_fmt
.Op Ar arg ...
.Fl i Ar count in_fmt
.Sh DESCRIPTION
The
.Nm
program is used to send commands to a SCSI device.
It is also a sample usage of the user-level SCSI commands.
.Ar out_fmt
can be
.Ql -
to read output data from stdin;
.Ar in_fmt
can be
.Ql -
to write input data to stdout.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl f Ar device
Specifies the
.Ar device
that should be opened, i.e.,
.Pa /dev/rsd0c .
.It Fl d Ar debug_level
Sets the SCSI kernel debug level.
The kernel must have been compiled with the
.Cm SCSIDEBUG
option.
See
.Pa /sys/scsi/scsi_debug.h
to figure out what to set the kernel debug level to.
.Pp
.It Fl z Ar seconds
Freezes all activity on all SCSI busses for a given number of
seconds.
If
.Fl v
is also specified, a BEL character is sent to the standard
output at the start and finish of the bus freeze.
This requires that the kernel be built with the SCSI_FREEZE kernel option.
This kernel code is not committed yet.
.Pp
.It Fl m Ar page
Read a device mode page.
The file
.Pa /usr/share/misc/scsi_modes
is read to discover how to interpret the mode data.
The environment variable
.Ev SCSI_MODES
can specify a different file to use.
.Pp
.It Fl P Ar pc
Specify a page control field.
The page control fields are
.Bd -literal -offset
0 Current Values
1 Changeable Values
2 Default Values
3 Saved Values
.Ed
.Pp
.It Fl e
Permits you to edit the fields.
It will use the editor specified by your
.Ev EDITOR
environment variable.
To store changes permanently, edit page control 3 using the
.Fl P
flag.
.Pp
.It Fl p
Can be used against the "super scsi" device
.Pa /dev/scsi/super
to probe all devices with a given SCSI
.Ar lun
on a given SCSI bus.
The
.Ar bus
can be selected with the
.Fl b
option and the default is 0.
The
.Ar lun
can be selected with the
.Fl l
option and the default is 0.
See
.Xr scsi 4
for a description of the "super scsi" device.
.Pp
.It Fl r
Can be used in
.Fx 1.1
to reprobe a specific SCSI device at a given
Bus, Target and Lun.
This is not needed in
.Fx 2.1 ,
since opening a fixed SCSI device
has the side effect of reprobing it, and probing with the bus with the
.Fl p
option should bring on line any newly found devices.
See
.Xr scsi 4
for a description of fixed SCSI devices.
.Pp
.It Fl c
Permits you to send user-level SCSI commands specified on
the command line to a
device.
The command is sent using the
.Dv SCIOCCOMMAND
ioctl, so the device you are accessing must permit this ioctl.
See
.Xr scsi 4
for full details of which minor devices permit the ioctl, and
.Xr scsi 3
for the full details on how to build up the commands and data phases
using the format arguments.
.Pp
.It Fl v
Turns on more verbose information.
.Pp
.It Fl s Ar seconds
Sets the command timeout to
.Ar seconds .
The default is two seconds.
.Pp
.It Fl c Ar cmd_fmt
Specifies the command as described in
.Xr scsi 3 .
The additional arguments provide values for any variables
specified in the command format.
.Pp
.It Fl o Ar count out_fmt arg ...
Indicates that this is a data out command (i.e., data will be sent from
the system to the device) with
.Ar count
bytes of data.
The data out is built up using the facilities described in
.Xr scsi 3
using the provided arguments to fill in any integer variables.
.Ar out_fmt
can be specified as a hyphen
.Pq Ql -
to indicate that
.Ar count
bytes of data should be read from the standard input.
.Pp
.It Fl i Ar count in_fmt arg ...
Indicates that this is a data in command (i.e., data will be read from
the device into the system) with
.Ar count
bytes of data read in.
The information is extracted according to
.Ar in_fmt
using the facilities described in
.Xr scsi 3
and displayed on the standard output.
.Ar in_fmt
can be specified as a hyphen
.Pq Ql -
to indicate that
.Ar count
bytes of data input should be written to the standard output.
.El
.Sh ENVIRONMENT
The
.Ev SU_DEBUG_OUTPUT
variable can be set to a file to send debugging
output to that file.
.Pp
The
.Ev SU_DEBUG_LEVEL
variable can be set to a non-zero integer to increase
the level of debugging.
Currently this is an on or off thing; it should
perhaps use the ioctl to set the debug level in the kernel and then set
it back to zero at program exit.
.Pp
The
.Ev SU_DEBUG_TRUNCATE
variable can be set to an integer to limit the
amount of data phase output sent to the debugging file.
.Pp
The
.Ev EDITOR
variable determines the editor to use for the mode editor.
.Sh EXAMPLES
To verify that the device type for the disk
.Pa /dev/rsd0c
is 0
(direct access device):
.Bd -literal -offset
# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 64 "*b3 b5"
0
.Ed
.Pp
To do an inquiry to
.Pa /dev/rsd2c :
.Bd -literal -offset
# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 64 "s8 z8 z16 z4"
FUJITSU M2654S-512 010P
.Ed
.Pp
To edit mode page 1 on
.Pa /dev/rsd2c
and store it permanently on the
drive (set AWRE and ARRE to 1 to enable bad block remapping):
.Bd -literal -offset
# scsi -f /dev/rsd2c -m 1 -e -P 3
.Ed
.Sh SEE ALSO
.Xr scsi 4
.Sh HISTORY
The
.Nm
command appeared in 386BSD 0.1.2.4/FreeBSD to support the new reprobe
and user SCSI commands.
.Sh BUGS
Some devices respond to an inquiry for all LUNS.
This will cause them
to come on line to 8 times during reprobe to different logical units.
"scsi -f /dev/rsd0c -c "4 0 0 0 0 0" permits anyone who can write to
.Pa /dev/rsd0c
to format the disk drive.
|