xref: /openbsd/sbin/scsi/scsi.8 (revision db2509f7)
1.\"	$OpenBSD: scsi.8,v 1.22 2003/04/30 11:58:49 jmc Exp $
2.\"	$FreeBSD: scsi.8,v 1.5 1995/05/05 20:41:58 dufault Exp $
3.\"
4.\" Written By Julian ELischer
5.\" Copyright julian Elischer 1993.
6.\" Permission is granted to use or redistribute this file in any way as long
7.\" as this notice remains. Julian Elischer does not guarantee that this file
8.\" is totally correct for any given task and users of this file must
9.\" accept responsibility for any damage that occurs from the application of
10.\" this file.
11.\"
12.\" (julian@tfs.com julian@dialix.oz.au)
13.\" User SCSI hooks added by Peter Dufault:
14.\"
15.\" Copyright (c) 1994 HD Associates
16.\" (contact: dufault@hda.com)
17.\" All rights reserved.
18.\"
19.\" Redistribution and use in source and binary forms, with or without
20.\" modification, are permitted provided that the following conditions
21.\" are met:
22.\" 1. Redistributions of source code must retain the above copyright
23.\"    notice, this list of conditions and the following disclaimer.
24.\" 2. Redistributions in binary form must reproduce the above copyright
25.\"    notice, this list of conditions and the following disclaimer in the
26.\"    documentation and/or other materials provided with the distribution.
27.\" 3. The name of HD Associates
28.\"    may not be used to endorse or promote products derived from this software
29.\"    without specific prior written permission.
30.\"
31.\" THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES ``AS IS'' AND
32.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34.\" ARE DISCLAIMED.  IN NO EVENT SHALL HD ASSOCIATES BE LIABLE
35.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41.\" SUCH DAMAGE.
42.\"
43.Dd October 11, 1993
44.Dt SCSI 8
45.Os
46.Sh NAME
47.Nm scsi
48.Nd program to assist with SCSI devices
49.Sh SYNOPSIS
50.Nm scsi
51.Fl f Ar device
52.Fl d Ar debug_level
53.Nm scsi
54.Fl f Ar device
55.Op Fl v
56.Fl z Ar seconds
57.Nm scsi
58.Fl f Ar device
59.Fl m Ar page
60.Op Fl P Ar pc
61.Op Fl e
62.Nm scsi
63.Fl f Ar device
64.Fl p
65.Op Fl b Ar bus
66.Op Fl l Ar lun
67.Nm scsi
68.Fl f Ar device
69.Fl r
70.Op Fl b Ar bus
71.Op Fl t Ar targ
72.Op Fl l Ar lun
73.Nm scsi
74.Fl f Ar device
75.Op Fl v
76.Op Fl s Ar seconds
77.Fl c Ar cmd_fmt
78.Op Ar arg ...
79.Fl o Ar count out_fmt
80.Op Ar arg ...
81.Fl i Ar count in_fmt
82.Sh DESCRIPTION
83The
84.Nm
85program is used to send commands to a SCSI device.
86It is also a sample usage of the user-level SCSI commands.
87.Ar out_fmt
88can be
89.Ql -
90to read output data from stdin;
91.Ar in_fmt
92can be
93.Ql -
94to write input data to stdout.
95.Pp
96The options are as follows:
97.Bl -tag -width Ds
98.It Fl f Ar device
99Specifies the
100.Ar device
101that should be opened, i.e.,
102.Pa /dev/rsd0c .
103.It Fl d Ar debug_level
104Sets the SCSI kernel debug level.
105The kernel must have been compiled with the
106.Cm SCSIDEBUG
107option.
108See
109.Pa /sys/scsi/scsi_debug.h
110to figure out what to set the kernel debug level to.
111.Pp
112.It Fl z Ar seconds
113Freezes all activity on all SCSI busses for a given number of
114seconds.
115If
116.Fl v
117is also specified, a BEL character is sent to the standard
118output at the start and finish of the bus freeze.
119This requires that the kernel be built with the SCSI_FREEZE kernel option.
120This kernel code is not committed yet.
121.Pp
122.It Fl m Ar page
123Read a device mode page.
124The file
125.Pa /usr/share/misc/scsi_modes
126is read to discover how to interpret the mode data.
127The environment variable
128.Ev SCSI_MODES
129can specify a different file to use.
130.Pp
131.It Fl P Ar pc
132Specify a page control field.
133The page control fields are
134.Bd -literal -offset
1350 Current Values
1361 Changeable Values
1372 Default Values
1383 Saved Values
139.Ed
140.Pp
141.It Fl e
142Permits you to edit the fields.
143It will use the editor specified by your
144.Ev EDITOR
145environment variable.
146To store changes permanently, edit page control 3 using the
147.Fl P
148flag.
149.Pp
150.It Fl p
151Can be used against the "super scsi" device
152.Pa /dev/scsi/super
153to probe all devices with a given SCSI
154.Ar lun
155on a given SCSI bus.
156The
157.Ar bus
158can be selected with the
159.Fl b
160option and the default is 0.
161The
162.Ar lun
163can be selected with the
164.Fl l
165option and the default is 0.
166See
167.Xr scsi 4
168for a description of the "super scsi" device.
169.Pp
170.It Fl r
171Can be used in
172.Fx 1.1
173to reprobe a specific SCSI device at a given
174Bus, Target and Lun.
175This is not needed in
176.Fx 2.1 ,
177since opening a fixed SCSI device
178has the side effect of reprobing it, and probing with the bus with the
179.Fl p
180option should bring on line any newly found devices.
181See
182.Xr scsi 4
183for a description of fixed SCSI devices.
184.Pp
185.It Fl c
186Permits you to send user-level SCSI commands specified on
187the command line to a
188device.
189The command is sent using the
190.Dv SCIOCCOMMAND
191ioctl, so the device you are accessing must permit this ioctl.
192See
193.Xr scsi 4
194for full details of which minor devices permit the ioctl, and
195.Xr scsi 3
196for the full details on how to build up the commands and data phases
197using the format arguments.
198.Pp
199.It Fl v
200Turns on more verbose information.
201.Pp
202.It Fl s Ar seconds
203Sets the command timeout to
204.Ar seconds .
205The default is two seconds.
206.Pp
207.It Fl c Ar cmd_fmt
208Specifies the command as described in
209.Xr scsi 3 .
210The additional arguments provide values for any variables
211specified in the command format.
212.Pp
213.It Fl o Ar count out_fmt arg ...
214Indicates that this is a data out command (i.e., data will be sent from
215the system to the device) with
216.Ar count
217bytes of data.
218The data out is built up using the facilities described in
219.Xr scsi 3
220using the provided arguments to fill in any integer variables.
221.Ar out_fmt
222can be specified as a hyphen
223.Pq Ql -
224to indicate that
225.Ar count
226bytes of data should be read from the standard input.
227.Pp
228.It Fl i Ar count in_fmt arg ...
229Indicates that this is a data in command (i.e., data will be read from
230the device into the system) with
231.Ar count
232bytes of data read in.
233The information is extracted according to
234.Ar in_fmt
235using the facilities described in
236.Xr scsi 3
237and displayed on the standard output.
238.Ar in_fmt
239can be specified as a hyphen
240.Pq Ql -
241to indicate that
242.Ar count
243bytes of data input should be written to the standard output.
244.El
245.Sh EXAMPLES
246To verify that the device type for the disk
247.Pa /dev/rsd0c
248is 0
249(direct access device):
250.Bd -literal -offset
251# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 64 "*b3 b5"
2520
253.Ed
254.Pp
255To do an inquiry to
256.Pa /dev/rsd2c :
257.Bd -literal -offset
258# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 64 "s8 z8 z16 z4"
259FUJITSU M2654S-512 010P
260.Ed
261.Pp
262To edit mode page 1 on
263.Pa /dev/rsd2c
264and store it permanently on the
265drive (set AWRE and ARRE to 1 to enable bad block remapping):
266.Bd -literal -offset
267# scsi -f /dev/rsd2c -m 1 -e -P 3
268.Ed
269.Sh ENVIRONMENT
270The
271.Ev SU_DEBUG_OUTPUT
272variable can be set to a file to send debugging
273output to that file.
274.Pp
275The
276.Ev SU_DEBUG_LEVEL
277variable can be set to a non-zero integer to increase
278the level of debugging.
279Currently this is an on or off thing; it should
280perhaps use the ioctl to set the debug level in the kernel and then set
281it back to zero at program exit.
282.Pp
283The
284.Ev SU_DEBUG_TRUNCATE
285variable can be set to an integer to limit the
286amount of data phase output sent to the debugging file.
287.Pp
288The
289.Ev EDITOR
290variable determines the editor to use for the mode editor.
291.Sh SEE ALSO
292.Xr scsi 3 ,
293.Xr scsi 4
294.Sh BUGS
295Some devices respond to an inquiry for all LUNS.
296This will cause them
297to come on line to 8 times during reprobe to different logical units.
298"scsi -f /dev/rsd0c -c "4 0 0 0 0 0" permits anyone who can write to
299.Pa /dev/rsd0c
300to format the disk drive.
301.Sh HISTORY
302The
303.Nm
304command appeared in 386BSD 0.1.2.4/FreeBSD to support the new reprobe
305and user SCSI commands.
306