Deleted Added
sdiff udiff text old ( 199079 ) new ( 199821 )
full compact
1.\"
2.\" Copyright (c) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Kenneth D. Merry.
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. The name of the author may not be used to endorse or promote products
14.\" derived from this software without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\" $FreeBSD: head/sbin/camcontrol/camcontrol.8 199079 2009-11-09 11:39:51Z mav $
29.\"
30.Dd November 9, 2009
31.Dt CAMCONTROL 8
32.Os
33.Sh NAME
34.Nm camcontrol
35.Nd CAM control program
36.Sh SYNOPSIS
37.Nm
38.Aq Ar command
39.Op device id
40.Op generic args
41.Op command args
42.Nm
43.Ic devlist
44.Op Fl v
45.Nm
46.Ic periphlist
47.Op device id
48.Op Fl n Ar dev_name
49.Op Fl u Ar unit_number
50.Nm
51.Ic tur
52.Op device id
53.Op generic args
54.Nm
55.Ic inquiry
56.Op device id
57.Op generic args
58.Op Fl D
59.Op Fl S
60.Op Fl R
61.Nm
62.Ic identify
63.Op device id
64.Op generic args
65.Nm
66.Ic reportluns
67.Op device id
68.Op generic args
69.Op Fl c
70.Op Fl l
71.Op Fl r Ar reporttype
72.Nm
73.Ic readcap
74.Op device id
75.Op generic args
76.Op Fl b
77.Op Fl h
78.Op Fl H
79.Op Fl N
80.Op Fl q
81.Op Fl s
82.Nm
83.Ic start
84.Op device id
85.Op generic args
86.Nm
87.Ic stop
88.Op device id
89.Op generic args
90.Nm
91.Ic load
92.Op device id
93.Op generic args
94.Nm
95.Ic eject
96.Op device id
97.Op generic args
98.Nm
99.Ic rescan
100.Aq all | bus Ns Op :target:lun
101.Nm
102.Ic reset
103.Aq all | bus Ns Op :target:lun
104.Nm
105.Ic defects
106.Op device id
107.Op generic args
108.Aq Fl f Ar format
109.Op Fl P
110.Op Fl G
111.Nm
112.Ic modepage
113.Op device id
114.Op generic args
115.Aq Fl m Ar page | Fl l
116.Op Fl P Ar pgctl
117.Op Fl b | Fl e
118.Op Fl d
119.Nm
120.Ic cmd
121.Op device id
122.Op generic args
123.Aq Fl a Ar cmd Op args
124.Aq Fl c Ar cmd Op args
125.Op Fl i Ar len Ar fmt
126.Bk -words
127.Op Fl o Ar len Ar fmt Op args
128.Op Fl r Ar fmt
129.Ek
130.Nm
131.Ic debug
132.Op Fl I
133.Op Fl P
134.Op Fl T
135.Op Fl S
136.Op Fl X
137.Op Fl c
138.Aq all|off|bus Ns Op :target Ns Op :lun
139.Nm
140.Ic tags
141.Op device id
142.Op generic args
143.Op Fl N Ar tags
144.Op Fl q
145.Op Fl v
146.Nm
147.Ic negotiate
148.Op device id
149.Op generic args
150.Op Fl c
151.Op Fl D Ar enable|disable
152.Op Fl O Ar offset
153.Op Fl q
154.Op Fl R Ar syncrate
155.Op Fl T Ar enable|disable
156.Op Fl U
157.Op Fl W Ar bus_width
158.Op Fl v
159.Nm
160.Ic format
161.Op device id
162.Op generic args
163.Op Fl q
164.Op Fl r
165.Op Fl w
166.Op Fl y
167.Nm
168.Ic idle
169.Op device id
170.Op generic args
171.Op Fl t Ar time
172.Nm
173.Ic standby
174.Op device id
175.Op generic args
176.Op Fl t Ar time
177.Nm
178.Ic sleep
179.Op device id
180.Op generic args
181.Nm
182.Ic help
183.Sh DESCRIPTION
184The
185.Nm
186utility is designed to provide a way for users to access and control the
187.Fx
188CAM subsystem.
189.Pp
190The
191.Nm
192utility
193can cause a loss of data and/or system crashes if used improperly.
194Even
195expert users are encouraged to exercise caution when using this command.
196Novice users should stay away from this utility.
197.Pp
198The
199.Nm
200utility has a number of primary functions, many of which support an optional
201device identifier.
202A device identifier can take one of three forms:
203.Bl -tag -width 14n
204.It deviceUNIT
205Specify a device name and unit number combination, like "da5" or "cd3".
206Note that character device node names (e.g.\& /dev/da0) are
207.Em not
208allowed here.
209.It bus:target
210Specify a bus number and target id.
211The bus number can be determined from
212the output of
213.Dq camcontrol devlist .
214The lun defaults to 0.
215.It bus:target:lun
216Specify the bus, target and lun for a device.
217(e.g.\& 1:2:0)
218.El
219.Pp
220The device identifier, if it is specified,
221.Em must
222come immediately after the function name, and before any generic or
223function-specific arguments.
224Note that the
225.Fl n
226and
227.Fl u
228arguments described below will override any device name or unit number
229specified beforehand.
230The
231.Fl n
232and
233.Fl u
234arguments will
235.Em not
236override a specified bus:target or bus:target:lun, however.
237.Pp
238Most of the
239.Nm
240primary functions support these generic arguments:
241.Bl -tag -width 14n
242.It Fl C Ar count
243SCSI command retry count.
244In order for this to work, error recovery
245.Pq Fl E
246must be turned on.
247.It Fl E
248Instruct the kernel to perform generic SCSI error recovery for the given
249command.
250This is needed in order for the retry count
251.Pq Fl C
252to be honored.
253Other than retrying commands, the generic error recovery in
254the code will generally attempt to spin up drives that are not spinning.
255It may take some other actions, depending upon the sense code returned from
256the command.
257.It Fl n Ar dev_name
258Specify the device type to operate on, e.g.\& "da", "cd".
259.It Fl t Ar timeout
260SCSI command timeout in seconds.
261This overrides the default timeout for
262any given command.
263.It Fl u Ar unit_number
264Specify the device unit number, e.g.\& "1", "5".
265.It Fl v
266Be verbose, print out sense information for failed SCSI commands.
267.El
268.Pp
269Primary command functions:
270.Bl -tag -width periphlist
271.It Ic devlist
272List all physical devices (logical units) attached to the CAM subsystem.
273This also includes a list of peripheral drivers attached to each device.
274With the
275.Fl v
276argument, SCSI bus number, adapter name and unit numbers are printed as
277well.
278.It Ic periphlist
279List all peripheral drivers attached to a given physical device (logical
280unit).
281.It Ic tur
282Send the SCSI test unit ready (0x00) command to the given device.
283The
284.Nm
285utility will report whether the device is ready or not.
286.It Ic inquiry
287Send a SCSI inquiry command (0x12) to a device.
288By default,
289.Nm
290will print out the standard inquiry data, device serial number, and
291transfer rate information.
292The user can specify that only certain types of
293inquiry data be printed:
294.Bl -tag -width 4n
295.It Fl D
296Get the standard inquiry data.
297.It Fl S
298Print out the serial number.
299If this flag is the only one specified,
300.Nm
301will not print out "Serial Number" before the value returned by the drive.
302This is to aid in script writing.
303.It Fl R
304Print out transfer rate information.
305.El
306.It Ic identify
307Send a ATA identify command (0xec) to a device.
308.It Ic reportluns
309Send the SCSI REPORT LUNS (0xA0) command to the given device.
310By default,
311.Nm
312will print out the list of logical units (LUNs) supported by the target device.
313There are a couple of options to modify the output:
314.Bl -tag -width 14n
315.It Fl c
316Just print out a count of LUNs, not the actual LUN numbers.
317.It Fl l
318Just print out the LUNs, and don't print out the count.
319.It Fl r Ar reporttype
320Specify the type of report to request from the target:
321.Bl -tag -width 012345678
322.It default
323Return the default report.
324This is the
325.Nm
326default.
327Most targets will support this report if they support the REPORT LUNS
328command.
329.It wellknown
330Return only well known LUNs.
331.It all
332Return all available LUNs.
333.El
334.El
335.Pp
336.Nm
337will try to print out LUN numbers in a reasonable format.
338It can understand the peripheral, flat, LUN and extended LUN formats.
339.It Ic readcap
340Send the SCSI READ CAPACITY command to the given device and display
341the results.
342If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
343action will be sent to obtain the full size of the device.
344By default,
345.Nm
346will print out the last logical block of the device, and the blocksize of
347the device in bytes.
348To modify the output format, use the following options:
349.Bl -tag -width 5n
350.It Fl b
351Just print out the blocksize, not the last block or device size.
352This cannot be used with
353.Fl N
354or
355.Fl s .
356.It Fl h
357Print out the device size in human readable (base 2, 1K == 1024) format.
358This implies
359.Fl N
360and cannot be used with
361.Fl q
362or
363.Fl b .
364.It Fl H
365Print out the device size in human readable (base 10, 1K == 1000) format.
366.It Fl N
367Print out the number of blocks in the device instead of the last logical
368block.
369.It Fl q
370Quiet, print out the numbers only (separated by a comma if
371.Fl b
372or
373.Fl s
374are not specified).
375.It Fl s
376Print out the last logical block or the size of the device only, and omit
377the blocksize.
378.El
379.It Ic start
380Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
381start bit set.
382.It Ic stop
383Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
384start bit cleared.
385.It Ic load
386Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
387start bit set and the load/eject bit set.
388.It Ic eject
389Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
390start bit cleared and the load/eject bit set.
391.It Ic rescan
392Tell the kernel to scan all busses in the system (with the
393.Ar all
394argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
395(XPT_SCAN_LUN) for new devices or devices that have gone away.
396The user
397may specify a scan of all busses, a single bus, or a lun.
398Scanning all luns
399on a target is not supported.
400.It Ic reset
401Tell the kernel to reset all busses in the system (with the
402.Ar all
403argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
404reset for that bus, or to reset the given bus:target:lun
405(XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
406connecting to that device.
407Note that this can have a destructive impact
408on the system.
409.It Ic defects
410Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
411print out any combination of: the total number of defects, the primary
412defect list (PLIST), and the grown defect list (GLIST).
413.Bl -tag -width 11n
414.It Fl f Ar format
415The three format options are:
416.Em block ,
417to print out the list as logical blocks,
418.Em bfi ,
419to print out the list in bytes from index format, and
420.Em phys ,
421to print out the list in physical sector format.
422The format argument is
423required.
424Most drives support the physical sector format.
425Some drives
426support the logical block format.
427Many drives, if they do not support the
428requested format, return the data in an alternate format, along with sense
429information indicating that the requested data format is not supported.
430The
431.Nm
432utility
433attempts to detect this, and print out whatever format the drive returns.
434If the drive uses a non-standard sense code to report that it does not
435support the requested format,
436.Nm
437will probably see the error as a failure to complete the request.
438.It Fl G
439Print out the grown defect list.
440This is a list of bad blocks that have
441been remapped since the disk left the factory.
442.It Fl P
443Print out the primary defect list.
444.El
445.Pp
446If neither
447.Fl P
448nor
449.Fl G
450is specified,
451.Nm
452will print out the number of defects given in the READ DEFECT DATA header
453returned from the drive.
454.It Ic modepage
455Allows the user to display and optionally edit a SCSI mode page.
456The mode
457page formats are located in
458.Pa /usr/share/misc/scsi_modes .
459This can be overridden by specifying a different file in the
460.Ev SCSI_MODES
461environment variable.
462The
463.Ic modepage
464command takes several arguments:
465.Bl -tag -width 12n
466.It Fl d
467Disable block descriptors for mode sense.
468.It Fl b
469Displays mode page data in binary format.
470.It Fl e
471This flag allows the user to edit values in the mode page.
472The user may
473either edit mode page values with the text editor pointed to by his
474.Ev EDITOR
475environment variable, or supply mode page values via standard input, using
476the same format that
477.Nm
478uses to display mode page values.
479The editor will be invoked if
480.Nm
481detects that standard input is terminal.
482.It Fl l
483Lists all available mode pages.
484.It Fl m Ar mode_page
485This specifies the number of the mode page the user would like to view
486and/or edit.
487This argument is mandatory unless
488.Fl l
489is specified.
490.It Fl P Ar pgctl
491This allows the user to specify the page control field.
492Possible values are:
493.Bl -tag -width xxx -compact
494.It 0
495Current values
496.It 1
497Changeable values
498.It 2
499Default values
500.It 3
501Saved values
502.El
503.El
504.It Ic cmd
505Allows the user to send an arbitrary ATA or SCSI CDB to any device.
506The
507.Ic cmd
508function requires the
509.Fl c
510argument to specify SCSI CDB or the
511.Fl a
512argument to specify ATA Command Block registers values.
513Other arguments are optional, depending on
514the command type.
515The command and data specification syntax is documented
516in
517.Xr cam_cdbparse 3 .
518NOTE: If the CDB specified causes data to be transfered to or from the
519SCSI device in question, you MUST specify either
520.Fl i
521or
522.Fl o .
523.Bl -tag -width 17n
524.It Fl a Ar cmd Op args
525This specifies the content of 12 ATA Command Block registers (command,
526features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp.
527lba_high_exp, features_exp, sector_count, sector_count_exp).
528.It Fl c Ar cmd Op args
529This specifies the SCSI CDB.
530SCSI CDBs may be 6, 10, 12 or 16 bytes.
531.It Fl i Ar len Ar fmt
532This specifies the amount of data to read, and how it should be displayed.
533If the format is
534.Sq - ,
535.Ar len
536bytes of data will be read from the device and written to standard output.
537.It Fl o Ar len Ar fmt Op args
538This specifies the amount of data to be written to a device, and the data
539that is to be written.
540If the format is
541.Sq - ,
542.Ar len
543bytes of data will be read from standard input and written to the device.
544.It Fl r Ar fmt
545This specifies that 11 result ATA Command Block registers should be displayed
546(status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp,
547lba_high_exp, sector_count, sector_count_exp), and how.
548If the format is
549.Sq - ,
55011 result registers will be written to standard output in hex.
551.El
552.It Ic debug
553Turn on CAM debugging printfs in the kernel.
554This requires options CAMDEBUG
555in your kernel config file.
556WARNING: enabling debugging printfs currently
557causes an EXTREME number of kernel printfs.
558You may have difficulty
559turning off the debugging printfs once they start, since the kernel will be
560busy printing messages and unable to service other requests quickly.
561The
562.Ic debug
563function takes a number of arguments:
564.Bl -tag -width 18n
565.It Fl I
566Enable CAM_DEBUG_INFO printfs.
567.It Fl P
568Enable CAM_DEBUG_PERIPH printfs.
569.It Fl T
570Enable CAM_DEBUG_TRACE printfs.
571.It Fl S
572Enable CAM_DEBUG_SUBTRACE printfs.
573.It Fl X
574Enable CAM_DEBUG_XPT printfs.
575.It Fl c
576Enable CAM_DEBUG_CDB printfs.
577This will cause the kernel to print out the
578SCSI CDBs sent to the specified device(s).
579.It all
580Enable debugging for all devices.
581.It off
582Turn off debugging for all devices
583.It bus Ns Op :target Ns Op :lun
584Turn on debugging for the given bus, target or lun.
585If the lun or target
586and lun are not specified, they are wildcarded.
587(i.e., just specifying a
588bus turns on debugging printfs for all devices on that bus.)
589.El
590.It Ic tags
591Show or set the number of "tagged openings" or simultaneous transactions
592we attempt to queue to a particular device.
593By default, the
594.Ic tags
595command, with no command-specific arguments (i.e., only generic arguments)
596prints out the "soft" maximum number of transactions that can be queued to
597the device in question.
598For more detailed information, use the
599.Fl v
600argument described below.
601.Bl -tag -width 7n
602.It Fl N Ar tags
603Set the number of tags for the given device.
604This must be between the
605minimum and maximum number set in the kernel quirk table.
606The default for
607most devices that support tagged queueing is a minimum of 2 and a maximum
608of 255.
609The minimum and maximum values for a given device may be
610determined by using the
611.Fl v
612switch.
613The meaning of the
614.Fl v
615switch for this
616.Nm
617subcommand is described below.
618.It Fl q
619Be quiet, and do not report the number of tags.
620This is generally used when
621setting the number of tags.
622.It Fl v
623The verbose flag has special functionality for the
624.Em tags
625argument.
626It causes
627.Nm
628to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
629.Bl -tag -width 13n
630.It dev_openings
631This is the amount of capacity for transactions queued to a given device.
632.It dev_active
633This is the number of transactions currently queued to a device.
634.It devq_openings
635This is the kernel queue space for transactions.
636This count usually mirrors
637dev_openings except during error recovery operations when
638the device queue is frozen (device is not allowed to receive
639commands), the number of dev_openings is reduced, or transaction
640replay is occurring.
641.It devq_queued
642This is the number of transactions waiting in the kernel queue for capacity
643on the device.
644This number is usually zero unless error recovery is in
645progress.
646.It held
647The held count is the number of CCBs held by peripheral drivers that have
648either just been completed or are about to be released to the transport
649layer for service by a device.
650Held CCBs reserve capacity on a given
651device.
652.It mintags
653This is the current "hard" minimum number of transactions that can be
654queued to a device at once.
655The
656.Ar dev_openings
657value above cannot go below this number.
658The default value for
659.Ar mintags
660is 2, although it may be set higher or lower for various devices.
661.It maxtags
662This is the "hard" maximum number of transactions that can be queued to a
663device at one time.
664The
665.Ar dev_openings
666value cannot go above this number.
667The default value for
668.Ar maxtags
669is 255, although it may be set higher or lower for various devices.
670.El
671.El
672.It Ic negotiate
673Show or negotiate various communication parameters.
674Some controllers may
675not support setting or changing some of these values.
676For instance, the
677Adaptec 174x controllers do not support changing a device's sync rate or
678offset.
679The
680.Nm
681utility
682will not attempt to set the parameter if the controller indicates that it
683does not support setting the parameter.
684To find out what the controller
685supports, use the
686.Fl v
687flag.
688The meaning of the
689.Fl v
690flag for the
691.Ic negotiate
692command is described below.
693Also, some controller drivers do not support
694setting negotiation parameters, even if the underlying controller supports
695negotiation changes.
696Some controllers, such as the Advansys wide
697controllers, support enabling and disabling synchronous negotiation for
698a device, but do not support setting the synchronous negotiation rate.
699.Bl -tag -width 17n
700.It Fl a
701Attempt to make the negotiation settings take effect immediately by sending
702a Test Unit Ready command to the device.
703.It Fl c
704Show or set current negotiation settings.
705This is the default.
706.It Fl D Ar enable|disable
707Enable or disable disconnection.
708.It Fl O Ar offset
709Set the command delay offset.
710.It Fl q
711Be quiet, do not print anything.
712This is generally useful when you want to
713set a parameter, but do not want any status information.
714.It Fl R Ar syncrate
715Change the synchronization rate for a device.
716The sync rate is a floating
717point value specified in MHz.
718So, for instance,
719.Sq 20.000
720is a legal value, as is
721.Sq 20 .
722.It Fl T Ar enable|disable
723Enable or disable tagged queueing for a device.
724.It Fl U
725Show or set user negotiation settings.
726The default is to show or set
727current negotiation settings.
728.It Fl v
729The verbose switch has special meaning for the
730.Ic negotiate
731subcommand.
732It causes
733.Nm
734to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
735controller driver.
736.It Fl W Ar bus_width
737Specify the bus width to negotiate with a device.
738The bus width is
739specified in bits.
740The only useful values to specify are 8, 16, and 32
741bits.
742The controller must support the bus width in question in order for
743the setting to take effect.
744.El
745.Pp
746In general, sync rate and offset settings will not take effect for a
747device until a command has been sent to the device.
748The
749.Fl a
750switch above will automatically send a Test Unit Ready to the device so
751negotiation parameters will take effect.
752.It Ic format
753Issue the
754.Tn SCSI
755FORMAT UNIT command to the named device.
756.Pp
757.Em WARNING! WARNING! WARNING!
758.Pp
759Low level formatting a disk will destroy ALL data on the disk.
760Use
761extreme caution when issuing this command.
762Many users low-level format
763disks that do not really need to be low-level formatted.
764There are
765relatively few scenarios that call for low-level formatting a disk.
766One reason for
767low-level formatting a disk is to initialize the disk after changing
768its physical sector size.
769Another reason for low-level formatting a disk
770is to revive the disk if you are getting "medium format corrupted" errors
771from the disk in response to read and write requests.
772.Pp
773Some disks take longer than others to format.
774Users should specify a
775timeout long enough to allow the format to complete.
776The default format
777timeout is 3 hours, which should be long enough for most disks.
778Some hard
779disks will complete a format operation in a very short period of time
780(on the order of 5 minutes or less).
781This is often because the drive
782does not really support the FORMAT UNIT command -- it just accepts the
783command, waits a few minutes and then returns it.
784.Pp
785The
786.Sq format
787subcommand takes several arguments that modify its default behavior.
788The
789.Fl q
790and
791.Fl y
792arguments can be useful for scripts.
793.Pp
794.Bl -tag -width 6n
795.It Fl q
796Be quiet, do not print any status messages.
797This option will not disable
798the questions, however.
799To disable questions, use the
800.Fl y
801argument, below.
802.It Fl r
803Run in
804.Dq report only
805mode.
806This will report status on a format that is already running on the drive.
807.It Fl w
808Issue a non-immediate format command.
809By default,
810.Nm
811issues the FORMAT UNIT command with the immediate bit set.
812This tells the
813device to immediately return the format command, before the format has
814actually completed.
815Then,
816.Nm
817gathers
818.Tn SCSI
819sense information from the device every second to determine how far along
820in the format process it is.
821If the
822.Fl w
823argument is specified,
824.Nm
825will issue a non-immediate format command, and will be unable to print any
826information to let the user know what percentage of the disk has been
827formatted.
828.It Fl y
829Do not ask any questions.
830By default,
831.Nm
832will ask the user if he/she really wants to format the disk in question,
833and also if the default format command timeout is acceptable.
834The user
835will not be asked about the timeout if a timeout is specified on the
836command line.
837.El
838.It Ic idle
839Put ATA device into IDLE state. Optional parameter specifies automatic
840idle timer value in seconds.
841.It Ic standby
842Put ATA device into STANDBY state. Optional parameter specifies automatic
843standby timer value in seconds.
844.It Ic sleep
845Put ATA device into SLEEP state. Note that the only way get device out of
846this state may be reset.
847.It Ic help
848Print out verbose usage information.
849.El
850.Sh ENVIRONMENT
851The
852.Ev SCSI_MODES
853variable allows the user to specify an alternate mode page format file.
854.Pp
855The
856.Ev EDITOR
857variable determines which text editor
858.Nm
859starts when editing mode pages.
860.Sh FILES
861.Bl -tag -width /usr/share/misc/scsi_modes -compact
862.It Pa /usr/share/misc/scsi_modes
863is the SCSI mode format database.
864.It Pa /dev/xpt0
865is the transport layer device.
866.It Pa /dev/pass*
867are the CAM application passthrough devices.
868.El
869.Sh EXAMPLES
870.Dl camcontrol eject -n cd -u 1 -v
871.Pp
872Eject the CD from cd1, and print SCSI sense information if the command
873fails.
874.Pp
875.Dl camcontrol tur da0
876.Pp
877Send the SCSI test unit ready command to da0.
878The
879.Nm
880utility will report whether the disk is ready, but will not display sense
881information if the command fails since the
882.Fl v
883switch was not specified.
884.Pp
885.Bd -literal -offset indent
886camcontrol tur da1 -E -C 4 -t 50 -v
887.Ed
888.Pp
889Send a test unit ready command to da1.
890Enable kernel error recovery.
891Specify a retry count of 4, and a timeout of 50 seconds.
892Enable sense
893printing (with the
894.Fl v
895flag) if the command fails.
896Since error recovery is turned on, the
897disk will be spun up if it is not currently spinning.
898The
899.Nm
900utility will report whether the disk is ready.
901.Bd -literal -offset indent
902camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
903 -i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
904.Ed
905.Pp
906Issue a READ BUFFER command (0x3C) to cd1.
907Display the buffer size of cd1,
908and display the first 10 bytes from the cache on cd1.
909Display SCSI sense
910information if the command fails.
911.Pp
912.Bd -literal -offset indent
913camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
914 -o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
915.Ed
916.Pp
917Issue a WRITE BUFFER (0x3B) command to cd1.
918Write out 10 bytes of data,
919not including the (reserved) 4 byte header.
920Print out sense information if
921the command fails.
922Be very careful with this command, improper use may
923cause data corruption.
924.Pp
925.Bd -literal -offset indent
926camcontrol modepage da3 -m 1 -e -P 3
927.Ed
928.Pp
929Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
930settings on the drive.
931Mode page 1 contains a disk drive's auto read and
932write reallocation settings, among other things.
933.Pp
934.Dl camcontrol rescan all
935.Pp
936Rescan all SCSI busses in the system for devices that have been added,
937removed or changed.
938.Pp
939.Dl camcontrol rescan 0
940.Pp
941Rescan SCSI bus 0 for devices that have been added, removed or changed.
942.Pp
943.Dl camcontrol rescan 0:1:0
944.Pp
945Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
946changed.
947.Pp
948.Dl camcontrol tags da5 -N 24
949.Pp
950Set the number of concurrent transactions for da5 to 24.
951.Pp
952.Bd -literal -offset indent
953camcontrol negotiate -n da -u 4 -T disable
954.Ed
955.Pp
956Disable tagged queueing for da4.
957.Pp
958.Bd -literal -offset indent
959camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
960.Ed
961.Pp
962Negotiate a sync rate of 20MHz and an offset of 15 with da3.
963Then send a
964Test Unit Ready command to make the settings take effect.
965.Sh SEE ALSO
966.Xr cam 3 ,
967.Xr cam_cdbparse 3 ,
968.Xr cam 4 ,
969.Xr pass 4 ,
970.Xr xpt 4
971.Sh HISTORY
972The
973.Nm
974utility first appeared in
975.Fx 3.0 .
976.Pp
977The mode page editing code and arbitrary SCSI command code are based upon
978code in the old
979.Xr scsi 8
980utility and
981.Xr scsi 3
982library, written by Julian Elischer and Peter Dufault.
983The
984.Xr scsi 8
985program first appeared in
986.Bx 386 0.1.2.4 ,
987and first appeared in
988.Fx
989in
990.Fx 2.0.5 .
991.Sh AUTHORS
992.An Kenneth Merry Aq ken@FreeBSD.org
993.Sh BUGS
994The code that parses the generic command line arguments does not know that
995some of the subcommands take multiple arguments.
996So if, for instance, you
997tried something like this:
998.Bd -literal -offset indent
999camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
1000.Ed
1001.Pp
1002The sense information from the test unit ready command would not get
1003printed out, since the first
1004.Xr getopt 3
1005call in
1006.Nm
1007bails out when it sees the second argument to
1008.Fl c
1009(0x00),
1010above.
1011Fixing this behavior would take some gross code, or changes to the
1012.Xr getopt 3
1013interface.
1014The best way to circumvent this problem is to always make sure
1015to specify generic
1016.Nm
1017arguments before any command-specific arguments.