aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--doc/sg3_utils.810
-rw-r--r--doc/sg_format.846
-rw-r--r--doc/sg_logs.84
-rw-r--r--doc/sg_raw.88
-rw-r--r--doc/sg_readcap.88
-rw-r--r--doc/sg_sanitize.818
-rw-r--r--doc/sg_senddiag.820
-rw-r--r--doc/sg_sync.810
-rw-r--r--doc/sg_timestamp.810
-rw-r--r--include/sg_lib.h14
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--src/sg_format.c68
-rw-r--r--src/sg_inq.c17
-rw-r--r--src/sg_raw.c4
-rw-r--r--src/sg_readcap.c14
-rw-r--r--src/sg_sanitize.c53
-rw-r--r--src/sg_senddiag.c14
-rw-r--r--src/sg_sync.c6
-rw-r--r--src/sg_timestamp.c12
20 files changed, 218 insertions, 131 deletions
diff --git a/ChangeLog b/ChangeLog
index b733ecf7..51d81f9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,18 +2,21 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.43 [20180515] [svn: r772]
+Changelog for sg3_utils-1.43 [20180519] [svn: r773]
- sg_write_x: where x can be normal, atomic, or(write),
same, scattered, or stream writes with 16 or 32 byte
cdbs (sbc4r04 for atomic, sbc4r11 for scattered)
- sg_bg_ctl: new Background control command (sbc4r08)
- sg_seek: new SEEK(10) or PRE-FETCH(10 or 16)
- sg_stream_ctl: new, STREAM CONTROL or GET STREAM STATUS
- - sg_senddiag: add --timeout=SEC option
- - sg_sanitize: add --timeout=SEC option
- - sg_format: add --timeout=SEC option
+ - sg_senddiag: add --timeout=SECS option
+ - sg_sanitize: add --timeout=SECS option
+ - add --dry-run option
+ - sg_format: add --timeout=SECS option
- add --dry-run option to bypass modifying behaviour
- add --quick option to skip reconsideration time
+ - extend --wait timeout to 40 hours for disk sizes
+ > 4 TB and 80 hours if > 8 TB
- sg_decode sense: add --cdb option
- sg_ses: handle 2 bit EIIOE field in aes dpage
- add --quiet option to suppress messages
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index f1c0f4e7..74e2fa9d 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -5,7 +5,7 @@ sg3_utils \- a package of utilities for sending SCSI commands
.B sg_*
[\fI\-\-dry\-run\fR] [\fI\-\-enumerate\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
[\fI\-\-in=FN\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-raw\fR]
-[\fI\-\-timeout=SEC\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
+[\fI\-\-timeout=SECS\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
[\fIOTHER_OPTIONS\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -516,19 +516,19 @@ SCSI command, use this option. Alternatively the \fI\-\-in=FN\fR option causes
from a file named \fIFN\fR. In these cases this option may indicate that
binary data can be read from stdin or from a nominated file (e.g. \fIFN\fR).
.TP
-\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
+\fB\-t\fR, \fB\-\-timeout\fR=\fISECS\fR
utilities that issue potentially long\-running SCSI commands often have a
-\fI\-\-timeout=SEC\fR option. This typically instructs the operating system
+\fI\-\-timeout=SECS\fR option. This typically instructs the operating system
to abort the SCSI command in question once the timeout expires. Aborting
SCSI commands is typically a messy business and in the case of format like
commands may leave the device in a "format corrupt" state requiring another
-long\-running re\-initialization command to be sent. The argument, \fISEC\fR,
+long\-running re\-initialization command to be sent. The argument, \fISECS\fR,
is usually in seconds and the short form of the option may be something
other than \fI\-t\fR since the timeout option was typically added later as
storage devices grew in size and initialization commands took longer. Since
many utilities had relatively long internal command timeouts before this
option was introduced, the actual command timeout given to the operating
-systems is the higher of the internal timeout and \fISEC\fR.
+systems is the higher of the internal timeout and \fISECS\fR.
.br
Many long running SCSI commands have an IMMED bit which causes the command
to finish relatively quickly but the initialization process to continue. In
diff --git a/doc/sg_format.8 b/doc/sg_format.8
index 85f6eb78..7d36f5fe 100644
--- a/doc/sg_format.8
+++ b/doc/sg_format.8
@@ -1,16 +1,16 @@
-.TH SG_FORMAT "8" "March 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_FORMAT "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_format \- format, resize a SCSI disk or format a tape
.SH SYNOPSIS
.B sg_format
[\fI\-\-cmplst=\fR{0|1}] [\fI\-\-count=COUNT\fR] [\fI\-\-dcrt\fR]
-[\fI\-\-early\fR] [\fI\-\-ffmt=FFMT\fR] [\fI\-\-fmtpinfo=FPI\fR]
-[\fI\-\-format\fR] [\fI\-\-help\fR] [\fI\-\-ip\-def\fR] [\fI\-\-long\fR]
-[\fI\-\-mode=MP\fR] [\fI\-\-pfu=PFU\fR] [\fI\-\-pie=PIE\fR] [\fI\-\-pinfo\fR]
-[\fI\-\-poll=PT\fR] [\fI\-\-quick\fR] [\fI\-\-resize\fR] [\fI\-\-rto_req\fR]
-[\fI\-\-security\fR] [\fI\-\-six\fR] [\fI\-\-size=SIZE\fR] [\fI\-\-tape=FM\fR]
-[\fI\-\-timeout=SEC\fR] [\fI\-\-verbose\fR] [\fI\-\-verify\fR]
-[\fI\-\-version\fR] [\fI\-\-wait\fR]
+[\fI\-\-dry\-run\fR] [\fI\-\-early\fR] [\fI\-\-ffmt=FFMT\fR]
+[\fI\-\-fmtpinfo=FPI\fR] [\fI\-\-format\fR] [\fI\-\-help\fR]
+[\fI\-\-ip\-def\fR] [\fI\-\-long\fR] [\fI\-\-mode=MP\fR] [\fI\-\-pfu=PFU\fR]
+[\fI\-\-pie=PIE\fR] [\fI\-\-pinfo\fR] [\fI\-\-poll=PT\fR] [\fI\-\-quick\fR]
+[\fI\-\-resize\fR] [\fI\-\-rto_req\fR] [\fI\-\-security\fR] [\fI\-\-six\fR]
+[\fI\-\-size=SIZE\fR] [\fI\-\-tape=FM\fR] [\fI\-\-timeout=SECS\fR]
+[\fI\-\-verbose\fR] [\fI\-\-verify\fR] [\fI\-\-version\fR] [\fI\-\-wait\fR]
\fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -117,6 +117,12 @@ The default action of this utility (i.e. when this option is not given) is
to clear the DCRT bit thereby requesting "media certification". When the DCRT
bit is set, the FOV bit must also be set hence sg_format does that.
.TP
+\fB\-d\fR, \fB\-\-dry\-run\fR
+this option will parse the command line, do all the preparation but bypass
+the actual FORMAT UNIT or FORMAT MEDIUM commands. Also if the options would
+cause the logical block size to change, then the MODE SELECT command that
+would do that is also bypassed when the dry run option is given.
+.TP
\fB\-e\fR, \fB\-\-early\fR
during a format operation, The default action of this utility is to poll the
disk every 60 seconds to determine the progress of the format operation until
@@ -275,17 +281,19 @@ set to \fIFM\fR. This option is used to prepare a tape (i.e. the "medium")
in a tape drive for use. Values for \fIFM\fR include 0 to do the "default"
format; 1 to partition a volume and 2 to do a default format then partition.
.TP
-\fB\-m\fR, \fB\-\-timeout\fR=\fISEC\fR
-where \fISEC\fR is the FORMAT UNIT or FORMAT MEDIUM command timeout in
-seconds. \fISEC\fR will only be used if it exceeds the internal timeout
+\fB\-m\fR, \fB\-\-timeout\fR=\fISECS\fR
+where \fISECS\fR is the FORMAT UNIT or FORMAT MEDIUM command timeout in
+seconds. \fISECS\fR will only be used if it exceeds the internal timeout
which is 20 seconds if the IMMED bit is set and 72000 seconds (20 hours)
-if the IMMED bit is not set. If the timeout is exceeded then the
-operating system will typically abort the command. Aborting a command
-may escalate to a LUN reset (or worse). A timeout may also leave
-the disk or tape format operation incomplete. And that may result in the
-disk or tape being in a "format corrupt" state requiring another format
-to remedy the situation. So for various reasons timeouts are best
-avoided.
+or higher if the IMMED bit is not set. If the didk unit exceeds 4 TB then
+the timeout value is increased to 144000 seconds (40 hours). And if it is
+greater than 8 TB then the timeout value is increased to 288000 seconds (80
+hours). If the timeout is exceeded then the operating system will typically
+abort the command. Aborting a command may escalate to a LUN reset (or
+worse). A timeout may also leave the disk or tape format operation
+incomplete. And that may result in the disk or tape being in a "format
+corrupt" state requiring another format to remedy the situation. So for
+various reasons timeouts are best avoided.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase the level of verbosity, (i.e. debug output). "\-vvv" gives
@@ -304,7 +312,7 @@ command's (short) parameter header. If this option (i.e. \fI\-\-wait\fR) is
given then the "IMMED" bit is not set. If \fI\-\-wait\fR is given then the
FORMAT UNIT or FORMAT MEDIUM command waits until the format operation
completes before returning its response. This can be many hours on large
-disks. See the \fI\-\-timeout=SEC\fR option.
+disks. See the \fI\-\-timeout=SECS\fR option.
.SH LISTS
The SBC\-3 draft (revision 36) defines PLIST, CLIST, DLIST and GLIST in
section 4.13 on "Medium defects". Briefly, the PLIST is the "primary"
diff --git a/doc/sg_logs.8 b/doc/sg_logs.8
index 04bb4f56..8a2447b6 100644
--- a/doc/sg_logs.8
+++ b/doc/sg_logs.8
@@ -1,4 +1,4 @@
-.TH SG_LOGS "8" "October 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_LOGS "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_logs \- access log pages with SCSI LOG SENSE command
.SH SYNOPSIS
@@ -472,7 +472,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2002\-2017 Douglas Gilbert
+Copyright \(co 2002\-2018 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_raw.8 b/doc/sg_raw.8
index 499ca46f..4bdea7ad 100644
--- a/doc/sg_raw.8
+++ b/doc/sg_raw.8
@@ -1,4 +1,4 @@
-.TH SG_RAW "8" "February 2018" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_RAW "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_raw \- send arbitrary SCSI command to a device
.SH SYNOPSIS
@@ -6,7 +6,7 @@ sg_raw \- send arbitrary SCSI command to a device
[\fI\-\-binary\fR] [\fI\-\-cmdfile=CF\fR] [\fI\-\-enumerate\fR]
[\fI\-\-help\fR] [\fI\-\-infile=IFILE\fR] [\fI\-\-nosense\fR]
[\fI\-\-outfile=OFILE\fR] [\fI\-\-readonly\fR] [\fI\-\-request=RLEN\fR]
-[\fI\-\-send=SLEN\fR] [\fI\-\-skip=KLEN\fR] [\fI\-\-timeout=SEC\fR]
+[\fI\-\-send=SLEN\fR] [\fI\-\-skip=KLEN\fR] [\fI\-\-timeout=SECS\fR]
[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR [CDB0 CDB1 ...]
.SH DESCRIPTION
This utility sends an arbitrary SCSI command (between 6 and 256 bytes) to
@@ -95,8 +95,8 @@ Skip the first \fIKLEN\fR bytes of the input file or stream. This option
is ignored if \fI\-\-send\fR is not specified. If \fI\-\-send\fR is given
and this option is not given, then zero bytes are skipped.
.TP
-\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
-Wait up to \fISEC\fR seconds for command completion (default: 20).
+\fB\-t\fR, \fB\-\-timeout\fR=\fISECS\fR
+Wait up to \fISECS\fR seconds for command completion (default: 20).
Note that if a command times out the operating system may start by
aborting the command and if that is unsuccessful it may attempt
to reset the device.
diff --git a/doc/sg_readcap.8 b/doc/sg_readcap.8
index 9ebb25d9..ffc8724b 100644
--- a/doc/sg_readcap.8
+++ b/doc/sg_readcap.8
@@ -1,4 +1,4 @@
-.TH SG_READCAP "8" "October 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_READCAP "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_readcap \- send SCSI READ CAPACITY command
.SH SYNOPSIS
@@ -31,8 +31,8 @@ CAPACITY(16). Sadly there are horrible SCSI command set implementations in
the wild that crash when the READ CAPACITY(16) command is sent to them.
.PP
Device capacity is the product of the number of blocks by the block size.
-This utility outputs this figure in bytes, MiB (1048576 bytes per MiB)
-and GB (1000000000 bytes per GB).
+This utility outputs this figure in bytes, MiB (1048576 bytes per MiB),
+GB (1000000000 bytes per GB) and, if large enough, TB (1000 GB).
.PP
If sg_readcap is called without the \fI\-\-long\fR option then the 10 byte
cdb version (i.e. READ CAPACITY (10)) is sent to the \fIDEVICE\fR. If the
@@ -179,7 +179,7 @@ using \fI\-\-old\fR (or \fI\-O\fR) as the first command line option.
.SH AUTHORS
Written by Douglas Gilbert
.SH COPYRIGHT
-Copyright \(co 1999\-2017 Douglas Gilbert
+Copyright \(co 1999\-2018 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_sanitize.8 b/doc/sg_sanitize.8
index 4886cd2b..5bc7cb61 100644
--- a/doc/sg_sanitize.8
+++ b/doc/sg_sanitize.8
@@ -1,13 +1,13 @@
-.TH SG_SANITIZE "8" "February 2016" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_SANITIZE "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_sanitize \- remove all user data from disk with SCSI SANITIZE command
.SH SYNOPSIS
.B sg_sanitize
[\fI\-\-ause\fR] [\fI\-\-block\fR] [\fI\-\-count=OC\fR] [\fI\-\-crypto\fR]
-[\fI\-\-desc\fR] [\fI\-\-early\fR] [\fI\-\-fail\fR] [\fI\-\-help\fR]
-[\fI\-\-invert\fR] [\fI\-\-ipl=LEN\fR] [\fI\-\-overwrite\fR]
+[\fI\-\-dry\-run\fR] [\fI\-\-desc\fR] [\fI\-\-early\fR] [\fI\-\-fail\fR]
+[\fI\-\-help\fR] [\fI\-\-invert\fR] [\fI\-\-ipl=LEN\fR] [\fI\-\-overwrite\fR]
[\fI\-\-pattern=PF\fR] [\fI\-\-quick\fR] [\fI\-\-test=TE\fR]
-[\fI\-\-timeout=SEC\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
+[\fI\-\-timeout=SECS\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
[\fI\-\-wait\fR] [\fI\-\-zero\fR] [\fI\-\-znr\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -72,6 +72,10 @@ used after the SANITIZE command is issued (assuming that neither the
\fI\-\-early\fR nor the \fI\-\-wait\fR option have been given) to check
on the progress of this command as it can take some time.
.TP
+\fB\-D\fR, \fB\-\-dry\-run\fR
+this option will parse the command line, do all the preparation but bypass
+the actual SANITIZE command.
+.TP
\fB\-e\fR, \fB\-\-early\fR
the default action of this utility is to poll the disk every 60 seconds to
fetch the progress indication until the sanitize is finished. When this
@@ -124,8 +128,8 @@ set the TEST field in the overwrite service action parameter list. This
only affects the "overwrite" sanitize operation. The default is to place
0 in that field.
.TP
-\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
-where \fISEC\fR is the number of seconds used for the timeout on the
+\fB\-t\fR, \fB\-\-timeout\fR=\fISECS\fR
+where \fISECS\fR is the number of seconds used for the timeout on the
SANITIZE command.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
@@ -234,7 +238,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2011\-2016 Douglas Gilbert
+Copyright \(co 2011\-2018 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_senddiag.8 b/doc/sg_senddiag.8
index 3877bfa3..e3fa612f 100644
--- a/doc/sg_senddiag.8
+++ b/doc/sg_senddiag.8
@@ -1,4 +1,4 @@
-.TH SG_SENDDIAG "8" "October 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_SENDDIAG "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_senddiag \- performs a SCSI SEND DIAGNOSTIC command
.SH SYNOPSIS
@@ -6,13 +6,13 @@ sg_senddiag \- performs a SCSI SEND DIAGNOSTIC command
[\fI\-\-doff\fR] [\fI\-\-extdur\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
[\fI\-\-list\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-page=PG\fR] [\fI\-\-pf\fR]
[\fI\-\-raw=H,H...\fR] [\fI\-\-raw=\-\fR] [\fI\-\-selftest=ST\fR]
-[\fI\-\-test\fR] [\fI\-\-timeout=SEC\fR] [\fI\-\-uoff\fR] [\fI\-\-verbose\fR]
+[\fI\-\-test\fR] [\fI\-\-timeout=SECS\fR] [\fI\-\-uoff\fR] [\fI\-\-verbose\fR]
[\fI\-\-version\fR] \fIDEVICE\fR
.PP
.B sg_senddiag
[\fI\-doff\fR] [\fI\-e\fR] [\fI\-h\fR] [\fI\-H\fR] [\fI\-l\fR] [\fI\-pf\fR]
[\fI\-raw=H,H...\fR] [\fI\-raw=\-\fR] [\fI\-s=ST\fR] [\fI\-t\fR]
-[\fI\-T=SEC\fR] [\fI\-uoff\fR] [\fI\-v\fR] [\fI\-V\fR] [\fI\-?\fR]
+[\fI\-T=SECS\fR] [\fI\-uoff\fR] [\fI\-v\fR] [\fI\-V\fR] [\fI\-?\fR]
\fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -129,10 +129,10 @@ The \fI\-\-selftest=ST\fR option should not be active together with this
option. Both the \fI\-\-doff\fR and/or \fI\-\-uoff\fR options can be used
with this option.
.TP
-\fB\-T\fR, \fB\-\-timeout\fR=\fISEC\fR
-where \fISEC\fR is a timeout value (in seconds) for foreground self\-test
+\fB\-T\fR, \fB\-\-timeout\fR=\fISECS\fR
+where \fISECS\fR is a timeout value (in seconds) for foreground self\-test
operations. The default value is 7200 seconds (2 hours) and any values
-of \fISEC\fR less than the default are ignored.
+of \fISECS\fR less than the default are ignored.
.TP
\fB\-u\fR, \fB\-\-uoff\fR
set the Unit Offline (UnitOffL) bit (default is clear). Only significant
@@ -254,9 +254,9 @@ The \fI\-s=ST\fR option should not be active together with this option.
Both the \fI\-doff\fR and/or \fI\-uoff\fR options can be used with this
option.
.TP
-\fB\-T\fR=\fISEC\fR
-where \fISEC\fR is a timeout value (in seconds) for foreground self\-test
-operations. See the \fI\-\-timeout=SEC\fR option above.
+\fB\-T\fR=\fISECS\fR
+where \fISECS\fR is a timeout value (in seconds) for foreground self\-test
+operations. See the \fI\-\-timeout=SECS\fR option above.
.TP
\fB\-uoff\fR
set the Unit Offline (UnitOffL) bit (default is clear). Equivalent to
@@ -292,7 +292,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2003\-2017 Douglas Gilbert
+Copyright \(co 2003\-2018 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_sync.8 b/doc/sg_sync.8
index 233a3f2d..64d3e479 100644
--- a/doc/sg_sync.8
+++ b/doc/sg_sync.8
@@ -1,11 +1,11 @@
-.TH SG_SYNC "8" "September 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_SYNC "8" "May 2018" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_sync \- send SCSI SYNCHRONIZE CACHE command
.SH SYNOPSIS
.B sg_sync
[\fI\-\-16\fR] [\fI\-\-count=COUNT\fR] [\fI\-\-group=GN\fR]
[\fI\-\-help\fR] [\fI\-\-immed\fR] [\fI\-\-lba=LBA\fR] [\fI\-\-sync\-nv\fR]
-[\fI\-\-timeout=SEC\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
+[\fI\-\-timeout=SECS\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -58,8 +58,8 @@ option (or if there is no non\-volatile cache in the device) the
synchronization is with the medium. The SYNC_NV bit was made obsolete in
SBC\-3 revision 35d.
.TP
-\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
-where \fISEC\fR is the number of seconds the OS allows the SYNCHRONIZE
+\fB\-t\fR, \fB\-\-timeout\fR=\fISECS\fR
+where \fISECS\fR is the number of seconds the OS allows the SYNCHRONIZE
CACHE(16) to complete before it tries to cancel the command. Cancelling
commands (typically with the task management function "abort task") is
best avoided. Note this option is only active together with the \fI\-\-16\fR
@@ -89,7 +89,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2004\-2017 Douglas Gilbert
+Copyright \(co 2004\-2018 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_timestamp.8 b/doc/sg_timestamp.8
index 36fa55f7..3dd076da 100644
--- a/doc/sg_timestamp.8
+++ b/doc/sg_timestamp.8
@@ -5,7 +5,7 @@ sg_timestamp \- report or set timestamp on SCSI device
.B sg_timestamp
[\fI\-\-elapsed\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
[\fI\-\-milliseconds=MS\fR] [\fI\-\-no\-timestamp\fR] [\fI\-\-origin\fR]
-[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-seconds=SEC\fR] [\fI\-\-srep\fR]
+[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-seconds=SECS\fR] [\fI\-\-srep\fR]
[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -14,7 +14,7 @@ Sends a SCSI REPORT TIMESTAMP or SET TIMESTAMP command to the \fIDEVICE\fR.
These commands are found in the SPC\-5 draft standard revision
7 (spc5r07.pdf).
.PP
-If either the \fI\-\-milliseconds=MS\fR or \fI\-\-seconds=SEC\fR option is
+If either the \fI\-\-milliseconds=MS\fR or \fI\-\-seconds=SECS\fR option is
given (and both can't be given) then the SET TIMESTAMP command is sent;
otherwise the REPORT TIMESTAMP command is sent.
.PP
@@ -78,9 +78,9 @@ verbose messages are output to stderr.
open the \fIDEVICE\fR read\-only. The default action is to open the
\fIDEVICE\fR read\-write.
.TP
-\fB\-s\fR, \fB\-\-seconds\fR=\fISEC\fR
-where \fISEC\fR is the number of seconds since 1970\-01\-01 00:00:00 UTC
-to set in the \fIDEVICE\fR with the SCSI SET TIMESTAMP command. \fISEC\fR
+\fB\-s\fR, \fB\-\-seconds\fR=\fISECS\fR
+where \fISECS\fR is the number of seconds since 1970\-01\-01 00:00:00 UTC
+to set in the \fIDEVICE\fR with the SCSI SET TIMESTAMP command. \fISECS\fR
is multiplied by 1000 before being used in the SET TIMESTAMP command.
.TP
\fB\-S\fR, \fB\-\-srep\fR
diff --git a/include/sg_lib.h b/include/sg_lib.h
index 7ea24b3f..b4bac4b1 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -14,8 +14,8 @@
* The intention is to keep this file and the related sg_lib.c file
* as open source and encourage their unencumbered use.
*
- * Current version number is in the sg_lib.c file and can be accessed
- * with the sg_lib_version() function.
+ * Current version number of this library is in the sg_lib_data.c file and
+ * can be accessed with the sg_lib_version() function.
*/
@@ -27,7 +27,7 @@
* http://www.t10.org . Virtually all devices in the Linux SCSI subsystem
* utilize SCSI command sets. Many devices in other Linux device subsystems
* utilize SCSI command sets either natively or via emulation (e.g. a
- * parallel ATA disk in a USB enclosure).
+ * SATA disk in a USB enclosure).
*/
#include <stdio.h>
@@ -391,7 +391,6 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char * b);
/* Utilities can use these exit status values for syntax errors and
* file (device node) problems (e.g. not found or permissions). */
#define SG_LIB_SYNTAX_ERROR 1 /* command line syntax problem */
-#define SG_LIB_FILE_ERROR 15 /* device or other file problem */
/* The sg_err_category_sense() function returns one of the following.
* These may be used as exit status values (from a process). Notice that
@@ -417,6 +416,7 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char * b);
/* [sk,asc,ascq: 0xb,! 0x10,*] */
#define SG_LIB_CAT_MISCOMPARE 14 /* sense key, probably verify */
/* [sk,asc,ascq: 0xe,*,*] */
+#define SG_LIB_FILE_ERROR 15 /* device or other file problem */
#define SG_LIB_CAT_NO_SENSE 20 /* sense data with key of "no sense" */
/* [sk,asc,ascq: 0x0,*,*] */
#define SG_LIB_CAT_RECOVERED 21 /* Successful command after recovered err */
@@ -435,17 +435,21 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char * b);
#define SG_LIB_CAT_TASK_ABORTED 29 /* SCSI status, this command aborted by? */
#define SG_LIB_CAT_PROTECTION 40 /* subset of aborted command (for PI, DIF) */
/* [sk,asc,ascq: 0xb,0x10,*] */
+/* 47: flock error in ddpt */
#define SG_LIB_NVME_STATUS 48 /* NVMe Status Field (SF) other than 0 */
#define SG_LIB_WILD_RESID 49 /* Residual value for data-in transfer of a */
/* SCSI command is nonsensical */
#define SG_LIB_OS_BASE_ERR 50 /* in Linux: values found in: */
/* include/uapi/asm-generic/errno-base.h */
/* Example: ENOMEM reported as 62 (=50+12) */
+ /* if errno > 46 then use this value */
+/* 51-->96 set aside for Unix errno values shifted by SG_LIB_OS_BASE_ERR */
#define SG_LIB_CAT_MALFORMED 97 /* Response to SCSI command malformed */
#define SG_LIB_CAT_SENSE 98 /* Something else is in the sense buffer */
#define SG_LIB_CAT_OTHER 99 /* Some other error/warning has occurred */
/* (e.g. a transport or driver error) */
-#define SG_LIB_UNUSED_ABOVE 99 /* Put extra errors in holes below this */
+/* 100 to 120 (inclusive) used by ddpt */
+#define SG_LIB_UNUSED_ABOVE 120 /* Put extra errors in holes below this */
/* Returns a SG_LIB_CAT_* value. If cannot decode sense_buffer or a less
* common sense key then return SG_LIB_CAT_SENSE .*/
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index ad5b8222..39278f98 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -17,7 +17,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "2.45 20180514";/* spc5r19, sbc4r15 */
+const char * sg_lib_version_str = "2.46 20180516";/* spc5r19, sbc4r15 */
/* indexed by pdt; those that map to own index do not decay */
diff --git a/src/sg_format.c b/src/sg_format.c
index eb0ad798..e447bdc1 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -37,14 +37,17 @@
#include "sg_pr2serr.h"
#include "sg_pt.h"
-static const char * version_str = "1.47 20180512";
+static const char * version_str = "1.49 20180519";
#define RW_ERROR_RECOVERY_PAGE 1 /* can give alternate with --mode=MP */
#define SHORT_TIMEOUT 20 /* 20 seconds unless --wait given */
#define FORMAT_TIMEOUT (20 * 3600) /* 20 hours ! */
-/* Seagate ST32000444SS 2TB disk takes 9.5 hours, now there are 4TB disks */
+#define FOUR_TBYTE (4LL * 1000 * 1000 * 1000 * 1000)
+#define LONG_FORMAT_TIMEOUT (40 * 3600) /* 40 hours */
+#define EIGHT_TBYTE (FOUR_TBYTE * 2)
+#define VLONG_FORMAT_TIMEOUT (80 * 3600) /* 3 days, 8 hours */
#define POLL_DURATION_SECS 60
#define DEF_POLL_TYPE_RS false /* false -> test unit ready;
@@ -92,9 +95,10 @@ struct opts_t {
int pie; /* -q value */
int sec_init; /* -S */
int tape; /* -T <format>, def: -1 */
- int timeout; /* -m SEC, def: depends on IMMED bit */
+ int timeout; /* -m SECS, def: depends on IMMED bit */
int verbose; /* -v */
int64_t blk_count; /* -c value */
+ int64_t total_byte_count; /* from READ CAPACITY command */
const char * device_name;
};
@@ -150,7 +154,7 @@ usage()
" [--poll=PT] [--quick] [--resize] [--rto_req] "
"[--security]\n"
" [--six] [--size=SIZE] [--tape=FM] "
- "[--timeout=SEC] [--verbose]\n"
+ "[--timeout=SECS] [--verbose]\n"
" [--verify] [--version] [--wait] DEVICE\n"
" where:\n"
" --cmplst=0|1\n"
@@ -211,7 +215,7 @@ usage()
" --tape=FM|-T FM request FORMAT MEDIUM with FORMAT "
"field set\n"
" to FM (def: 0 --> default format)\n"
- " --timeout=SEC|-m SEC FORMAT UNIT/MEDIUM command "
+ " --timeout=SECS|-m SECS FORMAT UNIT/MEDIUM command "
"timeout in seconds\n"
" --verbose|-v increase verbosity\n"
" --verify|-y sets VERIFY bit in FORMAT MEDIUM (tape)\n"
@@ -290,20 +294,27 @@ sg_ll_format_medium(int sg_fd, bool verify, bool immed, int format,
static int
scsi_format_unit(int fd, const struct opts_t * op)
{
- bool need_hdr, longlist;
+ bool need_hdr, longlist, ip_desc;
bool immed = ! op->fwait;
- bool ip_desc;
- int res, progress, pr, rem, verb, fmt_pl_sz, off, resp_len;
- int timeout;
+ int res, progress, pr, rem, verb, fmt_pl_sz, off, resp_len, timeout;
const int SH_FORMAT_HEADER_SZ = 4;
const int LO_FORMAT_HEADER_SZ = 8;
- const char INIT_PATTERN_DESC_SZ = 4;
+ const int INIT_PATTERN_DESC_SZ = 4;
uint8_t fmt_pl[LO_FORMAT_HEADER_SZ + INIT_PATTERN_DESC_SZ];
uint8_t reqSense[MAX_BUFF_SZ];
char b[80];
memset(fmt_pl, 0, sizeof(fmt_pl));
- timeout = (immed ? SHORT_TIMEOUT : FORMAT_TIMEOUT);
+ if (immed)
+ timeout = SHORT_TIMEOUT;
+ else {
+ if (op->total_byte_count > EIGHT_TBYTE)
+ timeout = VLONG_FORMAT_TIMEOUT;
+ else if (op->total_byte_count > FOUR_TBYTE)
+ timeout = LONG_FORMAT_TIMEOUT;
+ else
+ timeout = FORMAT_TIMEOUT;
+ }
if (op->timeout > timeout)
timeout = op->timeout;
longlist = (op->pie > 0);
@@ -332,13 +343,20 @@ scsi_format_unit(int fd, const struct opts_t * op)
res = 0;
pr2serr("Due to --dry-run option bypassing FORMAT UNIT "
"command\n");
- } else {
+ if (op->verbose) {
+ pr2serr("FU would have received: fmt_pl: ");
+ hex2stderr(fmt_pl, sizeof(fmt_pl), -1);
+ pr2serr(" fmtpinfo=0x%x, longlist=%d, need_hdr=%d, "
+ "cmplst=%d, ffmt=%d, timeout=%d\n",
+ op->fmtpinfo, longlist, need_hdr, op->cmplst,
+ op->ffmt, timeout);
+ }
+ } else
res = sg_ll_format_unit_v2(fd, op->fmtpinfo, longlist,
need_hdr/* FMTDATA*/, op->cmplst,
0 /* DEFECT_LIST_FORMAT */, op->ffmt,
timeout, fmt_pl, fmt_pl_sz, true,
op->verbose);
- }
if (res) {
sg_get_category_sense_str(res, sizeof(b), b, op->verbose);
pr2serr("Format unit command: %s\n", b);
@@ -457,7 +475,16 @@ scsi_format_medium(int fd, const struct opts_t * op)
uint8_t reqSense[MAX_BUFF_SZ];
char b[80];
- timeout = (immed ? SHORT_TIMEOUT : FORMAT_TIMEOUT);
+ if (immed)
+ timeout = SHORT_TIMEOUT;
+ else {
+ if (op->total_byte_count > EIGHT_TBYTE)
+ timeout = VLONG_FORMAT_TIMEOUT;
+ else if (op->total_byte_count > FOUR_TBYTE)
+ timeout = LONG_FORMAT_TIMEOUT;
+ else
+ timeout = FORMAT_TIMEOUT;
+ }
if (op->timeout > timeout)
timeout = op->timeout;
if (op->dry_run) {
@@ -718,12 +745,13 @@ print_dev_id(int fd, uint8_t * sinq_resp, int max_rlen,
/* Returns block size or -2 if do_16==0 and the number of blocks is too
* big, or returns -1 for other error. */
static int
-print_read_cap(int fd, const struct opts_t * op)
+print_read_cap(int fd, struct opts_t * op)
{
int res;
uint8_t resp_buff[RCAP_REPLY_LEN];
unsigned int last_blk_addr, block_size;
uint64_t llast_blk_addr;
+ int64_t ll;
char b[80];
if (op->do_rcap16) {
@@ -750,6 +778,9 @@ print_read_cap(int fd, const struct opts_t * op)
llast_blk_addr + 1);
printf(" Logical block size=%u bytes\n",
block_size);
+ ll = (int64_t)(llast_blk_addr + 1) * block_size;
+ if (ll > op->total_byte_count)
+ op->total_byte_count = ll;
return (int)block_size;
}
} else {
@@ -770,6 +801,9 @@ print_read_cap(int fd, const struct opts_t * op)
last_blk_addr + 1);
printf(" Logical block size=%u bytes\n",
block_size);
+ ll = (int64_t)(last_blk_addr + 1) * block_size;
+ if (ll > op->total_byte_count)
+ op->total_byte_count = ll;
return (int)block_size;
}
}
@@ -788,6 +822,7 @@ main(int argc, char **argv)
int resid = 0;
int ret = 0;
uint64_t ull;
+ int64_t ll;
struct opts_t * op;
uint8_t inq_resp[SAFE_STD_INQ_RESP_LEN];
struct opts_t opts;
@@ -1158,6 +1193,9 @@ again_with_long_lba:
printf(" Number of blocks=%" PRIu64 " [0x%" PRIx64 "]\n",
ull, ull);
printf(" Block size=%d [0x%x]\n", bd_blk_len, bd_blk_len);
+ ll = (int64_t)ull * bd_blk_len;
+ if (ll > op->total_byte_count)
+ op->total_byte_count = ll;
} else {
printf(" No block descriptors present\n");
prob = true;
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 85dab11a..82874ad2 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -49,7 +49,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * version_str = "1.93 20180425"; /* SPC-5 rev 19 */
+static const char * version_str = "1.94 20180519"; /* SPC-5 rev 19 */
/* INQUIRY notes:
* It is recommended that the initial allocation length given to a
@@ -4048,12 +4048,15 @@ show_nvme_id_ctl(const uint8_t *dinp, const char *dev_name, int do_long)
printf(" FGUID: 0x0\n");
printf(" Controller ID: 0x%x\n", sg_get_unaligned_le16(dinp + 78));
if (do_long) { /* Bytes 240 to 255 are reserved for NVME-MI */
- printf(" NVMe Enclosure: %d\n", !! (0x2 & dinp[253]));
- printf(" NVMe Storage device: %d\n", !! (0x1 & dinp[253]));
- printf(" Management endpoint capabilities, over a PCIe port: %d\n",
+ printf(" NVMe Management Interface [MI] settings:\n");
+ printf(" Enclosure: %d [NVMEE]\n", !! (0x2 & dinp[253]));
+ printf(" NVMe Storage device: %d [NVMESD]\n",
+ !! (0x1 & dinp[253]));
+ printf(" Management endpoint capabilities, over a PCIe port: %d "
+ "[PCIEME]\n",
!! (0x2 & dinp[255]));
- printf(" Management endpoint capabilities, over a SMBus/I2C port: "
- "%d\n", !! (0x1 & dinp[255]));
+ printf(" Management endpoint capabilities, over a SMBus/I2C port: "
+ "%d [SMBUSME]\n", !! (0x1 & dinp[255]));
}
printf(" Number of namespaces: %u\n", max_nsid);
sz1 = sg_get_unaligned_le64(dinp + 280); /* lower 64 bits */
@@ -4186,7 +4189,7 @@ skip1:
goto fini;
if (nsid > 0) {
if (! (op->do_raw || (op->do_hex > 2))) {
- printf(" Namespace %u (derived from device name):\n", nsid);
+ printf(" Namespace %u (deduced from device name):\n", nsid);
if (nsid > max_nsid)
pr2serr("NSID from device (%u) should not exceed number of "
"namespaces (%u)\n", nsid, max_nsid);
diff --git a/src/sg_raw.c b/src/sg_raw.c
index d480e6d0..209499c1 100644
--- a/src/sg_raw.c
+++ b/src/sg_raw.c
@@ -37,7 +37,7 @@
#include "sg_pr2serr.h"
#include "sg_unaligned.h"
-#define SG_RAW_VERSION "0.4.25 (2018-04-25)"
+#define SG_RAW_VERSION "0.4.26 (2018-05-19)"
#define DEFAULT_TIMEOUT 20
#define MIN_SCSI_CDBSZ 6
@@ -138,7 +138,7 @@ usage()
" --skip=KLEN|-k KLEN Skip the first KLEN bytes when "
"reading\n"
" data to send (default: 0)\n"
- " --timeout=SEC|-t SEC Timeout in seconds (default: 20)\n"
+ " --timeout=SECS|-t SECS Timeout in seconds (default: 20)\n"
" --verbose|-v Increase verbosity\n"
" --version|-V Show version information and exit\n"
"\n"
diff --git a/src/sg_readcap.c b/src/sg_readcap.c
index ac0b96e1..92d87b45 100644
--- a/src/sg_readcap.c
+++ b/src/sg_readcap.c
@@ -34,7 +34,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "4.00 20180302";
+static const char * version_str = "4.01 20180519";
#define ME "sg_readcap: "
@@ -509,11 +509,19 @@ main(int argc, char * argv[])
printf("Hence:\n");
#ifdef SG_LIB_MINGW
printf(" Device size: %" PRIu64 " bytes, %g MiB, %g "
- "GB\n", total_sz, sz_mb, sz_gb);
+ "GB", total_sz, sz_mb, sz_gb);
#else
printf(" Device size: %" PRIu64 " bytes, %.1f MiB, "
- "%.2f GB\n", total_sz, sz_mb, sz_gb);
+ "%.2f GB", total_sz, sz_mb, sz_gb);
#endif
+ if (sz_gb > 2000) {
+#ifdef SG_LIB_MINGW
+ printf(", %g TB", sz_gb / 1000);
+#else
+ printf(", %.2f TB", sz_gb / 1000);
+#endif
+ }
+ printf("\n");
}
goto fini;
} else {
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index aaa98c04..05c2ee3c 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -31,7 +31,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.08 20180515";
+static const char * version_str = "1.09 20180519";
/* Not all environments support the Unix sleep() */
#if defined(MSC_VER) || defined(__MINGW32__)
@@ -70,6 +70,8 @@ static struct option long_options[] = {
{"count", required_argument, 0, 'c'},
{"crypto", no_argument, 0, 'C'},
{"desc", no_argument, 0, 'd'},
+ {"dry-run", no_argument, 0, 'D'},
+ {"dry_run", no_argument, 0, 'D'},
{"early", no_argument, 0, 'e'},
{"fail", no_argument, 0, 'F'},
{"help", no_argument, 0, 'h'},
@@ -92,6 +94,7 @@ struct opts_t {
bool block;
bool crypto;
bool desc;
+ bool dry_run;
bool early;
bool fail;
bool invert;
@@ -113,13 +116,14 @@ static void
usage()
{
pr2serr("Usage: sg_sanitize [--ause] [--block] [--count=OC] [--crypto] "
- "[--early]\n"
- " [--fail] [--help] [--invert] [--ipl=LEN] "
- "[--overwrite]\n"
- " [--pattern=PF] [--quick] [--test=TE] "
- "[--timeout=SEC]\n"
- " [--verbose] [--version] [--wait] [--zero] "
- "[--znr] DEVICE\n"
+ "[--dry-run]\n"
+ " [--early] [--fail] [--help] [--invert] "
+ "[--ipl=LEN]\n"
+ " [--overwrite] [--pattern=PF] [--quick] "
+ "[--test=TE]\n"
+ " [--timeout=SECS] [--verbose] [--version] "
+ "[--wait]\n"
+ " [--zero] [--znr] DEVICE\n"
" where:\n"
" --ause|-A set AUSE bit in cdb\n"
" --block|-B do BLOCK ERASE sanitize\n"
@@ -129,6 +133,8 @@ usage()
" --desc|-d polling request sense sets 'desc' "
"field\n"
" (def: clear 'desc' field)\n"
+ " --dry-run|-D to preparation but bypass SANITIZE "
+ "commnd\n"
" --early|-e exit once sanitize started (IMMED set "
"in cdb)\n"
" user can monitor progress with REQUEST "
@@ -149,7 +155,8 @@ usage()
" --test=TE|-T TE TE is placed in TEST field of "
"OVERWRITE\n"
" parameter list (def: 0)\n"
- " --timeout=SEC|-t SEC SANITIZE command timeout in seconds\n"
+ " --timeout=SECS|-t SECS SANITIZE command timeout in "
+ "seconds\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string then exit\n"
" --wait|-w wait for command to finish (could "
@@ -213,11 +220,15 @@ do_sanitize(int sg_fd, const struct opts_t * op, const void * param_lstp,
if (op->verbose > 2) {
if (param_lst_len > 0) {
pr2serr(" Parameter list contents:\n");
- hex2stderr((const uint8_t *)param_lstp, param_lst_len, 1);
+ hex2stderr((const uint8_t *)param_lstp, param_lst_len, -1);
}
pr2serr(" Sanitize command timeout: %d seconds\n", timeout);
}
}
+ if (op->dry_run) {
+ pr2serr("Due to --dry-run option, bypassing SANITIZE command\n");
+ return 0;
+ }
ptvp = construct_scsi_pt_obj();
if (NULL == ptvp) {
pr2serr("Sanitize: out of memory\n");
@@ -441,6 +452,7 @@ main(int argc, char * argv[])
char b[80];
uint8_t rsBuff[DEF_REQS_RESP_LEN];
uint8_t * wBuff = NULL;
+ uint8_t * free_wBuff = NULL;
struct opts_t opts;
struct opts_t * op;
struct stat a_stat;
@@ -452,8 +464,8 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "ABc:CdeFhi:IOp:Qt:T:vVwzZ", long_options,
- &option_index);
+ c = getopt_long(argc, argv, "ABc:CdDeFhi:IOp:Qt:T:vVwzZ",
+ long_options, &option_index);
if (c == -1)
break;
@@ -477,6 +489,9 @@ main(int argc, char * argv[])
case 'd':
op->desc = true;
break;
+ case 'D':
+ op->dry_run = true;
+ break;
case 'e':
op->early = true;
break;
@@ -509,7 +524,7 @@ main(int argc, char * argv[])
case 't':
op->timeout = sg_get_num(optarg);
if (op->timeout < 0) {
- pr2serr("bad argument to '--timeout=SEC', want 0 or more\n");
+ pr2serr("bad argument to '--timeout=SECS', want 0 or more\n");
return SG_LIB_SYNTAX_ERROR;
}
break;
@@ -621,7 +636,7 @@ main(int argc, char * argv[])
if (op->overwrite) {
param_lst_len = op->ipl + 4;
- wBuff = (uint8_t*)calloc(op->ipl + 4, 1);
+ wBuff = (uint8_t*)sg_memalign(op->ipl + 4, 0, &free_wBuff, false);
if (NULL == wBuff) {
pr2serr("unable to allocate %d bytes of memory with calloc()\n",
op->ipl + 4);
@@ -697,6 +712,10 @@ main(int argc, char * argv[])
if ((0 == ret) && (! op->early) && (! op->wait)) {
for (k = 0; ;++k) { /* unbounded, exits via break */
+ if (op->dry_run && (k > 0)) {
+ pr2serr("Due to --dry-run option, leave poll loop\n");
+ break;
+ }
sleep_for(POLL_DURATION_SECS);
memset(rsBuff, 0x0, sizeof(rsBuff));
res = sg_ll_request_sense(sg_fd, op->desc, rsBuff, sizeof(rsBuff),
@@ -726,7 +745,7 @@ main(int argc, char * argv[])
resp_len = rsBuff[7] + 8;
if (vb > 2) {
pr2serr("Parameter data in hex\n");
- hex2stderr(rsBuff, resp_len, 1);
+ hex2stderr(rsBuff, resp_len, -1);
}
progress = -1;
sg_get_sense_progress_fld(rsBuff, resp_len, &progress);
@@ -744,8 +763,8 @@ main(int argc, char * argv[])
}
err_out:
- if (wBuff)
- free(wBuff);
+ if (free_wBuff)
+ free(free_wBuff);
if (sg_fd >= 0) {
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
diff --git a/src/sg_senddiag.c b/src/sg_senddiag.c
index 410e1409..3034e376 100644
--- a/src/sg_senddiag.c
+++ b/src/sg_senddiag.c
@@ -31,7 +31,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "0.60 20180325";
+static const char * version_str = "0.61 20180519";
#define ME "sg_senddiag: "
@@ -87,7 +87,7 @@ usage()
"[--list]\n"
" [--maxlen=LEN] [--page=PG] [--pf] "
"[--raw=H,H...]\n"
- " [--selftest=ST] [--test] [--timeout=SEC] "
+ " [--selftest=ST] [--test] [--timeout=SECS] "
"[--uoff]\n"
" [--verbose] [--version] [DEVICE]\n"
" where:\n"
@@ -117,7 +117,7 @@ usage()
" 5->foreground short, 6->foreground "
"extended\n"
" --test|-t default self-test\n"
- " --timeout=SEC|-T SEC timeout for foreground self tests\n"
+ " --timeout=SECS|-T SECS timeout for foreground self tests\n"
" unit: second (def: 7200 seconds)\n"
" --uoff|-u unit offline (def: 0, only with '--test')\n"
" --verbose|-v increase verbosity\n"
@@ -133,7 +133,7 @@ usage_old()
{
printf("Usage: sg_senddiag [-doff] [-e] [-h] [-H] [-l] [-pf]"
" [-raw=H,H...]\n"
- " [-s=SF] [-t] [-T=SEC] [-uoff] [-v] [-V] "
+ " [-s=SF] [-t] [-T=SECS] [-uoff] [-v] [-V] "
"[DEVICE]\n"
" where:\n"
" -doff device online (def: 0, only with '-t')\n"
@@ -151,7 +151,7 @@ usage_old()
" 4->abort test\n"
" 5->foreground short, 6->foreground extended\n"
" -t default self-test\n"
- " -T SEC timeout for foreground self tests\n"
+ " -T SECS timeout for foreground self tests\n"
" -uoff unit offline (def: 0, only with '-t')\n"
" -v increase verbosity (print issued SCSI cmds)\n"
" -V output version string\n"
@@ -237,7 +237,7 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
case 'T':
n = sg_get_num(optarg);
if (n < 0) {
- pr2serr("bad argument to '--timeout=SEC'\n");
+ pr2serr("bad argument to '--timeout=SECS'\n");
return SG_LIB_SYNTAX_ERROR;
}
op->timeout = n;
@@ -364,7 +364,7 @@ old_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
} else if (0 == strncmp("T=", cp, 2)) {
num = sscanf(cp + 2, "%d", &n);
if ((1 != num) || (n < 0)) {
- printf("Bad page code after '-T=SEC' option\n");
+ printf("Bad page code after '-T=SECS' option\n");
usage_old();
return SG_LIB_SYNTAX_ERROR;
}
diff --git a/src/sg_sync.c b/src/sg_sync.c
index 23a26d5b..2ac1eb83 100644
--- a/src/sg_sync.c
+++ b/src/sg_sync.c
@@ -35,7 +35,7 @@
* (e.g. disks).
*/
-static const char * version_str = "1.21 20180514";
+static const char * version_str = "1.22 20180519";
#define SYNCHRONIZE_CACHE16_CMD 0x91
#define SYNCHRONIZE_CACHE16_CMDLEN 16
@@ -61,7 +61,7 @@ static void usage()
{
pr2serr("Usage: sg_sync [--16] [--count=COUNT] [--group=GN] [--help] "
"[--immed]\n"
- " [--lba=LBA] [--sync-nv] [--timeout=SEC] "
+ " [--lba=LBA] [--sync-nv] [--timeout=SECS] "
"[--verbose]\n"
" [--version] DEVICE\n"
" where:\n"
@@ -82,7 +82,7 @@ static void usage()
" --sync-nv|-s synchronize to non-volatile storage "
"(if distinct\n"
" from medium). Obsolete in sbc3r35d.\n"
- " --timeout=SEC|-t SEC command timeout in seconds, only "
+ " --timeout=SECS|-t SECS command timeout in seconds, only "
"active\n"
" if '--16' given (def: 60 seconds)\n"
" --verbose|-v increase verbosity\n"
diff --git a/src/sg_timestamp.c b/src/sg_timestamp.c
index 2049052c..51d7d7f4 100644
--- a/src/sg_timestamp.c
+++ b/src/sg_timestamp.c
@@ -35,7 +35,7 @@
* to the given SCSI device. Based on spc5r07.pdf .
*/
-static const char * version_str = "1.08 20180502";
+static const char * version_str = "1.09 20180519";
#define REP_TIMESTAMP_CMDLEN 12
#define SET_TIMESTAMP_CMDLEN 12
@@ -92,7 +92,7 @@ usage(int num)
"sg_timestamp [--elapsed] [--help] [--hex] [--milliseconds=MS]\n"
" [--no-timestamp] [--origin] [--raw] "
"[--readonly]\n"
- " [--seconds=SEC] [--srep] [--verbose] "
+ " [--seconds=SECS] [--srep] [--verbose] "
"[--version]\n"
" DEVICE\n"
);
@@ -120,7 +120,7 @@ usage(int num)
" binary\n"
" --readonly|-R open DEVICE read only (def: "
"read/write)\n"
- " --seconds=SEC|-s SEC set timestamp to SEC "
+ " --seconds=SECS|-s SECS set timestamp to SECS "
"seconds since\n"
" 1970-01-01 00:00:00 UTC\n"
" --srep|-S output Report timestamp in seconds "
@@ -131,7 +131,7 @@ usage(int num)
);
pr2serr("Performs a SCSI REPORT TIMESTAMP or SET TIMESTAMP command. "
"The timestamp\nis SET if either the --milliseconds=MS or "
- "--seconds=SEC option is given,\notherwise the existing "
+ "--seconds=SECS option is given,\notherwise the existing "
"timestamp is reported in milliseconds. The\nDEVICE stores "
"the timestamp as the number of milliseconds since power up\n"
"(or reset) or since 1970-01-01 00:00:00 UTC which also "
@@ -374,7 +374,7 @@ main(int argc, char * argv[])
case 's':
ll = sg_get_llnum(optarg);
if (-1 == ll) {
- pr2serr("bad argument to '--seconds=SEC'\n");
+ pr2serr("bad argument to '--seconds=SECS'\n");
return SG_LIB_SYNTAX_ERROR;
}
secs = (uint64_t)ll;
@@ -414,7 +414,7 @@ main(int argc, char * argv[])
}
if (do_set > 1) {
- pr2serr("either --milliseconds=MS or --seconds=SEC may be given, "
+ pr2serr("either --milliseconds=MS or --seconds=SECS may be given, "
"not both\n");
usage(1);
return SG_LIB_SYNTAX_ERROR;