OpenBSD manual page server

Manual Page Search Parameters

SCSI(8) System Manager's Manual SCSI(8)

scsiprogram to assist with SCSI devices

scsi -f device -d debug_level

scsi -f device -m page [-e] [-P pc]

scsi -f device [-v] [-s seconds] -c cmd_fmt [arg ...] -o count out_fmt [arg ...] -i count in_fmt [arg ...]

The scsi program is used to send commands to a SCSI device. It is also a sample usage of the user-level SCSI commands. out_fmt can be ‘-’ to read output data from stdin; in_fmt can be ‘-’ to write input data to stdout.

The options are as follows:

cmd_fmt [arg ...]
Send a user-level SCSI command to a device. The command format is described below and the command is sent using the SCIOCCOMMAND ioctl(2), so the device being accessed must permit this ioctl. See scsi(4) for full details of which minor devices permit the ioctl.
debug_level
Sets the SCSI kernel debug level. The kernel must have been compiled with the SCSIDEBUG option. See /sys/scsi/scsi_debug.h to figure out what to set the kernel debug level to.
Permits edit of the fields. It will use the editor specified by the EDITOR environment variable. To store changes permanently, edit page control 3 using the -P flag.
device
Specifies the device that should be opened, e.g., /dev/rsd0c.
count in_fmt [arg ...]
Indicates that this is an input command (i.e., data will be read from the device into the system) with count bytes of data read in. The information is extracted according to in_fmt and is displayed on standard output. in_fmt can be specified as a hyphen (‘-’) to indicate that count bytes of data input should be written to standard output.
page
Read a device mode page. The file /usr/share/misc/scsi_modes is read to discover how to interpret the mode data. The environment variable SCSI_MODES can specify a different file to use.
count out_fmt [arg ...]
Indicates that this is an output command (i.e., data will be sent from the system to the device) with count bytes of data. The data is built up using the provided arguments to fill in any integer variables. out_fmt can be specified as a hyphen (‘-’) to indicate that count bytes of data should be read from standard input.
pc
Specify a page control field. The page control fields are
0 Current Values
1 Changeable Values
2 Default Values
3 Saved Values
seconds
Sets the command timeout to seconds. The default is two seconds.
Turns on more verbose information.

The command arguments to the -cio options specify the command data buffer used to both send and receive information to and from the scsi(4) subsystem. Their format is:

-c command [argument ...]

The commands are composed of a list of field specifiers. The specifiers denote the field name, the field value, and the length of the field. Examples are given below.

Whitespace and text following a ‘#’ character in the command string are ignored.

The first part of a field specifier is the field name and is surrounded by curly braces (‘{}’). This part is optional and may be left out.

The second part is the value of the field. The value may be given directly or may arrange that the next argument to the scsi command be used as the value of the field. Direct hexadecimal (0-FF) or decimal (0-255) values may be specified. The special value v can be used to arrange that the next integer argument be taken from the argument list. For retrieving output (with -i), this part of the field cannot be used.

The third part specifies the length of the field. This is optional and defaults to one byte if not specified. The length may be specified in bits by prefixing it with b or t, or in bytes by prefixing it with i. Additionally, character arrays can be specified by prefixing with c or, with zeroed trailing spaces, with z. Bits are packed together tightly and begin with the high bit. New bytes are started when a byte fills or an i field is next. i fields indicate a 1-4 byte integral value that must already be given in SCSI byte order (most significant byte first). Otherwise, the field value specified will be swapped into SCSI byte order.

Retrieving data (with -i) follows similarly but without field values. Besides field specifiers, the command can also include control operations, which currently includes seeking operations used to ignore returned data. Seek operations are composed of the s character followed by the absolute position to skip to. If the position is prefixed with a +, the position is interpreted relative to the current position.

Entire fields can be suppressed from being returned with the * modifier prepended to the field width.

Here are some examples:

Seek to position 8 and specify three fields of lengths 8 bytes, 16 bytes, and 4 bytes.
Specify a one-byte field with the hexadecimal value 0x1A followed by another one-byte field with the decimal value 2.
Specify a one-byte field whose value will be determined from the next argument in the argument list.
Specify a 7-bit field with a value of zero.
Specify a three-bit field that will be suppressed from being returned and a five-bit field that will be returned.

This variable can be set to a file to send debugging output to that file.
This 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.
This variable can be set to an integer to limit the amount of data phase output sent to the debugging file.
This variable determines the editor to use for the mode editor.

/usr/share/misc/scsi_modes
 

The scsi utility exits 0 on success, and >0 if an error occurs.

To verify that the device type for the disk /dev/rsd0c is 0 (direct access device):

# scsi -f /dev/rsd0c -c "12 0 0 0 64 0" -i 0x64 "*b3 b5"
0

To do an inquiry to /dev/rsd2c:

# scsi -f /dev/rsd2c -c "12 0 0 0 64 0" -i 0x64 "s8 z8 z16 z4"
FUJITSU M2654S-512 010P

To spin down /dev/rsd2c:

# scsi -f /dev/rsd2c -c "1b 0 0 0 0 0"

To edit mode page 1 on /dev/rsd2c and store it permanently on the drive (set AWRE and ARRE to 1 to enable bad block remapping):

# scsi -f /dev/rsd2c -m 1 -e -P 3

ioctl(2), scsi(4)

The scsi command appeared in 386BSD 0.1.2.4/FreeBSD to support the new reprobe and user SCSI commands.

scsi -f /dev/rsd0c -c "4 0 0 0 0 0" permits anyone who can write to /dev/rsd0c to format the disk drive.

February 28, 2015 OpenBSD-7.0