Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 1 | Introduction |
| 2 | ============ |
| 3 | The FreeBSD port of sg3_utils contains those utilities that are _not_ |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 4 | specific to Linux. In some cases the FreeBSD camcontrol command supplies |
| 5 | similar functionality; for example 'sg_map' is similar to |
| 6 | 'camcontrol devlist'. |
| 7 | |
| 8 | The dd variants from the sg3_utils package (e.g. sg_dd) rely on too many |
Douglas Gilbert | 1cca59e | 2011-12-17 02:11:10 +0000 | [diff] [blame] | 9 | Linux idiosyncrasies to be easily ported. A new package called 'ddpt' |
Douglas Gilbert | fdb38cb | 2009-02-05 17:42:34 +0000 | [diff] [blame] | 10 | contains a utility with similar functionality to sg_dd and ddpt is available |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 11 | for FreeBSD. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 12 | |
| 13 | Supported Utilities |
| 14 | =================== |
| 15 | Here is a list of utilities that have been ported: |
Douglas Gilbert | 35242f7 | 2017-09-25 21:57:43 +0000 | [diff] [blame] | 16 | sg_bg_ctl |
Douglas Gilbert | c0a7268 | 2013-01-18 00:51:54 +0000 | [diff] [blame] | 17 | sg_compare_and_write |
Douglas Gilbert | 3c60a8b | 2010-12-06 02:27:23 +0000 | [diff] [blame] | 18 | sg_decode_sense |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 19 | sg_format |
| 20 | sg_get_config |
Douglas Gilbert | 53add62 | 2009-09-20 13:12:50 +0000 | [diff] [blame] | 21 | sg_get_lba_status |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 22 | sg_ident |
| 23 | sg_inq [dropped ATA IDENTIFY DEVICE capability] |
| 24 | sg_logs |
| 25 | sg_luns |
| 26 | sg_modes |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 27 | sg_opcodes |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 28 | sg_persist |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 29 | sg_prevent |
Douglas Gilbert | 2e37f3d | 2007-06-27 03:53:07 +0000 | [diff] [blame] | 30 | sg_raw |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 31 | sg_rdac |
Douglas Gilbert | 242e1a8 | 2009-06-15 21:46:24 +0000 | [diff] [blame] | 32 | sg_read_block_limits |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 33 | sg_read_buffer |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 34 | sg_read_long |
| 35 | sg_readcap |
| 36 | sg_reassign |
Douglas Gilbert | 542179b | 2010-09-13 16:41:13 +0000 | [diff] [blame] | 37 | sg_referrals |
Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 38 | sg_rep_zones |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 39 | sg_requests |
| 40 | sg_rmsn |
| 41 | sg_rtpg |
Douglas Gilbert | 084021a | 2007-09-29 13:51:35 +0000 | [diff] [blame] | 42 | sg_safte |
Douglas Gilbert | 857d1cc | 2011-06-22 15:13:59 +0000 | [diff] [blame] | 43 | sg_sanitize |
Douglas Gilbert | 543a9ec | 2007-06-27 03:26:00 +0000 | [diff] [blame] | 44 | sg_sat_identify |
Douglas Gilbert | 203814d | 2007-12-01 05:04:11 +0000 | [diff] [blame] | 45 | sg_sat_phy_event |
Douglas Gilbert | 084021a | 2007-09-29 13:51:35 +0000 | [diff] [blame] | 46 | sg_sat_set_features |
Douglas Gilbert | 3a7e166 | 2018-01-28 06:50:39 +0000 | [diff] [blame] | 47 | sg_seek |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 48 | sg_senddiag |
| 49 | sg_ses |
| 50 | sg_start |
Douglas Gilbert | f834051 | 2007-09-01 03:01:06 +0000 | [diff] [blame] | 51 | sg_stpg |
Douglas Gilbert | 3a7e166 | 2018-01-28 06:50:39 +0000 | [diff] [blame] | 52 | sg_stream_ctl |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 53 | sg_sync |
| 54 | sg_turs |
| 55 | sg_verify |
Douglas Gilbert | 8432345 | 2009-06-11 20:41:54 +0000 | [diff] [blame] | 56 | sg_unmap |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 57 | sg_vpd |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 58 | sg_wr_mode |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 59 | sg_write_buffer |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 60 | sg_write_long |
Douglas Gilbert | f5674ee | 2009-03-11 17:53:31 +0000 | [diff] [blame] | 61 | sg_write_same |
Douglas Gilbert | 35242f7 | 2017-09-25 21:57:43 +0000 | [diff] [blame] | 62 | sg_write_verify |
Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 63 | sg_write_x |
| 64 | sg_zone |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 65 | |
| 66 | Most utility names are indicative of the main SCSI command |
| 67 | that they execute. Some utilities are slightly higher level, for |
| 68 | example sg_ses fetches SCSI Enclosure Services (SES) status pages and |
| 69 | can send control pages. Each utility has a man page (placed in |
| 70 | section 8). An overview of sg3_utils can be found at: |
Douglas Gilbert | ca3850f | 2008-10-26 21:43:17 +0000 | [diff] [blame] | 71 | http://sg.danny.cz/sg/sg3_utils.html . |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 72 | A copy of the "sg3_utils.html" file is in the "doc" subdirectory. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 73 | |
| 74 | |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 75 | The executables and library can be built from the source code in |
| 76 | the tarball and installed with the familiar |
| 77 | "./configure ; make ; make install" sequence. If this fails try |
| 78 | running the "./autogen.sh" script prior to that sequence. There |
| 79 | are generic instruction on configure and friend in the INSTALL file. |
| 80 | |
Douglas Gilbert | 1cca59e | 2011-12-17 02:11:10 +0000 | [diff] [blame] | 81 | Some man pages have examples which use Linux device names which |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 82 | hopefully will not confuse the FreeBSD users. |
| 83 | |
| 84 | Device naming |
| 85 | ============= |
| 86 | In FreeBSD disks have block names like '/dev/da0' with a corresponding |
| 87 | pass-through device name like '/dev/pass0'. Use this command |
| 88 | "camcontrol devlist" to see that SCSI devices available. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 89 | |
Douglas Gilbert | bccea1a | 2012-01-19 14:09:40 +0000 | [diff] [blame] | 90 | FreeBSD installation |
| 91 | ==================== |
| 92 | The traditional './configure ; make ; make install' sequence from the |
| 93 | top level of the unpacked tarball will work on FreeBSD. But the man pages |
| 94 | will be placed under the /usr/local/share/man directory which unfortunately |
| 95 | is not on the standard manpath. One solution is to add this path by |
| 96 | creating 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 | |
| 100 | FreeBSD 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 |
| 102 | which is now a bit dated. It could be used as a template to point |
| 103 | to more recent versions. |
| 104 | |
Douglas Gilbert | e799fe2 | 2011-02-26 02:23:57 +0000 | [diff] [blame] | 105 | kFreeBSD |
| 106 | ======== |
| 107 | sg3_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 |
| 109 | with Debian 6.0 release. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 110 | |
| 111 | Details |
| 112 | ======= |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 113 | Most of the ported utilities listed above use SCSI command functions |
| 114 | declared in sg_cmds_*.h headers . Those SCSI command functions are |
| 115 | implemented in the corresponding ".c" files. The ".c" files pass SCSI |
| 116 | commands to the host operating system via an interface declared in sg_pt.h . |
| 117 | There are currently five implementations of that interface depending on |
| 118 | the host operating system: |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 119 | - sg_pt_linux.c |
| 120 | - sg_pt_freebsd.c |
| 121 | - sg_pt_osf1.c [Tru64] |
Douglas Gilbert | 543a9ec | 2007-06-27 03:26:00 +0000 | [diff] [blame] | 122 | - sg_pt_win32.c |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 123 | - sg_pt_solaris.c |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 124 | |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 125 | The sg_pt_freebsd.c file uses the FreeBSD CAM SCSI pass through mechanism. |
| 126 | Hence only FreeBSD device nodes that support CAM can be used. These can be |
| 127 | viewed with the "camcontrol devlist" command. To access ATAPI devices (e.g. |
| 128 | ATAPI DVD drives) the kernel may need to be configured with the "atapicam" |
| 129 | device. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 130 | |
Douglas Gilbert | e799fe2 | 2011-02-26 02:23:57 +0000 | [diff] [blame] | 131 | Attempts to send SCSI commands with data-in or data-out buffers around 64 KB |
| 132 | and larger failed on a FreeBSD 7.0 with an "argument list too long" error |
| 133 | message. There is an associated kernel message (viewable with dmesg) that an |
| 134 | attempt has been made to map <n> bytes which is greater than |
| 135 | DFLTPHYS(65536). Still a problem in FreeBSD 8.1 . Due to CAM overhead the |
| 136 | largest power of 2 that can fit through with one command is 32768 bytes (32 |
| 137 | KB). |
| 138 | |
Douglas Gilbert | bccea1a | 2012-01-19 14:09:40 +0000 | [diff] [blame] | 139 | FreeBSD 9.0 is the most recent version of FreeBSD tested with these |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 140 | utilities. |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 141 | |
Douglas Gilbert | 2e37f3d | 2007-06-27 03:53:07 +0000 | [diff] [blame] | 142 | |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 143 | |
Douglas Gilbert | dd92db0 | 2012-02-10 23:09:25 +0000 | [diff] [blame] | 144 | Douglas Gilbert |
Douglas Gilbert | 3a7e166 | 2018-01-28 06:50:39 +0000 | [diff] [blame] | 145 | 27th January 2018 |