1SG_MODES(8)                        SG3_UTILS                       SG_MODES(8)
2
3
4

NAME

6       sg_modes - reads mode pages with SCSI MODE SENSE command
7

SYNOPSIS

9       sg_modes [--all] [--control=PC] [--dbd] [--dbout] [--examine] [--flexi‐
10       ble]    [--help]    [--hex]    [--list]    [--llbaa]     [--maxlen=LEN]
11       [--page=PG[,SPG]] [--raw] [-R] [--six] [--verbose] [--version] [DEVICE]
12
13       sg_modes [-6] [-a] [-A] [-c=PC] [-d] [-D] [-e] [-f] [-h] [-H] [-l] [-L]
14       [-m=LEN] [-p=PG[,SPG]] [-r] [-subp=SPG] [-v] [-V] [-?] [DEVICE]
15

DESCRIPTION

17       This utility sends a MODE SENSE SCSI command to the DEVICE and  outputs
18       the  response.  There is a 6 byte and 10 byte (cdb) variant of the MODE
19       SENSE command, this utility defaults to the 10 byte variant.
20
21       This utility decodes mode page headers and block descriptors  but  out‐
22       puts  the contents of each mode page in hex. It also has no facility to
23       change the mode page contents or block descriptor data. Mode page  con‐
24       tents are decoded and can be changed by the sdparm utility.
25
26       This  utility  supports two command line syntaxes, the preferred one is
27       shown first in the synopsis and explained in this section. A later sec‐
28       tion  on  the  old  command  line  syntax  outlines the second group of
29       options.
30
31       If no page is given (and --list is not selected) then --all is assumed.
32       The --all option requests all mode pages (but not subpages) in a single
33       response.
34

OPTIONS

