SG_MODES(8)

NAME
sg_modes - reads SCSI MODE SENSE pages

SYNOPSIS
sg_modes [-a] [-A] [-c=<page_control>] [-d] [-h] [-l] [-p=<page_code>] [-p=<page_code>,<sub_page_code>] [-r] [-subp=<sub_page_code>] [-v] [-V] [-6] [-?] [<scsi_device>]

DESCRIPTION

This utility sends a MODE SENSE SCSI command (the 10 byte variant by default) to the given device and then outputs the response. There is no facility to change the page or descriptor data with this utility. If no page is given (and '-l' is not selected) then '-a' is assumed.

-a  output all the mode pages supported by the given device.

-A  output all the mode pages and subpages supported by the device.

-c=page_control
    up to four different versions of each page are held by the device: the current values [0] (i.e. those active at the moment), the changeable values [1] (bit mask showing which sections could be changed with a MODE SELECT), default values [2] (the manufacturer's settings) and saved values [3] (the values that will be re-instated the next time the device is power cycled). If this option is not given then current values [0] are assumed.

-d  disable block descriptors. By default MODE SENSE returns in its response block descriptors and this parameter can be used to suppress them.

-h  currently only suppresses the printing out of known page code descriptions

-l  lists all common page and subpage codes and their names that are found in the command set that matches the peripheral type of the given device. If no device and no page_code is given then the common page and subpage codes and their names for the disk command set are listed. If no device is given and a page_code is given then the common page and subpage codes and their names for the command set whose peripheral device type matches the value given to page_code are listed. For example 'sg_mode -l -p=1' lists the command mode pages and subpages for tape devices. Additionally if a sub_page_code is given then it is interpreted as a transport identifier and command transport specific mode page codes and their names are listed following the main mode page list. Other options are ignored.

-p=<page_code>
    page code to fetch. Should be a hexadecimal number between 0 and 3f inclusive (0 to 63 decimal). The default value is 0.

-p=<page_code>,<sub_page_code>
    page code and subpage code values to fetch. The page code should be a hexadecimal number between 0 and 3f inclusive. The subpage code should be a hexadecimal number between 0 and ff inclusive. The default value of both is 0.

-r  output the selected mode page to stdout a byte per line. Each line contains two hexadecimal digits (e.g. "0a"). Useful as input (after editing) to the sg_wr_mode utility.

-subp=<sub_page_code>
    sub page code to fetch. Should be a hexadecimal number between 0 and 0xff inclusive. The default value is 0.

-v  verbose: output cdbs in hex before executing them.

-V  print out version string

-6  by default this utility sends out a 10 byte MODE SENSE command. However some SCSI devices only support 6 byte MODE SENSE commands (e.g. SCSI-2 tape drives). This parameter forces the use of 6 byte MODE SENSE commands.

-?  output usage message. Ignore all other parameters.

If the normal sg_modes utility fails with "illegal command operation code" then try the "-6" parameter. To alter page settings see the program listed in the "See Also" section below.

Mode pages cannot be modified with this utility. Mode pages (and subpages) can be modified with the sg_wr_mode and sginfo utilities in the sg3_utils package. Some other utilities for displaying and modifying mode pages are listed in the "see also" section below.

This utility performs a SCSI INQUIRY command to determine the peripheral type of the device (e.g. 0 -> Direct Access Device (disk)) prior to sending a MODE SENSE command. This helps in decoding the block descriptor and mode pages.

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 SCSI DVDs) can also be specified. For example "sg_modes -a /dev/sda" will work in the 2.6 series kernels.

AUTHOR
Written by Doug Gilbert

REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

COPYRIGHT
Copyright © 2000-2004 Douglas Gilbert
This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SEE ALSO
sg_wr_mode(sg3_utils), sginfo(sg3_utils), sgmode(scsirastools), scsiinfo(see net), scu(see net), seatools(see seagate)

All these utilities offer some facility to change mode page (or block descriptor) parameters.