aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2020-10-09 18:09:07 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2020-10-09 18:09:07 +0000
commit050aa4385fef1eb0ef515bdc97c47dc24858354a (patch)
treea61eada99c8bcb262a7670445430ce56fd66830e
parent20eb07694951b0760f741e7b74c0a363f8ed2b3b (diff)
downloadsg3_utils-050aa4385fef1eb0ef515bdc97c47dc24858354a.tar.gz
sg_dd: add 00,ff,random flags; sg_modes: document '-s' option
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@864 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog7
-rw-r--r--doc/sg3_utils.82
-rw-r--r--doc/sg_dd.890
-rw-r--r--doc/sg_modes.812
-rw-r--r--doc/sg_start.84
-rw-r--r--src/sg_dd.c140
-rw-r--r--src/sg_modes.c4
-rw-r--r--src/sg_start.c6
-rw-r--r--testing/sg_mrq_dd.cpp4
9 files changed, 186 insertions, 83 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f398e22..6d817281 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,17 +2,20 @@ 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.46 [20200927] [svn: r863]
+Changelog for sg3_utils-1.46 [20201009] [svn: r864]
- sg_rep_pip: report new provisioning initialization pattern cmd
- sg_turs: estimated time-to-ready [20-061r2]
- add --delay=MS option
- sg_requests: substantial cleanup
- - sg_dd: separate category for miscompare errors
+ - sg_dd: --verify : separate category for miscompare errors
+ - --verify : oflag=coe continue on miscompares, counts them
+ - add iflag=00,ff, random flags
- sg_get_elem_status: add ralwd bit sbc4r20a
- sg_write_x: add dld bits to write(32) [sbc4r19a]
- sg_rep_zones: print invalid write pointer LBA as -1 rather
than 16 "f"s
- sg_ses: use fan speed factor field for calculation [ses4r04]
+ - sg_modes: document '-s' option (same as '-6')
- sg_raw: increase maximum data-in and data-out buffer size
from 64 KB to 1 MB
- fix --cmdfile= handling
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index e2238285..1f0874a0 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,4 +1,4 @@
-.TH SG3_UTILS "8" "September 2020" "sg3_utils\-1.46" SG3_UTILS
+.TH SG3_UTILS "8" "October 2020" "sg3_utils\-1.46" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
diff --git a/doc/sg_dd.8 b/doc/sg_dd.8
index 7f4ed65b..90d707bc 100644
--- a/doc/sg_dd.8
+++ b/doc/sg_dd.8
@@ -1,4 +1,4 @@
-.TH SG_DD "8" "April 2020" "sg3_utils\-1.46" SG3_UTILS
+.TH SG_DD "8" "October 2020" "sg3_utils\-1.46" SG3_UTILS
.SH NAME
sg_dd \- copy data to and from files and devices, especially SCSI
devices
@@ -90,7 +90,7 @@ that a 4 byte block number may be exceeded or \fIBPT\fR is greater than
16 bits (65535), in which case it defaults to 16 byte SCSI commands).
.TP
\fBcoe\fR={0|1|2|3}
-set to 1 or more for continue on error. Only applies to errors on sg
+set to 1 or more for continue on error ('coe'). Only applies to errors on sg
devices or block devices with the 'sgio' flag set. Thus errors on other
files will stop sg_dd. Default is 0 which implies stop on any error. See
the 'coe' flag for more information.
@@ -231,13 +231,13 @@ be used with "oflag=sparse". \fIof=OFILE\fR must be given and \fIOFILE\fR
must be an sg device or a block device with "oflag=sgio" also given. Uses the
SCSI VERIFY command with the BYTCHK field set to 1. The VERIFY command is
used instead of WRITE when this option is given. There is no VERIFY(6)
-command.
+command. Stops on the first miscompare unless \fIoflag=coe\fR is given.
.TP
\fB\-V\fR, \fB\-\-version\fR
outputs version number information and exits.
.SH CONVERSIONS
-One or more conversions can be given to the "conv=" option. If more than
-one is given, they should be comma separated. sg_dd does not perform the
+One or more conversions can be given to the "conv=" option. If more than one
+is given, they should be comma separated. sg_dd does not perform the
traditional dd conversions (e.g. ASCII to EBCDIC). Recently added
conversions overlap somewhat with the flags so some conversions are
now supported by sg_dd.
@@ -264,40 +264,46 @@ functionality as sg_dd's "iflag=coe".
.SH FLAGS
Here is a list of flags and their meanings:
.TP
+00
+this flag is only active with \fIiflag=\fR and when given replaces
+\fIif=IFILE\fR. If both are given an error is generated. The input will
+be a stream of zeros, similar to using "if=/dev/zero" alone (but a little
+quicker).
+.TP
append
causes the O_APPEND flag to be added to the open of \fIOFILE\fR. For regular
-files this will lead to data appended to the end of any existing data.
-Cannot be used together with the \fIseek=SEEK\fR option as they conflict.
-The default action of this utility is to overwrite any existing data
-from the beginning of the file or, if \fISEEK\fR is given, starting at
-block \fISEEK\fR. Note that attempting to 'append' to a device file (e.g.
-a disk) will usually be ignored or may cause an error to be reported.
+files this will lead to data appended to the end of any existing data. Cannot
+be used together with the \fIseek=SEEK\fR option as they conflict. The default
+action of this utility is to overwrite any existing data from the beginning
+of the file or, if \fISEEK\fR is given, starting at block \fISEEK\fR. Note
+that attempting to 'append' to a device file (e.g. a disk) will usually be
+ignored or may cause an error to be reported.
.TP
coe
-continue on error. Only active for sg devices and block devices that
-have the 'sgio' flag set. 'iflag=coe oflag=coe' and 'coe=1' are
-equivalent. Use this flag twice (e.g. 'iflag=coe,coe') to have the
-same action as the 'coe=2'. A medium, hardware or blank check error
-while reading will re\-read blocks prior to the bad block, then try to
-recover the bad block, supplying zeros if that fails, and finally reread
-the blocks after the bad block. A medium, hardware or blank check error
-while writing is noted and ignored. The recovery of the bad block when
-reading uses the SCSI READ LONG command if 'coe' given twice or
-more (also with the command line option 'coe=2'). Further, the READ LONG
-will set its CORRCT bit if 'coe' given thrice. SCSI disks may automatically
-try and remap faulty sectors (see the AWRE and ARRE in the read write
-error recovery mode page (the sdparm utility can access and possibly change
-these attributes)). Errors occurring on other files types will stop sg_dd.
-Error messages are sent to stderr. This flag is similar
- o 'conv=noerror,sync' in the
+continue on error. Only active for sg devices and block devices that have
+the 'sgio' flag set. 'iflag=coe oflag=coe' and 'coe=1' are equivalent. Use
+this flag twice (e.g. 'iflag=coe,coe') to have the same action as the 'coe=2'.
+A medium, hardware or blank check error while reading will re\-read blocks
+prior to the bad block, then try to recover the bad block, supplying zeros
+if that fails, and finally re\-read the blocks after the bad block. A medium,
+hardware or blank check error while writing is noted and ignored. A miscompare
+sense key during a VERIFY command (i.e. \fI\-\-verify\fR given) is noted and
+ignored when 'oflag=coe'. The recovery of the bad block when reading uses the
+SCSI READ LONG command if 'coe' given twice or more (also with the command
+line option 'coe=2'). Further, the READ LONG will set its CORRCT bit if 'coe'
+given thrice. SCSI disks may automatically try and remap faulty sectors (see
+the AWRE and ARRE in the read write error recovery mode page (the sdparm
+utility can access and possibly change these attributes)). Errors occurring on
+other files types will stop sg_dd. Error messages are sent to stderr. This
+flag is similar to 'conv=noerror,sync' in the
.B dd(1)
utility. See note about READ LONG below.
.TP
dio
-request the sg device node associated with this flag does direct IO.
-If direct IO is not available, falls back to indirect IO and notes
-this at completion. If direct IO is selected and /proc/scsi/sg/allow_dio
-has the value of 0 then a warning is issued (and indirect IO is performed).
+request the sg device node associated with this flag does direct IO. If direct
+IO is not available, falls back to indirect IO and notes this at completion.
+If direct IO is selected and /proc/scsi/sg/allow_dio has the value of 0 then a
+warning is issued (and indirect IO is performed).
.TP
direct
causes the O_DIRECT flag to be added to the open of \fIIFILE\fR and/or
@@ -309,10 +315,9 @@ commands are issued via the SG_IO ioctl.
.TP
dpo
set the DPO bit (disable page out) in SCSI READ and WRITE commands. Not
-supported for 6 byte cdb variants of READ and WRITE. Indicates that
-data is unlikely to be required to stay in device (e.g. disk) cache.
-May speed media copy and/or cause a media copy to have less impact
-on other device users.
+supported for 6 byte cdb variants of READ and WRITE. Indicates that data is
+unlikely to be required to stay in device (e.g. disk) cache. May speed media
+copy and/or cause a media copy to have less impact on other device users.
.TP
dsync
causes the O_SYNC flag to be added to the open of \fIIFILE\fR and/or
@@ -324,6 +329,11 @@ excl
causes the O_EXCL flag to be added to the open of \fIIFILE\fR and/or
\fIOFILE\fR.
.TP
+ff
+this flag is only active with \fIiflag=\fR and when given replaces
+\fIif=IFILE\fR. If both are given an error is generated. The input will
+be a stream of 0xff bytes (or all bits set).
+.TP
flock
after opening the associated file (i.e. \fIIFILE\fR and/or \fIOFILE\fR)
an attempt is made to get an advisory exclusive lock with the flock()
@@ -345,6 +355,16 @@ the file buffer with recently read or written blocks.
null
has no affect, just a placeholder.
.TP
+random
+this flag is only active with \fIiflag=\fR and when given replaces
+\fIif=IFILE\fR. If both are given an error is generated. The input will
+be a stream of pseudo random bytes. The Linux getrandom(2) system call is
+used to create a seed and thereadter mrand48_r(3) is used to generate a
+pseudo random sequence, 4 bytes at a time. The quality of the randomness
+can be viewed with the ent(1) utility. This is not a high quality random
+number generator, it is built for speed, not quality. One application is
+checking the correctness of the copy and verify operations of this utility.
+.TP
sgio
causes block devices to be accessed via the SG_IO ioctl rather than
standard UNIX read() and write() commands. When the SG_IO ioctl is
diff --git a/doc/sg_modes.8 b/doc/sg_modes.8
index d68bc409..162f5f93 100644
--- a/doc/sg_modes.8
+++ b/doc/sg_modes.8
@@ -1,4 +1,4 @@
-.TH SG_MODES "8" "January 2020" "sg3_utils\-1.45" SG3_UTILS
+.TH SG_MODES "8" "September 2020" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg_modes \- reads mode pages with SCSI MODE SENSE command
.SH SYNOPSIS
@@ -171,11 +171,11 @@ the sg_wr_mode(8) utility.
open \fIDEVICE\fR in "read\-write" mode. Default is to open it in read\-only
mode.
.TP
-\fB\-6\fR, \fB\-\-six\fR
-by default this utility sends a 10 byte MODE SENSE command to
-the \fIDEVICE\fR. However some SCSI devices only support 6 byte MODE SENSE
-commands (e.g. SCSI\-2 tape drives). This parameter forces the use
-of 6 byte MODE SENSE commands.
+\fB\-6\fR, \fB\-s\fR, \fB\-\-six\fR
+by default this utility sends a 10 byte MODE SENSE command to the
+\fIDEVICE\fR. However some SCSI devices only support 6 byte MODE SENSE
+commands (e.g. SCSI\-2 tape drives). This parameter forces the use of 6
+byte MODE SENSE commands.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase level of verbosity. Can be used multiple times.
diff --git a/doc/sg_start.8 b/doc/sg_start.8
index d22a0171..c9a44491 100644
--- a/doc/sg_start.8
+++ b/doc/sg_start.8
@@ -1,4 +1,4 @@
-.TH SG_START "8" "October 2017" "sg3_utils\-1.43" SG3_UTILS
+.TH SG_START "8" "September 2020" "sg3_utils\-1.43" SG3_UTILS
.SH NAME
sg_start \- send SCSI START STOP UNIT command: start, stop, load or eject
medium
@@ -264,7 +264,7 @@ Written by K. Garloff and D. Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2002\-2017 Kurt Garloff, Douglas Gilbert
+Copyright \(co 2002\-2020 Kurt Garloff, 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/src/sg_dd.c b/src/sg_dd.c
index a224ef31..a3e9022a 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -50,6 +50,7 @@
#include <sys/time.h>
#include <sys/file.h>
#include <sys/sysmacros.h>
+#include <sys/random.h> /* for getrandom() system call */
#ifndef major
#include <sys/types.h>
#endif
@@ -66,7 +67,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "6.17 20200923";
+static const char * version_str = "6.19 20201008";
#define ME "sg_dd: "
@@ -115,10 +116,14 @@ static const char * version_str = "6.17 20200923";
#define FT_BLOCK 32 /* filetype is block device */
#define FT_FIFO 64 /* filetype is a fifo (name pipe) */
#define FT_NVME 128 /* NVMe char device (e.g. /dev/nvme2) */
-#define FT_ERROR 256 /* couldn't "stat" file */
+#define FT_RANDOM_0_FF 256 /* iflag=00, iflag=ff and iflag=random
+ overriding if=IFILE */
+#define FT_ERROR 512 /* couldn't "stat" file */
#define DEV_NULL_MINOR_NUM 3
+#define SG_DD_BYPASS 999 /* failed but coe set */
+
/* If platform does not support O_DIRECT then define it harmlessly */
#ifndef O_DIRECT
#define O_DIRECT 0
@@ -166,6 +171,9 @@ static uint8_t * zeros_buff = NULL;
static uint8_t * free_zeros_buff = NULL;
static int read_long_blk_inc = READ_LONG_DEF_BLK_INC;
+static long seed;
+static struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */
+
static const char * proc_allow_dio = "/proc/scsi/sg/allow_dio";
struct flags_t {
@@ -176,9 +184,12 @@ struct flags_t {
bool dsync;
bool excl;
bool flock;
+ bool ff;
bool fua;
+ bool random;
bool sgio;
bool sparse;
+ bool zero;
int cdbsz;
int coe;
int nocache;
@@ -447,9 +458,9 @@ usage()
" ibs input logical block size (if given must be same "
"as 'bs=')\n"
" if file or device to read from (def: stdin)\n"
- " iflag comma separated list from: [coe,dio,direct,"
- "dpo,dsync,excl,\n"
- " flock,fua,nocache,null,sgio]\n"
+ " iflag comma separated list from: [00,coe,dio,direct,"
+ "dpo,dsync,\n"
+ " excl,ff,flock,fua,nocache,null,random,sgio]\n"
" obs output logical block size (if given must be "
"same as 'bs=')\n"
" odir 1->use O_DIRECT when opening block dev, "
@@ -665,13 +676,13 @@ sg_build_scsi_cdb(uint8_t * cdbp, int cdb_sz, unsigned int blocks,
}
-/* 0 -> successful, SG_LIB_SYNTAX_ERROR -> unable to build cdb,
- SG_LIB_CAT_UNIT_ATTENTION -> try again,
- SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> 'io_addrp' written to,
- SG_LIB_CAT_MEDIUM_HARD -> no info field,
- SG_LIB_CAT_NOT_READY, SG_LIB_CAT_ABORTED_COMMAND,
- -2 -> ENOMEM
- -1 other errors */
+/* Does SCSI READ on IFILE. Returns 0 -> successful,
+ * SG_LIB_SYNTAX_ERROR -> unable to build cdb,
+ * SG_LIB_CAT_UNIT_ATTENTION -> try again,
+ * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> 'io_addrp' written to,
+ * SG_LIB_CAT_MEDIUM_HARD -> no info field,
+ * SG_LIB_CAT_NOT_READY, SG_LIB_CAT_ABORTED_COMMAND,
+ * -2 -> ENOMEM, -1 other errors */
static int
sg_read_low(int sg_fd, uint8_t * buff, int blocks, int64_t from_block,
int bs, const struct flags_t * ifp, bool * diop,
@@ -811,10 +822,10 @@ sg_read_low(int sg_fd, uint8_t * buff, int blocks, int64_t from_block,
}
-/* 0 -> successful, SG_LIB_SYNTAX_ERROR -> unable to build cdb,
- SG_LIB_CAT_UNIT_ATTENTION -> try again, SG_LIB_CAT_NOT_READY,
- SG_LIB_CAT_MEDIUM_HARD, SG_LIB_CAT_ABORTED_COMMAND,
- -2 -> ENOMEM, -1 other errors */
+/* Does repeats associated with a SCSI READ on IFILE. Returns 0 -> successful,
+ * SG_LIB_SYNTAX_ERROR -> unable to build cdb, SG_LIB_CAT_UNIT_ATTENTION ->
+ * try again, SG_LIB_CAT_NOT_READY, SG_LIB_CAT_MEDIUM_HARD,
+ * SG_LIB_CAT_ABORTED_COMMAND, -2 -> ENOMEM, -1 other errors */
static int
sg_read(int sg_fd, uint8_t * buff, int blocks, int64_t from_block,
int bs, struct flags_t * ifp, bool * diop, int * blks_readp)
@@ -1077,11 +1088,11 @@ err_out:
}
-/* 0 -> successful, SG_LIB_SYNTAX_ERROR -> unable to build cdb,
+/* Does a SCSI WRITE or VERIFY (if do_verify set) on OFILE. Returns:
+ * 0 -> successful, SG_LIB_SYNTAX_ERROR -> unable to build cdb,
* SG_LIB_CAT_NOT_READY, SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_MEDIUM_HARD,
* SG_LIB_CAT_ABORTED_COMMAND, -2 -> recoverable (ENOMEM),
- * -1 -> unrecoverable error + others. Note: if do_verify is true then does
- * a VERIFY rather than a WRITE command. */
+ * -1 -> unrecoverable error + others. SG_DD_BYPASS -> failed but coe set. */
static int
sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block,
int bs, const struct flags_t * ofp, bool * diop)
@@ -1157,10 +1168,17 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block,
case SG_LIB_CAT_UNIT_ATTENTION:
sg_chk_n_print3(op_str, &io_hdr, verbose > 1);
return res;
- case SG_LIB_CAT_MISCOMPARE:
+ case SG_LIB_CAT_MISCOMPARE: /* must be VERIFY cpommand */
++miscompare_errs;
- pr2serr("VERIFY reports miscompare\n");
- return res;
+ if (ofp->coe) {
+ if (verbose > 1)
+ pr2serr(">> bypass due to miscompare: out blk=%" PRId64
+ " for %d blocks\n", to_block, blocks);
+ return SG_DD_BYPASS; /* fudge success */
+ } else {
+ pr2serr("VERIFY reports miscompare\n");
+ return res;
+ }
case SG_LIB_CAT_NOT_READY:
++unrecovered_errs;
pr2serr("device not ready (w)\n");
@@ -1172,9 +1190,10 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block,
sg_print_command_len(wrCmd, ofp->cdbsz);
++unrecovered_errs;
if (ofp->coe) {
- pr2serr(">> ignored errors for out blk=%" PRId64 " for %d "
- "bytes\n", to_block, bs * blocks);
- return 0; /* fudge success */
+ if (verbose > 1)
+ pr2serr(">> ignored errors for out blk=%" PRId64 " for %d "
+ "bytes\n", to_block, bs * blocks);
+ return SG_DD_BYPASS; /* fudge success */
} else
return res;
}
@@ -1234,7 +1253,9 @@ process_flags(const char * arg, struct flags_t * fp)
np = strchr(cp, ',');
if (np)
*np++ = '\0';
- if (0 == strcmp(cp, "append"))
+ if (0 == strcmp(cp, "00"))
+ fp->zero = true;
+ else if (0 == strcmp(cp, "append"))
fp->append = true;
else if (0 == strcmp(cp, "coe"))
++fp->coe;
@@ -1250,12 +1271,16 @@ process_flags(const char * arg, struct flags_t * fp)
fp->excl = true;
else if (0 == strcmp(cp, "flock"))
fp->flock = true;
+ else if (0 == strcmp(cp, "ff"))
+ fp->ff = true;
else if (0 == strcmp(cp, "fua"))
fp->fua = true;
else if (0 == strcmp(cp, "nocache"))
++fp->nocache;
else if (0 == strcmp(cp, "null"))
;
+ else if (0 == strcmp(cp, "random"))
+ fp->random = true;
else if (0 == strcmp(cp, "sgio"))
fp->sgio = true;
else if (0 == strcmp(cp, "sparse"))
@@ -1766,6 +1791,8 @@ main(int argc, char * argv[])
int64_t out_num_sect = -1;
char * key;
char * buf;
+ const char * ccp = NULL;
+ const char * cc2p;
uint8_t * wrkBuff = NULL;
uint8_t * wrkPos;
char inf[INOUTF_SZ];
@@ -2035,7 +2062,33 @@ main(int argc, char * argv[])
outfd = STDOUT_FILENO;
iflag.pdt = -1;
oflag.pdt = -1;
- if (inf[0] && ('-' != inf[0])) {
+ if (iflag.ff) {
+ ccp = "<0xff bytes>";
+ cc2p = "ff";
+ } else if (iflag.random) {
+ ssize_t ssz;
+
+ ccp = "<random>";
+ cc2p = "random";
+ ssz = getrandom(&seed, sizeof(seed), 0);
+ if (ssz < (ssize_t)sizeof(seed))
+ pr2serr("getrandom() failed, ret=%d\n", (int)ssz);
+ if (verbose > 1)
+ pr2serr("seed=%ld\n", seed);
+ srand48_r(seed, &drand);
+ } else if (iflag.zero) {
+ ccp = "<zero bytes>";
+ cc2p = "00";
+ }
+ if (ccp) {
+ if (inf[0]) {
+ pr2serr("iflag=%s and if=%s contradict\n", cc2p, inf);
+ return SG_LIB_CONTRADICT;
+ }
+ in_type = FT_RANDOM_0_FF;
+ strcpy(inf, ccp);
+ infd = -1;
+ } else if (inf[0] && ('-' != inf[0])) {
infd = open_if(inf, skip, bpt, &iflag, &in_type, verbose);
if (infd < 0)
return -infd;
@@ -2269,6 +2322,29 @@ main(int argc, char * argv[])
if (iflag.dio && (! dio_tmp))
dio_incomplete_count++;
}
+ } else if (FT_RANDOM_0_FF == in_type) {
+ res = blocks * blk_sz;
+ if (iflag.zero)
+ memset(wrkPos, 0, res);
+ else if (iflag.ff)
+ memset(wrkPos, 0xff, res);
+ else {
+ int kk, j;
+ const int jbump = sizeof(uint32_t);
+ long rn;
+ uint8_t * bp;
+
+ bp = wrkPos;
+ for (kk = 0; kk < blocks; ++kk, bp += blk_sz) {
+ for (j = 0; j < blk_sz; j += jbump) {
+ /* mrand48 takes uniformly from [-2^31, 2^31) */
+ mrand48_r(&drand, &rn);
+ *((uint32_t *)(bp + j)) = (uint32_t)rn;
+ }
+ }
+ }
+ bytes_read = res;
+ in_full += blocks;
} else {
while (((res = read(infd, wrkPos, blocks * blk_sz)) < 0) &&
((EINTR == errno) || (EAGAIN == errno) ||
@@ -2365,9 +2441,9 @@ main(int argc, char * argv[])
retries_tmp = oflag.retries;
first = true;
while (1) {
- ret = sg_write(outfd, wrkPos, blocks, seek, blk_sz,
- &oflag, &dio_tmp);
- if (0 == ret)
+ ret = sg_write(outfd, wrkPos, blocks, seek, blk_sz, &oflag,
+ &dio_tmp);
+ if ((0 == ret) || (SG_DD_BYPASS))
break;
if ((SG_LIB_CAT_NOT_READY == ret) ||
(SG_LIB_SYNTAX_ERROR == ret))
@@ -2414,7 +2490,9 @@ main(int argc, char * argv[])
break;
first = false;
}
- if (0 != ret) {
+ if (SG_DD_BYPASS == ret)
+ ret = 0; /* not bumping out_full */
+ else if (0 != ret) {
pr2serr("sg_write failed,%s seek=%" PRId64 "\n",
((-2 == ret) ? " try reducing bpt," : ""), seek);
break;
diff --git a/src/sg_modes.c b/src/sg_modes.c
index a6335cdb..6218a31b 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -32,7 +32,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.71 20200121";
+static const char * version_str = "1.72 20200930";
#define DEF_ALLOC_LEN (1024 * 4)
#define DEF_6_ALLOC_LEN 252
@@ -330,7 +330,7 @@ usage()
" hex (same result as '--raw --raw')\n"
" --readwrite|-w open DEVICE read-write (def: open "
"read-only)\n"
- " --six|-6 use MODE SENSE(6), by default uses MODE "
+ " --six|-6|-s use MODE SENSE(6), by default uses MODE "
"SENSE(10)\n"
" --verbose|-v increase verbosity\n"
" --old|-O use old interface (use as first option)\n"
diff --git a/src/sg_start.c b/src/sg_start.c
index ccf98aa6..bd098282 100644
--- a/src/sg_start.c
+++ b/src/sg_start.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1999-2018 D. Gilbert
+ * Copyright (C) 1999-2020 D. Gilbert
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -36,7 +36,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "0.66 20180628"; /* sbc3r14; mmc6r01a */
+static const char * version_str = "0.67 20200930"; /* sbc3r14; mmc6r01a */
static struct option long_options[] = {
{"eject", no_argument, 0, 'e'},
@@ -162,7 +162,7 @@ usage_old()
"action\n"
" --stop stop unit (same as '0')\n"
" -v verbose (print out SCSI commands)\n"
- " -N|--new use new interface\n"
+ " --new|-N use new interface\n"
" -V print version string then exit\n\n"
" Example: 'sg_start --stop /dev/sdb' stops unit\n"
" 'sg_start --eject /dev/scd0' stops unit and "
diff --git a/testing/sg_mrq_dd.cpp b/testing/sg_mrq_dd.cpp
index 2d4515a4..5cd9da49 100644
--- a/testing/sg_mrq_dd.cpp
+++ b/testing/sg_mrq_dd.cpp
@@ -30,7 +30,7 @@
*
*/
-static const char * version_str = "1.13 20200927";
+static const char * version_str = "1.14 20201008";
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE
@@ -1829,6 +1829,7 @@ sg_half_segment_mrq0(Rq_elem * rep, scat_gath_iter & sg_it, bool is_wr,
t_v4p->request = (uint64_t)t_cdb.data();
t_v4p->usr_ptr = t_v4p->request;
t_v4p->response = (uint64_t)rep->sb;
+ t_v4p->max_response_len = sizeof(rep->sb);
t_v4p->flags = rflags;
t_v4p->request_len = cdbsz;
if (is_wr) {
@@ -2352,6 +2353,7 @@ do_both_sg_segment_mrq0(Rq_elem * rep, scat_gath_iter & i_sg_it,
t_v4p->request = (uint64_t)t_cdb.data();
t_v4p->usr_ptr = t_v4p->request;
t_v4p->response = (uint64_t)rep->sb;
+ t_v4p->max_response_len = sizeof(rep->sb);
t_v4p->flags = iflags;
t_v4p->request_len = cdbsz;
t_v4p->din_xfer_len = num * clp->bs;