36       Arguments to long options are mandatory for short options as well.
37
38       -a, --all
39              output all the mode pages reported by the DEVICE. This  is  what
40              the  page  code 63 (0x3f) is defined to do. When used once, mode
41              subpages are not fetched. When used twice (e.g. '-aa'), all mode
42              pages   and  subpages  are  requested  which  is  equivalent  to
43              '--page=63,255'.
44
45       -c, --control=PC
46              PC is the page control value. Up to four different  versions  of
47              each page are held by the device:
48                0 : current values (i.e. those active at present)
49                1 : changeable values
50                2 : default values (i.e. the manufacturer's settings)
51                3 : saved values
52              The  changeable  values are bit masks showing which fields could
53              be changed  with  a  MODE  SELECT.  The  saved  values  will  be
54              re-instated  the  next time the device is power cycled or reset.
55              If this option is not given then current values [0] are assumed.
56
57       -d, --dbd
58              disable block descriptors. By default, block  descriptors  (usu‐
59              ally  one  (for  disks)  or  none)  are returned in a MODE SENSE
60              response. This option sets the "disable block descriptors" (DBD)
61              bit  in  the  cdb  which  instructs the device not to return any
62              block descriptors in its response. Older devices may not support
63              this  setting  and  may  return  an "illegal request" sense key;
64              alternatively they may ignore it. Oddly the Reduced  Block  Com‐
65              mand set (RBC) requires this bit set.
66
67       -D, --dbout
68              disable  outputting  block  descriptors. Irrespective of whether
69              block descriptors are present in the response or not,  they  are
70              not output.
71
72       -e, --examine
73              examine each mode page in the range 0 through to 62 (inclusive).
74              If some response is given then print out the mode page  name  or
75              number (in hex) if the name is not known.
76
77       -f, --flexible
78              Some  devices, bridges and/or drivers attempt crude translations
79              between MODE SENSE 6 and 10 byte commands without correcting the
80              response.  This  will  cause  the response to be mis-interpreted
81              (usually with an error saying the response is  malformed).  With
82              this  option,  the  length of the response is checked, and if it
83              looks wrong, the response is then decoded as if the  other  mode
84              sense (cdb length) was sent.
85
86       -h, --help
87              print out the usage message then exit.
88
89       -H, --hex
90              The  default  action  is  to decode known mode page numbers (and
91              subpage numbers) into text. When this option is used  once,  the
92              response is output in hexadecimal to stdout. When this option is
93              used twice, mode page numbers and page control values are output
94              in hex.
95              When  this  option is used three times, the full response to the
96              MODE SENSE command is output in hex to stdout without any decod‐
97              ing.  This  form can be redirected to a file (or piped) and then
98              used 'sdparm --inhex=' to decode.
99
100       -l, --list
101              lists all common page and subpage codes and their names that are
102              found in the command set that matches the peripheral type of the
103              given DEVICE.  If no DEVICE and no --page=PG is given  then  the
104              common page and subpage codes and their names are listed for SBC
105              (e.g. a disk). If no DEVICE is given and a  --page=PG  is  given
106              then  the  common  page  and  subpage  codes and their names are
107              listed for the command set whose peripheral device type  matches
108              the  value  given  to  PG. For example 'sg_mode --list --page=1'
109              lists the command mode pages  and  subpages  for  tape  devices.
110              Additionally  if a sub_page_code is given then it is interpreted
111              as a transport identifier and command  transport  specific  mode
112              page  codes  and  their names are listed following the main mode
113              page list.  Other options are ignored.
114
115       -L, --llbaa
116              set the Long LBA Accepted (LLBAA) bit in  the  MODE  SENSE  (10)
117              cdb.  This  bit is not defined in the MODE SENSE (6) cdb so set‐
118              ting the '-L' and '--six' options is reported as an error.  When
119              set  the  DEVICE  may  respond with 16 byte block descriptors as
120              indicated by the 'LongLBA' field in the response. In most  cases
121              setting this option is not needed.
122
123       -m, --maxlen=LEN
124              The  LEN argument is the maximum response length in bytes. It is
125              the 'allocation length' field in the cdb. When not given (or LEN
126              is  zero)  then  the  allocation length field is set to 4096 for
127              MODE SENSE (10) or 252 for MODE SENSE (6). The LEN argument must
128              be  non-negative  and  no greater than 65535 for MODE SENSE (10)
129              and not greater than 255 for MODE SENSE (6).
130
131       -O, --old
132              switch to older style options.
133
134       -p, --page=PG
135              page code to fetch. The PG is assumed  to  be  a  decimal  value
136              unless  prefixed  by  '0x' or has a trailing 'h'. It should be a
137              value between 0 and 63 (inclusive). When not given and a default
138              is  required  then  a value of 63 (0x3f), which fetches all mode
139              pages, is used.
140
141       -p, --page=PG,SPG
142              page code and subpage code values to fetch. Both  arguments  are
143              assumed  to  be  decimal unless flagged as hexadecimal. The page
144              code should be between 0 and  63  inclusive.  The  subpage  code
145              should be between 0 and 255 inclusive. The default value for the
146              subpage code is 0.
147
148       -r, --raw
149              output the response in binary  to  stdout.  Error  messages  and
150              warnings,  if  any, are sent to stderr. When this option is used
151              twice (e.g. '-rr') then has the same action as '-R'
152
153       -R     output the selected mode page to stdout a byte  per  line.  Each
154              line  contains  two  hexadecimal  digits  (e.g. "3e"). Useful as
155              input (after editing) to the sg_wr_mode(8) utility.
156
157       -6, --six
158              by default this utility sends a 10 byte MODE  SENSE  command  to
159              the  DEVICE.  However some SCSI devices only support 6 byte MODE
160              SENSE commands (e.g. SCSI-2 tape drives). This parameter  forces
161              the use of 6 byte MODE SENSE commands.
162
163       -v, --verbose
164              increase level of verbosity. Can be used multiple times.
165
166       -V, --version
167              print out version string then exit.
168

NOTES

170       If  the  normal  sg_modes utility fails with "illegal command operation
171       code" then try the '--six' (or '-6') option.
172
173       This utility performs a SCSI INQUIRY command to determine  the  periph‐
174       eral  type  of the device (e.g. 0 -> Direct Access Device (disk)) prior
175       to sending a MODE SENSE command.  This  helps  in  decoding  the  block
176       descriptor and mode pages.
177
178       This  utility opens DEVICE with a read-only flag (e.g. in Unix with the
179       O_RDONLY flag).
180
181       In the 2.4 series of Linux kernels the DEVICE must be  a  SCSI  generic
182       (sg)  device.  In the 2.6 series block devices (e.g. SCSI disks and DVD
183       drives) can also be specified. For example "sg_modes -a /dev/sda"  will
184       work in the 2.6 series kernels.
185

EXIT STATUS

187       The  exit  status of sg_modes is 0 when it is successful. Otherwise see
188       the sg3_utils(8) man page.
189

OLDER COMMAND LINE OPTIONS

191       The options in this section were  the  only  ones  available  prior  to
192       sg3_utils  version  1.23  .  In  sg3_utils version 1.23 and later these
193       older options can be selected by either setting the  SG3_UTILS_OLD_OPTS
194       environment variable or using '--old' (or '-O) as the first option.
195
196       -6     by  default  this  utility sends a 10 byte MODE SENSE command to
197              the DEVICE. This parameter forces the use of 6 byte  MODE  SENSE
198              commands.  See --six in the main description.
199
200       -a     see --all in the main description.
201
202       -A     output  all the mode pages and subpages supported by the DEVICE.
203              Same as '--all --all' in the new syntax.
204
205       -c=PC  PC is the page control  value.  See  --control=PC  in  the  main
206              description.
207
208       -d     see --dbd in the main description.
209
210       -D     see --dbout in the main description.
211
212       -e     see --examine in the main description.
213
214       -f     see --flexible in the main description.
215
216       -h     The  default  action  is  to decode known mode page numbers (and
217              subpage numbers) into text. With this option mode  page  numbers
218              (and subpage numbers) are output in hexadecimal.
219
220       -H     same action as the '-h' option.
221
222       -l     see --list in the main description.
223
224       -L     see --llbaa in the main description.
225
226       -N     switch to the newer style options.
227
228       -m=LEN see --maxlen=LEN in the main description.
229
230       -p=PG  PG is page code to fetch. Should be a hexadecimal number between
231              0 and 3f inclusive (0 to 63 decimal).  The  default  value  when
232              required is 3f (fetch all mode pages).
233
234       -p=PG,SPG
235              page code and subpage code values to fetch. The page code should
236              be a hexadecimal number between 0 and 3f inclusive. The  subpage
237              code  should be a hexadecimal number between 0 and ff inclusive.
238              The default value for the subpage code is 0.
239
240       -r     output the selected mode page to stdout a byte  per  line.  Each
241              line  contains  two  hexadecimal  digits  (e.g. "3e"). Useful as
242              input (after editing) to the sg_wr_mode(8) utility.
243
244       -subp=SPG
245              sub page code to fetch. Should be a hexadecimal number between 0
246              and 0xff inclusive. The default value is 0.
247
248       -v     increase verbosity of output.
249
250       -V     print out version string then exit.
251
252       -?     output usage message then exit. Ignore all other parameters.
253

AUTHOR

255       Written by Douglas Gilbert
256

REPORTING BUGS

258       Report bugs to <dgilbert at interlog dot com>.
259
261       Copyright © 2000-2015 Douglas Gilbert
262       This  software is distributed under the GPL version 2. There is NO war‐
263       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
264       POSE.
265

SEE ALSO

267       sdparm(8),   sg_wr_mode(8),   sginfo(8),   sgmode(scsirastools),  scsi‐
268       info(net), scu(net), seatools(seagate)
269
270       All these utilities offer some facility to change mode page  (or  block
271       descriptor) parameters.
272
273
274
275sg3_utils-1.41                   January 2015                      SG_MODES(8)
Impressum