blob: 7ca25e9a8c77d3c1746f82749317e05cf20fb6c9 [file] [log] [blame]
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +00001Introduction
2============
3The FreeBSD port of sg3_utils contains those utilities that are _not_
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +00004specific to Linux. In some cases the FreeBSD camcontrol command supplies
5similar functionality; for example 'sg_map' is similar to
6'camcontrol devlist'.
7
8The dd variants from the sg3_utils package (e.g. sg_dd) rely on too many
Douglas Gilbert1cca59e2011-12-17 02:11:10 +00009Linux idiosyncrasies to be easily ported. A new package called 'ddpt'
Douglas Gilbertfdb38cb2009-02-05 17:42:34 +000010contains a utility with similar functionality to sg_dd and ddpt is available
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +000011for FreeBSD.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000012
13Supported Utilities
14===================
15Here is a list of utilities that have been ported:
Douglas Gilbert35242f72017-09-25 21:57:43 +000016 sg_bg_ctl
Douglas Gilbertc0a72682013-01-18 00:51:54 +000017 sg_compare_and_write
Douglas Gilbert3c60a8b2010-12-06 02:27:23 +000018 sg_decode_sense
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000019 sg_format
20 sg_get_config
Douglas Gilbert53add622009-09-20 13:12:50 +000021 sg_get_lba_status
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000022 sg_ident
23 sg_inq [dropped ATA IDENTIFY DEVICE capability]
24 sg_logs
25 sg_luns
26 sg_modes
Douglas Gilbert75026472007-06-27 03:51:21 +000027 sg_opcodes
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +000028 sg_persist
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000029 sg_prevent
Douglas Gilbert2e37f3d2007-06-27 03:53:07 +000030 sg_raw
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000031 sg_rdac
Douglas Gilbert242e1a82009-06-15 21:46:24 +000032 sg_read_block_limits
Douglas Gilbert75026472007-06-27 03:51:21 +000033 sg_read_buffer
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000034 sg_read_long
35 sg_readcap
36 sg_reassign
Douglas Gilbert542179b2010-09-13 16:41:13 +000037 sg_referrals
Douglas Gilbertcad48992017-11-15 06:21:21 +000038 sg_rep_zones
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000039 sg_requests
40 sg_rmsn
41 sg_rtpg
Douglas Gilbert084021a2007-09-29 13:51:35 +000042 sg_safte
Douglas Gilbert857d1cc2011-06-22 15:13:59 +000043 sg_sanitize
Douglas Gilbert543a9ec2007-06-27 03:26:00 +000044 sg_sat_identify
Douglas Gilbert203814d2007-12-01 05:04:11 +000045 sg_sat_phy_event
Douglas Gilbert084021a2007-09-29 13:51:35 +000046 sg_sat_set_features
Douglas Gilbert3a7e1662018-01-28 06:50:39 +000047 sg_seek
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000048 sg_senddiag
49 sg_ses
50 sg_start
Douglas Gilbertf8340512007-09-01 03:01:06 +000051 sg_stpg
Douglas Gilbert3a7e1662018-01-28 06:50:39 +000052 sg_stream_ctl
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000053 sg_sync
54 sg_turs
55 sg_verify
Douglas Gilbert84323452009-06-11 20:41:54 +000056 sg_unmap
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000057 sg_vpd
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000058 sg_wr_mode
Douglas Gilbert75026472007-06-27 03:51:21 +000059 sg_write_buffer
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000060 sg_write_long
Douglas Gilbertf5674ee2009-03-11 17:53:31 +000061 sg_write_same
Douglas Gilbert35242f72017-09-25 21:57:43 +000062 sg_write_verify
Douglas Gilbertcad48992017-11-15 06:21:21 +000063 sg_write_x
64 sg_zone
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000065
66Most utility names are indicative of the main SCSI command
67that they execute. Some utilities are slightly higher level, for
68example sg_ses fetches SCSI Enclosure Services (SES) status pages and
69can send control pages. Each utility has a man page (placed in
70section 8). An overview of sg3_utils can be found at:
Douglas Gilbertca3850f2008-10-26 21:43:17 +000071http://sg.danny.cz/sg/sg3_utils.html .
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000072A copy of the "sg3_utils.html" file is in the "doc" subdirectory.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000073
74
Douglas Gilbert3457b262010-04-24 20:56:46 +000075The executables and library can be built from the source code in
76the tarball and installed with the familiar
77"./configure ; make ; make install" sequence. If this fails try
78running the "./autogen.sh" script prior to that sequence. There
79are generic instruction on configure and friend in the INSTALL file.
80
Douglas Gilbert1cca59e2011-12-17 02:11:10 +000081Some man pages have examples which use Linux device names which
Douglas Gilbert3457b262010-04-24 20:56:46 +000082hopefully will not confuse the FreeBSD users.
83
84Device naming
85=============
86In FreeBSD disks have block names like '/dev/da0' with a corresponding
87pass-through device name like '/dev/pass0'. Use this command
88"camcontrol devlist" to see that SCSI devices available.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000089
Douglas Gilbertbccea1a2012-01-19 14:09:40 +000090FreeBSD installation
91====================
92The traditional './configure ; make ; make install' sequence from the
93top level of the unpacked tarball will work on FreeBSD. But the man pages
94will be placed under the /usr/local/share/man directory which unfortunately
95is not on the standard manpath. One solution is to add this path by
96creating a file with a name like local_share.conf in the
97/usr/local/etc/man.d/ directory and placing this line in it:
98 MANPATH /usr/local/share/man
99
100FreeBSD 9.0 has a "ports" entry for sg3_utils under the
101/usr/ports/sysutils directory. It points to version 1.28 of sg3_utils
102which is now a bit dated. It could be used as a template to point
103to more recent versions.
104
Douglas Gilberte799fe22011-02-26 02:23:57 +0000105kFreeBSD
106========
107sg3_utils can be built into a Debian package for kFreeBSD using the
108./build_debian.sh script in the top level directory. This has been tested
109with Debian 6.0 release.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000110
111Details
112=======
Douglas Gilbert3457b262010-04-24 20:56:46 +0000113Most of the ported utilities listed above use SCSI command functions
114declared in sg_cmds_*.h headers . Those SCSI command functions are
115implemented in the corresponding ".c" files. The ".c" files pass SCSI
116commands to the host operating system via an interface declared in sg_pt.h .
117There are currently five implementations of that interface depending on
118the host operating system:
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000119 - sg_pt_linux.c
120 - sg_pt_freebsd.c
121 - sg_pt_osf1.c [Tru64]
Douglas Gilbert543a9ec2007-06-27 03:26:00 +0000122 - sg_pt_win32.c
Douglas Gilbert3457b262010-04-24 20:56:46 +0000123 - sg_pt_solaris.c
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000124
Douglas Gilbert3457b262010-04-24 20:56:46 +0000125The sg_pt_freebsd.c file uses the FreeBSD CAM SCSI pass through mechanism.
126Hence only FreeBSD device nodes that support CAM can be used. These can be
127viewed with the "camcontrol devlist" command. To access ATAPI devices (e.g.
128ATAPI DVD drives) the kernel may need to be configured with the "atapicam"
129device.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000130
Douglas Gilberte799fe22011-02-26 02:23:57 +0000131Attempts to send SCSI commands with data-in or data-out buffers around 64 KB
132and larger failed on a FreeBSD 7.0 with an "argument list too long" error
133message. There is an associated kernel message (viewable with dmesg) that an
134attempt has been made to map <n> bytes which is greater than
135DFLTPHYS(65536). Still a problem in FreeBSD 8.1 . Due to CAM overhead the
136largest power of 2 that can fit through with one command is 32768 bytes (32
137KB).
138
Douglas Gilbertbccea1a2012-01-19 14:09:40 +0000139FreeBSD 9.0 is the most recent version of FreeBSD tested with these
Douglas Gilbert3457b262010-04-24 20:56:46 +0000140utilities.
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +0000141
Douglas Gilbert2e37f3d2007-06-27 03:53:07 +0000142
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000143
Douglas Gilbertdd92db02012-02-10 23:09:25 +0000144Douglas Gilbert
Douglas Gilbert3a7e1662018-01-28 06:50:39 +000014527th January 2018