xref: /openbsd-src/sbin/scsi/scsi.8 (revision 76b1f2ebe5106c591f5eafcb9d7b05643509a2c4)
1*76b1f2ebSjsg.\"	$OpenBSD: scsi.8,v 1.36 2024/12/21 13:15:36 jsg Exp $
2ce8aa036Sderaadt.\"	$FreeBSD: scsi.8,v 1.5 1995/05/05 20:41:58 dufault Exp $
3ce8aa036Sderaadt.\"
4ce8aa036Sderaadt.\" Written By Julian ELischer
5ce8aa036Sderaadt.\" Copyright julian Elischer 1993.
6ce8aa036Sderaadt.\" Permission is granted to use or redistribute this file in any way as long
7ce8aa036Sderaadt.\" as this notice remains. Julian Elischer does not guarantee that this file
8ce8aa036Sderaadt.\" is totally correct for any given task and users of this file must
947121e47Smillert.\" accept responsibility for any damage that occurs from the application of
1047121e47Smillert.\" this file.
11ce8aa036Sderaadt.\"
12ce8aa036Sderaadt.\" (julian@tfs.com julian@dialix.oz.au)
13ce8aa036Sderaadt.\" User SCSI hooks added by Peter Dufault:
14ce8aa036Sderaadt.\"
15ce8aa036Sderaadt.\" Copyright (c) 1994 HD Associates
16ce8aa036Sderaadt.\" (contact: dufault@hda.com)
17ce8aa036Sderaadt.\" All rights reserved.
18ce8aa036Sderaadt.\"
19ce8aa036Sderaadt.\" Redistribution and use in source and binary forms, with or without
20ce8aa036Sderaadt.\" modification, are permitted provided that the following conditions
21ce8aa036Sderaadt.\" are met:
22ce8aa036Sderaadt.\" 1. Redistributions of source code must retain the above copyright
23ce8aa036Sderaadt.\"    notice, this list of conditions and the following disclaimer.
24ce8aa036Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
25ce8aa036Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
26ce8aa036Sderaadt.\"    documentation and/or other materials provided with the distribution.
27ce8aa036Sderaadt.\" 3. The name of HD Associates
28ce8aa036Sderaadt.\"    may not be used to endorse or promote products derived from this software
29ce8aa036Sderaadt.\"    without specific prior written permission.
30ce8aa036Sderaadt.\"
31ce8aa036Sderaadt.\" THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES ``AS IS'' AND
32ce8aa036Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33ce8aa036Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34ce8aa036Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL HD ASSOCIATES BE LIABLE
35ce8aa036Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36ce8aa036Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37ce8aa036Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38ce8aa036Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39ce8aa036Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40ce8aa036Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41ce8aa036Sderaadt.\" SUCH DAMAGE.
42ce8aa036Sderaadt.\"
43*76b1f2ebSjsg.Dd $Mdocdate: December 21 2024 $
44ce8aa036Sderaadt.Dt SCSI 8
4547121e47Smillert.Os
46ce8aa036Sderaadt.Sh NAME
47ce8aa036Sderaadt.Nm scsi
485eaf1a72Saaron.Nd program to assist with SCSI devices
49ce8aa036Sderaadt.Sh SYNOPSIS
507349792aSaaron.Nm scsi
515eaf1a72Saaron.Fl f Ar device
525eaf1a72Saaron.Fl d Ar debug_level
537349792aSaaron.Nm scsi
545eaf1a72Saaron.Fl f Ar device
555eaf1a72Saaron.Fl m Ar page
565eaf1a72Saaron.Op Fl e
570b9161b6Sjaredy.Op Fl P Ar pc
587349792aSaaron.Nm scsi
595eaf1a72Saaron.Fl f Ar device
605eaf1a72Saaron.Op Fl v
615eaf1a72Saaron.Op Fl s Ar seconds
625eaf1a72Saaron.Fl c Ar cmd_fmt
635eaf1a72Saaron.Op Ar arg ...
645eaf1a72Saaron.Fl o Ar count out_fmt
655eaf1a72Saaron.Op Ar arg ...
665eaf1a72Saaron.Fl i Ar count in_fmt
670b9161b6Sjaredy.Op Ar arg ...
68ce8aa036Sderaadt.Sh DESCRIPTION
69ce8aa036SderaadtThe
7058aefd4bSaaron.Nm
719615e1d4Saaronprogram is used to send commands to a SCSI device.
729615e1d4SaaronIt is also a sample usage of the user-level SCSI commands.
73de517754Saaron.Ar out_fmt
74de517754Saaroncan be
75de517754Saaron.Ql -
76de517754Saaronto read output data from stdin;
77de517754Saaron.Ar in_fmt
78de517754Saaroncan be
79de517754Saaron.Ql -
80de517754Saaronto write input data to stdout.
81ce8aa036Sderaadt.Pp
828cf461a5SaaronThe options are as follows:
835eaf1a72Saaron.Bl -tag -width Ds
840b9161b6Sjaredy.It Xo
850b9161b6Sjaredy.Fl c Ar cmd_fmt Op Ar arg ...
860b9161b6Sjaredy.Xc
870b9161b6SjaredySend a user-level SCSI command to a device.
880b9161b6SjaredyThe command format is described below and the command is sent using the
890b9161b6Sjaredy.Dv SCIOCCOMMAND
900b9161b6Sjaredy.Xr ioctl 2 ,
910b9161b6Sjaredyso the device being accessed must permit this ioctl.
920b9161b6SjaredySee
930b9161b6Sjaredy.Xr scsi 4
940b9161b6Sjaredyfor full details of which minor devices permit the ioctl.
955eaf1a72Saaron.It Fl d Ar debug_level
969615e1d4SaaronSets the SCSI kernel debug level.
979615e1d4SaaronThe kernel must have been compiled with the
980b9161b6Sjaredy.Ic SCSIDEBUG
999615e1d4Saaronoption.
1009615e1d4SaaronSee
1015eaf1a72Saaron.Pa /sys/scsi/scsi_debug.h
102ce8aa036Sderaadtto figure out what to set the kernel debug level to.
1030b9161b6Sjaredy.It Fl e
1040b9161b6SjaredyPermits edit of the fields.
1050b9161b6SjaredyIt will use the editor specified by the
1060b9161b6Sjaredy.Ev EDITOR
1070b9161b6Sjaredyenvironment variable.
1080b9161b6SjaredyTo store changes permanently, edit page control 3 using the
1090b9161b6Sjaredy.Fl P
1100b9161b6Sjaredyflag.
1110b9161b6Sjaredy.It Fl f Ar device
1120b9161b6SjaredySpecifies the
1130b9161b6Sjaredy.Ar device
1140b9161b6Sjaredythat should be opened, e.g.,
1150b9161b6Sjaredy.Pa /dev/rsd0c .
1160b9161b6Sjaredy.It Xo
1170b9161b6Sjaredy.Fl i Ar count in_fmt Op Ar arg ...
1180b9161b6Sjaredy.Xc
1190b9161b6SjaredyIndicates that this is an input command (i.e., data will be read from
1200b9161b6Sjaredythe device into the system) with
1210b9161b6Sjaredy.Ar count
1220b9161b6Sjaredybytes of data read in.
1230b9161b6SjaredyThe information is extracted according to
1240b9161b6Sjaredy.Ar in_fmt
1250b9161b6Sjaredyand is displayed on standard output.
1260b9161b6Sjaredy.Ar in_fmt
1270b9161b6Sjaredycan be specified as a hyphen
1280b9161b6Sjaredy.Pq Ql -
1290b9161b6Sjaredyto indicate that
1300b9161b6Sjaredy.Ar count
1310b9161b6Sjaredybytes of data input should be written to standard output.
1325eaf1a72Saaron.It Fl m Ar page
1339615e1d4SaaronRead a device mode page.
1349615e1d4SaaronThe file
1355eaf1a72Saaron.Pa /usr/share/misc/scsi_modes
1369615e1d4Saaronis read to discover how to interpret the mode data.
1379615e1d4SaaronThe environment variable
1385eaf1a72Saaron.Ev SCSI_MODES
1395eaf1a72Saaroncan specify a different file to use.
1400b9161b6Sjaredy.It Xo
1410b9161b6Sjaredy.Fl o Ar count out_fmt Op Ar arg ...
1420b9161b6Sjaredy.Xc
1430b9161b6SjaredyIndicates that this is an output command (i.e., data will be sent from
144ce8aa036Sderaadtthe system to the device) with
1455eaf1a72Saaron.Ar count
1469615e1d4Saaronbytes of data.
1470b9161b6SjaredyThe data is built up
1480b9161b6Sjaredyusing the provided arguments to fill in any integer variables.
1495eaf1a72Saaron.Ar out_fmt
1505eaf1a72Saaroncan be specified as a hyphen
151de517754Saaron.Pq Ql -
152ce9dbd65Sjmcto indicate that
1535eaf1a72Saaron.Ar count
1540b9161b6Sjaredybytes of data should be read from standard input.
1550b9161b6Sjaredy.It Fl P Ar pc
1560b9161b6SjaredySpecify a page control field.
1570b9161b6SjaredyThe page control fields are
1580b9161b6Sjaredy.Bd -literal -offset indent
1590b9161b6Sjaredy0 Current Values
1600b9161b6Sjaredy1 Changeable Values
1610b9161b6Sjaredy2 Default Values
1620b9161b6Sjaredy3 Saved Values
1630b9161b6Sjaredy.Ed
1640b9161b6Sjaredy.It Fl s Ar seconds
1650b9161b6SjaredySets the command timeout to
1660b9161b6Sjaredy.Ar seconds .
1670b9161b6SjaredyThe default is two seconds.
1680b9161b6Sjaredy.It Fl v
1690b9161b6SjaredyTurns on more verbose information.
1700b9161b6Sjaredy.El
1710b9161b6Sjaredy.Ss SCSI commands
1720b9161b6SjaredyThe command arguments to the
1730b9161b6Sjaredy.Fl cio
1740b9161b6Sjaredyoptions specify the command data buffer used to both send and receive
1750b9161b6Sjaredyinformation to and from the
1760b9161b6Sjaredy.Xr scsi 4
1770b9161b6Sjaredysubsystem.
1780b9161b6SjaredyTheir format is:
179ce8aa036Sderaadt.Pp
1800b9161b6Sjaredy.Dl Fl c Ar command Op Ar argument ...
1810b9161b6Sjaredy.Pp
1820b9161b6SjaredyThe commands are composed of a list of field specifiers.
1830b9161b6SjaredyThe specifiers denote the field name, the field value, and the length of
1840b9161b6Sjaredythe field.
1850b9161b6SjaredyExamples are given below.
1860b9161b6Sjaredy.Pp
1870b9161b6SjaredyWhitespace and text following a
1880b9161b6Sjaredy.Sq #
1890b9161b6Sjaredycharacter in the command string are ignored.
1900b9161b6Sjaredy.Pp
1910b9161b6SjaredyThe first part of a field specifier is the field name and is surrounded
1920b9161b6Sjaredyby curly braces
1930b9161b6Sjaredy.Pq Sq {} .
1940b9161b6SjaredyThis part is optional and may be left out.
1950b9161b6Sjaredy.Pp
1960b9161b6SjaredyThe second part is the value of the field.
1970b9161b6SjaredyThe value may be given directly or may arrange that the next argument to
1980b9161b6Sjaredythe
1990b9161b6Sjaredy.Nm
2000b9161b6Sjaredycommand be used as the value of the field.
2010b9161b6SjaredyDirect hexadecimal
2020b9161b6Sjaredy.Pq Li 0\-FF
2030b9161b6Sjaredyor decimal
2040b9161b6Sjaredy.Pq 0\-255
2050b9161b6Sjaredyvalues may be specified.
2060b9161b6SjaredyThe special value
2070b9161b6Sjaredy.Ic v
2080b9161b6Sjaredycan be used to arrange that the next integer argument be taken from the
2090b9161b6Sjaredy.Ar argument
2100b9161b6Sjaredylist.
2110b9161b6SjaredyFor retrieving output (with
2120b9161b6Sjaredy.Fl i ) ,
2130b9161b6Sjaredythis part of the field cannot be used.
2140b9161b6Sjaredy.Pp
2150b9161b6SjaredyThe third part specifies the length of the field.
2160b9161b6SjaredyThis is optional and defaults to one byte if not specified.
2170b9161b6SjaredyThe length may be specified in bits by prefixing it with
2180b9161b6Sjaredy.Ic b
2190b9161b6Sjaredyor
2200b9161b6Sjaredy.Ic t ,
2210b9161b6Sjaredyor in bytes by prefixing it with
2220b9161b6Sjaredy.Ic i .
2230b9161b6SjaredyAdditionally, character arrays can be specified by prefixing with
2240b9161b6Sjaredy.Ic c
2250b9161b6Sjaredyor, with zeroed trailing spaces, with
2260b9161b6Sjaredy.Ic z .
2270b9161b6SjaredyBits are packed together tightly and begin with the high bit.
2280b9161b6SjaredyNew bytes are started when a byte fills or an
2290b9161b6Sjaredy.Ic i
2300b9161b6Sjaredyfield is next.
2310b9161b6Sjaredy.Ic i
2320b9161b6Sjaredyfields indicate a 1\-4 byte integral value that must already be given in
2330b9161b6SjaredySCSI byte order (most significant byte first).
2340b9161b6SjaredyOtherwise, the field value specified will be swapped into SCSI byte order.
2350b9161b6Sjaredy.Pp
2360b9161b6SjaredyRetrieving data (with
2370b9161b6Sjaredy.Fl i )
2380b9161b6Sjaredyfollows similarly but without field values.
2390b9161b6SjaredyBesides field specifiers, the command can also include control operations,
2400b9161b6Sjaredywhich currently includes seeking operations used to ignore returned data.
2410b9161b6SjaredySeek operations are composed of the
2420b9161b6Sjaredy.Ic s
2430b9161b6Sjaredycharacter followed by the absolute position to skip to.
2440b9161b6SjaredyIf the position is prefixed with a
2450b9161b6Sjaredy.Ic + ,
2460b9161b6Sjaredythe position is interpreted relative to the current position.
2470b9161b6Sjaredy.\" The position can also be read from the
2480b9161b6Sjaredy.\" .Ar arg
2490b9161b6Sjaredy.\" list if
2500b9161b6Sjaredy.\" .Ic v
2510b9161b6Sjaredy.\" is specified as the seek value.
2520b9161b6Sjaredy.Pp
2530b9161b6SjaredyEntire fields can be suppressed from being returned with the
2540b9161b6Sjaredy.Ic *
2550b9161b6Sjaredymodifier prepended to the field width.
2560b9161b6Sjaredy.Pp
2570b9161b6SjaredyHere are some examples:
2580b9161b6Sjaredy.Bl -tag -width 17n
2590b9161b6Sjaredy.It Ic s8 z8 z16 z4
2600b9161b6SjaredySeek to position 8 and specify three fields of lengths 8 bytes, 16
2610b9161b6Sjaredybytes, and 4 bytes.
2620b9161b6Sjaredy.It Ic 1A 2
2630b9161b6SjaredySpecify a one-byte field with the hexadecimal value
2640b9161b6Sjaredy.Li 0x1A
2650b9161b6Sjaredyfollowed by another one-byte field with the decimal value 2.
2660b9161b6Sjaredy.It Ic v:i1
2670b9161b6SjaredySpecify a one-byte field whose value will be determined from the
2680b9161b6Sjaredynext argument in the
2690b9161b6Sjaredy.Ar argument
2700b9161b6Sjaredylist.
2710b9161b6Sjaredy.It Ic 0:7
2720b9161b6SjaredySpecify a 7-bit field with a value of zero.
2730b9161b6Sjaredy.It Ic *b3 b5
2740b9161b6SjaredySpecify a three-bit field that will be suppressed from being returned
2750b9161b6Sjaredyand a five-bit field that will be returned.
27692698011Saaron.El
2772b65e200Sjmc.Sh ENVIRONMENT
2780b9161b6Sjaredy.Bl -tag -width SU_DEBUG_TRUNCATE
2790b9161b6Sjaredy.It Ev SU_DEBUG_OUTPUT
2800b9161b6SjaredyThis
2812b65e200Sjmcvariable can be set to a file to send debugging
2822b65e200Sjmcoutput to that file.
2830b9161b6Sjaredy.It Dv SU_DEBUG_LEVEL
2840b9161b6SjaredyThis
2852b65e200Sjmcvariable can be set to a non-zero integer to increase
2862b65e200Sjmcthe level of debugging.
2872b65e200SjmcCurrently this is an on or off thing; it should
2882b65e200Sjmcperhaps use the ioctl to set the debug level in the kernel and then set
2892b65e200Sjmcit back to zero at program exit.
2900b9161b6Sjaredy.It Ev SU_DEBUG_TRUNCATE
2910b9161b6SjaredyThis
2922b65e200Sjmcvariable can be set to an integer to limit the
2932b65e200Sjmcamount of data phase output sent to the debugging file.
2940b9161b6Sjaredy.It Ev EDITOR
2950b9161b6SjaredyThis
2962b65e200Sjmcvariable determines the editor to use for the mode editor.
2970b9161b6Sjaredy.El
2980b9161b6Sjaredy.Sh FILES
2990b9161b6Sjaredy.Bl -tag -width /usr/share/misc/scsi_modes
3000b9161b6Sjaredy.It Pa /usr/share/misc/scsi_modes
3010b9161b6Sjaredy.El
302fede019aSjmc.Sh EXIT STATUS
303fede019aSjmc.Ex -std scsi
304ce8aa036Sderaadt.Sh EXAMPLES
305ce9dbd65SjmcTo verify that the device type for the disk
306ce9dbd65Sjmc.Pa /dev/rsd0c
307ce9dbd65Sjmcis 0
308ce8aa036Sderaadt(direct access device):
3090b9161b6Sjaredy.Bd -literal -offset indent
310b7aee287Skrw# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 0x64 "*b3 b5"
311ce8aa036Sderaadt0
312ce8aa036Sderaadt.Ed
313ce8aa036Sderaadt.Pp
314ce9dbd65SjmcTo do an inquiry to
315ce9dbd65Sjmc.Pa /dev/rsd2c :
3160b9161b6Sjaredy.Bd -literal -offset indent
317b7aee287Skrw# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 0x64 "s8 z8 z16 z4"
318ce8aa036SderaadtFUJITSU M2654S-512 010P
3191af69cb5Smpech.Ed
320ce8aa036Sderaadt.Pp
321cab5004fSmillertTo spin down
322cab5004fSmillert.Pa /dev/rsd2c :
323cab5004fSmillert.Bd -literal -offset indent
324cab5004fSmillert# scsi -f /dev/rsd2c -c "1b 0 0 0 0 0"
325cab5004fSmillert.Ed
326cab5004fSmillert.Pp
327ce9dbd65SjmcTo edit mode page 1 on
328ce9dbd65Sjmc.Pa /dev/rsd2c
329ce9dbd65Sjmcand store it permanently on the
330a0a3a196Smillertdrive (set AWRE and ARRE to 1 to enable bad block remapping):
3310b9161b6Sjaredy.Pp
3320b9161b6Sjaredy.Dl # scsi -f /dev/rsd2c -m 1 -e -P 3
333ce8aa036Sderaadt.Sh SEE ALSO
3340b9161b6Sjaredy.Xr ioctl 2 ,
3357acc01d2Saaron.Xr scsi 4
3362b65e200Sjmc.Sh HISTORY
3372b65e200SjmcThe
3382b65e200Sjmc.Nm
339*76b1f2ebSjsgcommand appeared in
340*76b1f2ebSjsg.Fx
341*76b1f2ebSjsgto support the new reprobe and user SCSI commands.
342ce8aa036Sderaadt.Sh BUGS
3439dbd6965Sbentley.Ic scsi\ -f /dev/rsd0c -c \(dq4 0 0 0 0 0\(dq
3440b9161b6Sjaredypermits anyone who can write to
3455eaf1a72Saaron.Pa /dev/rsd0c
3465eaf1a72Saaronto format the disk drive.
347