forked from doug-gilbert/sg3_utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
113 lines (100 loc) · 5.73 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
README for sg3_utils
====================
Introduction
------------
sg3_utils is a package of utilities originally written to send individual
SCSI commands to storage devices that used one of the SCSI command sets.
These utilities can be divided into three groups:
- sg_raw: the user supplies the cdb (command descriptor block) and
optionally the size of the data-in and data-out buffers
- one command utilities: the majority of the utilities in this package
send one SCSI command. Their names start with "sg_" while the
remaining part of their name alludes to the command which is sent. For
example, "sg_inq" sends the SCSI INQUIRY command. Some utilities in
this group send one of a selection of commands, typically those
commands have a lot it common (e.g. sg_write_x).
- copy type utilities: sg_dd, sgp_dd and sgm_dd use the Unix dd command
as a template. sg_xcopy sends the SCSI EXTENDED COPY command which in
some cases can do offloaded copies. As well as copying some of these
utilities can compare if two data segments held on disks are the same.
Platforms
---------
These utilities were written on Linux and should work from Linux kernel
(lk) 2.4 through to the current series 5. The third group ("copy type")
are only implemented on Linux, but a separate portable package/utility
called ddpt implements similar functionality. The first two groups are
implemented (i.e. ported) to Android, FreeBSD, Solaris and Windows. The
Windows port uses either a Cygwin or MinGW (plus Msys) build environment
(rather than Visual Studio).
Library
-------
Many of these utilities share a lot of code (e.g. SCSI error messages)
so a lot of repetition (potentially error prone) is saved by having a
library called libsgutils or some variation on that name. Distributions
(especially of Linux) have differing policies on how a library (and a
package) should be named. For that reason this package is sometimes
known as "sg3-utils" (i.e. the underscore is turned into a hyphen).
Various other packages use libsgutils. The library interface is not
altered from one package release, to the next, but the library interface
may be expanded. If a utility from one release is used with a libsgutils
from an earlier release, then the runtime linking may fail. Typically
package managers take care of these details so that runtime linking
errors should be rare.
Command Sets
------------
SCSI command sets are not the only storage command sets in wide use, there
are also ATA and NVMe command sets. There is a SCSI command set to
translate SCSI commands to ATA commands (called SAT: SCSI to ATA
Translation). SAT includes an ATA PASS-THROUGH SCSI command and sg_sat_*
utilities (there are four) are examples of using SAT. The SAS transport
(Serial Attached SCSI) can convey ATA commands through a SCSI/SAS domain
via its Serial ATA Tunnelled Protocol (STP).
NVMe command sets (e.g. Admin, NVM and MI) are relatively new. There was an
early paper on a SCSI to NVMe Translation Layer (SNTL) but it hasn't been
standardized. The sg_inq utility will send (and decode the response of) a
SCSI INQUIRY command if the underlying device is a SCSI device. If the
underlying device is a NVMe controller or namespace, then sg_inq will send
a NVMe Admin Identify command and decode the response. The sg_ses utility
(for SCSI Enclosure Services) also checks whether its underlying device is
SCSI or NVME. In the NVMe case, sg_ses translates the SCSI SEND DIAGNOSTIC
and READ DIAGNOSTIC RESULTS commands to the NVMe Management Interface (MI)
SES Send and SES Receive commands respectively. The output of the sg_ses
utility should be similar, irrespective of whether the "SES" device is
SCSI or NVMe.
The sg_raw utility may send NVMe Admin or NVM commands (as well as SCSI
commands). One difficulty with a command-line utility invoking NVME
commands is that those commands contain memory addresses for data-in (from
the storage device) or data-out (toward the storage device) transfers. See
the sg_raw manpage for how this difficulty is addressed.
Documentation
-------------
Manual pages ("manpages") are the primary method of utility documentation.
All utilities and scripts that are installed by this package have a
manpage. There are utilities in the examples, testing and utils
directories that are not installed and do not have manpages. Nearly
all utilities have runtime help, usually invoked with either the '-h'
short option or the '--help' long option. There is also an overarching
manpage called "sg3_utils". All manpages are placed in chapter 8 which
is for system administration commands/utilities.
The sg3_utils package and some more complex utilities have html pages:
sg3_utils: https://sg.danny.cz/sg/sg3_utils.html
sg_ses: https://sg.danny.cz/sg/sg_ses.html
sg_dd: https://sg.danny.cz/sg/sg_dd.html
A tarball (and zip) of all the manpages from the previous release are
here:
https://sg.danny.cz/sg/p/sg3_utils_man_html.tgz
https://sg.danny.cz/sg/p/sg3_utils_man_html.zip
There is a html rendering of the sg3_utils manpage in the same directory
as this README file called sg3_utils.man8.html .
The previous README file is now called README.details plus there are
these OS specific files: README.freebsd , README.solaris , README.tru64
and README.win32 . To know the current state of the package the ChangeLog
file is the good reference.
The author's primary source code repository uses subversion and is on
the author's equipment (a RPi). One advantage of subversion is its
revision numbers which are simply integers starting at 1 and ascending.
For this package the current revision is 928 . The subversion repository
is mirrored in git (using "git svn" tools) here:
https://github.com/doug-gilbert/sg3_utils
Douglas Gilbert
31st December 2021