aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2020-09-03 15:32:35 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2020-09-03 15:32:35 +0000
commita37cbfd6b346caf0af438f405a8e72fe69454005 (patch)
tree287e2c661580ae696095783225bedb1bf6fcdab9
parente294cca49d78b88ed74f628353970ff907a77e05 (diff)
downloadsg3_utils-a37cbfd6b346caf0af438f405a8e72fe69454005.tar.gz
C++ fix in library, testing cleanup
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@862 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg3_utils.82
-rw-r--r--lib/sg_lib.c1
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_dd.c7
-rw-r--r--testing/Makefile4
-rw-r--r--testing/sg_mrq_dd.cpp112
-rw-r--r--testing/sg_scat_gath.cpp32
-rw-r--r--testing/sg_scat_gath.h17
-rw-r--r--testing/sg_tst_ioctl.c12
-rw-r--r--testing/sgh_dd.cpp6
-rw-r--r--testing/tst_sg_lib.c16
14 files changed, 68 insertions, 149 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f31cbb2..9826472e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ 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 [20200822] [svn: r861]
+Changelog for sg3_utils-1.46 [20200903] [svn: r862]
- sg_rep_pip: report new provisioning initialization pattern cmd
- sg_turs: estimated time-to-ready [20-061r2]
- add --delay=MS option
diff --git a/debian/changelog b/debian/changelog
index 1f83b26d..3240f61b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.46-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Sun, 02 Aug 2020 17:00:00 -0400
+ -- Douglas Gilbert <dgilbert@interlog.com> Tue, 01 Sep 2020 11:00:00 -0400
sg3-utils (1.45-0.1) unstable; urgency=low
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 89839b4e..e2238285 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -1,4 +1,4 @@
-.TH SG3_UTILS "8" "August 2020" "sg3_utils\-1.46" SG3_UTILS
+.TH SG3_UTILS "8" "September 2020" "sg3_utils\-1.46" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 4e8c5ce9..c916f29f 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -52,6 +52,7 @@
#include "sg_lib.h"
#include "sg_lib_data.h"
#include "sg_unaligned.h"
+#include "sg_pr2serr.h"
/* sg_lib_version_str (and datestamp) defined in sg_lib_data.c file */
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index b0a38049..4a55194d 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -635,7 +635,7 @@ struct sg_lib_value_name_t sg_lib_read_attr_arr[] = {
/* A conveniently formatted list of SCSI ASC/ASCQ codes and their
* corresponding text can be found at: www.t10.org/lists/asc-num.txt
- * The following should match asc-num.txt dated 20200710 */
+ * The following should match asc-num.txt dated 20200817 */
#ifdef SG_SCSI_STRINGS
struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[] =
diff --git a/sg3_utils.spec b/sg3_utils.spec
index d055573a..532547be 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -84,7 +84,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Aug 02 2020 - dgilbert at interlog dot com
+* Tue Sep 01 2020 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.46
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 8fa5b141..328ff3d7 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -66,7 +66,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "6.15 20200429";
+static const char * version_str = "6.16 20200825";
#define ME "sg_dd: "
@@ -1766,7 +1766,7 @@ main(int argc, char * argv[])
int64_t out_num_sect = -1;
char * key;
char * buf;
- uint8_t * wrkBuff;
+ uint8_t * wrkBuff = NULL;
uint8_t * wrkPos;
char inf[INOUTF_SZ];
char outf[INOUTF_SZ];
@@ -2536,7 +2536,8 @@ bypass_copy:
if (progress > 0)
pr2serr("\nCompleted:\n");
- free(wrkBuff);
+ if (wrkBuff)
+ free(wrkBuff);
if (free_zeros_buff)
free(free_zeros_buff);
if (STDIN_FILENO != infd)
diff --git a/testing/Makefile b/testing/Makefile
index 0e1a8402..0a34ddec 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -33,8 +33,8 @@ CXXFLAGS = -std=c++17 -pthread -ggdb -O2 -W -Wall -iquote ../include -D_REENTRAN
# CXXFLAGS = -std=c++2a -pthread -ggdb -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CXXFLAGS = -std=c++11 -pthread -ggdb -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CPPFLAGS = -iquote ../include -iquote .. -D_REENTRANT $(LARGE_FILE_FLAGS) -DHAVE_CONFIG_H -DHAVE_NVME -DDEBUG
-# CFLAGS = -g -O2 -W -Wall
-CFLAGS = -ggdb -O2 -W -Wall -DDEBUG
+CFLAGS = -g -O2 -W -Wall
+# CFLAGS = -ggdb -O2 -W -Wall -DDEBUG
# CFLAGS = -g -O2 -Wall -DSG_KERNEL_INCLUDES
# CFLAGS = -g -O2 -Wall -pedantic
# CFLAGS = -Wall -W -pedantic -std=c11 --analyze
diff --git a/testing/sg_mrq_dd.cpp b/testing/sg_mrq_dd.cpp
index 3a4c3306..5049b0b2 100644
--- a/testing/sg_mrq_dd.cpp
+++ b/testing/sg_mrq_dd.cpp
@@ -30,7 +30,7 @@
*
*/
-static const char * version_str = "1.08 20200820";
+static const char * version_str = "1.10 20200830";
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE
@@ -310,9 +310,7 @@ struct sg_io_extra {
#define MONO_MRQ_ID_INIT 0x10000
-// typedef vector< pair<int, struct sg_io_v4> > mrq_arr_t;
typedef array<uint8_t, 32> big_cdb; /* allow up to a 32 byte cdb */
-typedef pair< vector<struct sg_io_v4>, vector<big_cdb> > mrq_arr_t;
/* Use this class to wrap C++11 <random> features to produce uniform random
@@ -330,14 +328,9 @@ private:
default_random_engine dre;
};
-static atomic<long int> pos_index(0);
-
static atomic<int> num_ebusy(0);
static atomic<int> num_start_eagain(0);
static atomic<int> num_fin_eagain(0);
-#if 0
-static atomic<long> num_waiting_calls(0);
-#endif
static atomic<bool> vb_first_time(true);
static sigset_t signal_set;
@@ -377,8 +370,6 @@ static int num_threads = DEF_NUM_THREADS;
static int exit_status = 0;
static bool after1 = false;
-static mutex rand_lba_mutex;
-
static const char * my_name = "sg_mrq_dd: ";
// static const char * mrq_blk_s = "mrq: ordinary blocking";
@@ -390,15 +381,8 @@ static const char * mrq_vb_s = "mrq: variable blocking";
#ifdef __GNUC__
static int pr2serr_lk(const char * fmt, ...)
__attribute__ ((format (printf, 1, 2)));
-#if 0
-static void pr_errno_lk(int e_no, const char * fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
-#endif
#else
static int pr2serr_lk(const char * fmt, ...);
-#if 0
-static void pr_errno_lk(int e_no, const char * fmt, ...);
-#endif
#endif
@@ -415,21 +399,6 @@ pr2serr_lk(const char * fmt, ...)
return n;
}
-#if 0 // not used yet
-static void
-pr_errno_lk(int e_no, const char * fmt, ...)
-{
- char b[180];
- va_list args;
- lock_guard<mutex> lk(strerr_mut);
-
- va_start(args, fmt);
- vsnprintf(b, sizeof(b), fmt, args);
- fprintf(stderr, "%s: %s\n", b, strerror(e_no));
- va_end(args);
-}
-#endif
-
static void
lk_print_command_len(const char *prefix, uint8_t * cmdp, int len, bool lock)
{
@@ -788,14 +757,6 @@ install_handler(int sig_num, void (*sig_handler) (int sig))
}
}
-#if 0 /* SG_LIB_ANDROID */
-static void
-thread_exit_handler(int sig)
-{
- pthread_exit(0);
-}
-#endif
-
/* Make safe_strerror() thread safe */
static char *
tsafe_strerror(int code, char * ebp)
@@ -810,16 +771,6 @@ tsafe_strerror(int code, char * ebp)
}
-/* Following macro from D.R. Butenhof's POSIX threads book:
- * ISBN 0-201-63392-2 . Changed __FILE__ to __func__ */
-#define err_exit(code,text) do { \
- char strerr_buff[STRERR_BUFF_LEN]; \
- pr2serr("%s at \"%s\":%d: %s\n", \
- text, __func__, __LINE__, tsafe_strerror(code, strerr_buff)); \
- exit(1); \
- } while (0)
-
-
static int
dd_filetype(const char * filename, off_t & st_size)
{
@@ -867,7 +818,7 @@ usage(int pg_num)
"[elemsz_kb=EKB]\n"
" [fua=0|1|2|3] [mrq=MRQ] [no_waitq=0|1] "
"[ofreg=OFREG]\n"
- " [sync=0|1] [thr=THR] [time=0|1] "
+ " [sync=0|1] [thr=THR] [time=0|1|2] "
"[verbose=VERB]\n"
" [--dry-run] [--verbose] [--verify] "
"[--version]\n\n"
@@ -1181,12 +1132,6 @@ sg_take_snap(int sg_fd, int id, bool vb_b)
pr2serr_lk("tid=%d: ioctl(SNAP_DEV) ok\n", id);
}
-static inline uint8_t *
-get_buffp(Rq_elem * rep)
-{
- return rep->buffp;
-}
-
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/* Each thread's "main" function */
static void
@@ -1197,17 +1142,14 @@ read_write_thread(struct global_collection * clp, int id, bool singleton)
int n, sz, fd, vb, err, seg_blks;
int res = 0;
int num_sg = 0;
- // volatile bool stop_after_write = false;
bool own_infd = false;
bool in_is_sg, in_mmap, out_is_sg, out_mmap;
bool own_outfd = false;
bool only_one_sg = false;
- // bool share_and_ofreg;
class scat_gath_iter i_sg_it(clp->i_sgl);
class scat_gath_iter o_sg_it(clp->o_sgl);
vector<cdb_arr_t> a_cdb;
vector<struct sg_io_v4> a_v4;
- // mrq_arr_t deferred_arr; /* MRQ deferred array (vector) */
vb = clp->verbose;
sz = clp->mrq_num * clp->bpt * clp->bs;
@@ -1231,11 +1173,13 @@ read_write_thread(struct global_collection * clp, int id, bool singleton)
if (vb > 2)
pr2serr_lk("%d <-- Starting worker thread\n", id);
- if (! rep->both_sg) {
+ if (! (rep->both_sg || in_mmap)) {
rep->buffp = sg_memalign(sz, 0 /* page align */, &rep->alloc_bp,
false);
- if (NULL == rep->buffp)
- err_exit(ENOMEM, "out of memory creating user buffers\n");
+ if (NULL == rep->buffp) {
+ pr2serr_lk("Failed to allocate %d bytes, exiting\n", sz);
+ return;
+ }
}
rep->infd = clp->infd;
rep->outfd = clp->outfd;
@@ -1385,9 +1329,6 @@ read_write_thread(struct global_collection * clp, int id, bool singleton)
fini:
-#if 0
- if ((rep->mmap_active == 0) && rep->alloc_bp)
- free(rep->alloc_bp);
if ((1 == rep->mmap_active) && (rep->mmap_len > 0)) {
if (munmap(rep->buffp, rep->mmap_len) < 0) {
err = errno;
@@ -1401,13 +1342,9 @@ fini:
rep->mmap_len);
rep->mmap_active = 0;
}
-#endif
if (own_infd && (rep->infd >= 0)) {
if (vb && in_is_sg) {
-#if 0
- ++num_waiting_calls;
-#endif
if (ioctl(rep->infd, SG_GET_NUM_WAITING, &n) >= 0) {
if (n > 0)
pr2serr_lk("%s: tid=%d: num_waiting=%d prior close(in)\n",
@@ -1422,9 +1359,6 @@ fini:
}
if (own_outfd && (rep->outfd >= 0)) {
if (vb && out_is_sg) {
-#if 0
- ++num_waiting_calls;
-#endif
if (ioctl(rep->outfd, SG_GET_NUM_WAITING, &n) >= 0) {
if (n > 0)
pr2serr_lk("%s: tid=%d: num_waiting=%d prior "
@@ -1442,6 +1376,8 @@ fini:
clp->out_rem_count -= rep->out_local_count;
clp->in_partial += rep->in_local_partial;
clp->out_partial += rep->out_local_partial;
+ if (rep->alloc_bp)
+ free(rep->alloc_bp);
}
/* N.B. Returns 'blocks' is successful, lesser positive number if there was
@@ -2383,7 +2319,7 @@ do_both_sg_segment_mrq0(Rq_elem * rep, scat_gath_iter & i_sg_it,
if (num <= 0) {
res = 0;
pr2serr_lk("[%d] %s: min(i_lin_blks=%d o_lin_blks=%d) < 1\n", id,
- __func__, i_lin_blks, o_lin_blks);
+ __func__, i_lin_blks, o_lin_blks);
break;
}
@@ -2560,7 +2496,7 @@ do_both_sg_segment(Rq_elem * rep, scat_gath_iter & i_sg_it,
if (num <= 0) {
res = 0;
pr2serr_lk("[%d] %s: min(i_lin_blks=%d o_lin_blks=%d) < 1\n", id,
- __func__, i_lin_blks, o_lin_blks);
+ __func__, i_lin_blks, o_lin_blks);
break;
}
@@ -2891,7 +2827,7 @@ skip_seek(struct global_collection *clp, const char * key, const char * buf,
bool is_skip, bool ignore_verbose)
{
bool def_hex = false;
- int len, err;
+ int len;
int vb = clp->verbose; /* needs to appear before skip/seek= on cl */
int64_t ll;
const char * cp;
@@ -2912,7 +2848,7 @@ skip_seek(struct global_collection *clp, const char * key, const char * buf,
if (! either_list.load_from_file(cp, def_hex, clp->flexible, true)) {
pr2serr("bad argument to '%s=' [err=%d]\n", key,
either_list.m_errno);
- return err ? err : SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_SYNTAX_ERROR;
}
} else if (num_either_ch_in_str(buf, len, ',', ' ') > 0) {
if (! either_list.load_from_cli(buf, vb > 0)) {
@@ -2931,14 +2867,6 @@ skip_seek(struct global_collection *clp, const char * key, const char * buf,
}
either_list.sum_scan(key, vb > 3 /* bool show_sgl */, vb > 1);
-#if 0
- if (vb > 3) {
- lock_guard<mutex> lk(strerr_mut);
-
- pr2serr("%s: scatter gathet list:\n", is_skip ? ("skip" : "seek"));
- either_list.dbg_print(false, is_skip ? ("skip" : "seek"), false,
- bool show_sgl)
-#endif
return 0;
}
@@ -2988,6 +2916,8 @@ process_flags(const char * arg, struct flags_t * fp)
fp->no_dur = true;
else if (0 == strcmp(cp, "no_dur"))
fp->no_dur = true;
+ else if (0 == strcmp(cp, "no_dur"))
+ fp->no_dur = true;
else if (0 == strcmp(cp, "noxfer"))
; /* accept but ignore */
else if (0 == strcmp(cp, "null"))
@@ -3392,12 +3322,6 @@ parse_cmdline_sanity(int argc, char * argv[], struct global_collection * clp,
pr2serr("mmap flag on both IFILE and OFILE doesn't work\n");
return SG_LIB_SYNTAX_ERROR;
}
-#if 0
- if (clp->out_flags.mmap) {
- pr2serr("oflag=mmap needs either noshare=1\n");
- return SG_LIB_SYNTAX_ERROR;
- }
-#endif
/* defaulting transfer size to 128*2048 for CD/DVDs is too large
* for the block layer in lk 2.6 and results in an EIO on the
* SG_IO ioctl. So reduce it in that case. */
@@ -4006,12 +3930,6 @@ fini:
pr2serr("Number of finish EAGAINs: %d\n", num_fin_eagain.load());
if (clp->verbose && (num_ebusy > 0))
pr2serr("Number of EBUSYs: %d\n", num_ebusy.load());
-#if 0
- if (clp->verbose > 1) {
- pr2serr("Number of SG_GET_NUM_WAITING calls=%ld\n",
- num_waiting_calls.load());
- }
-#endif
if (clp->verify && (SG_LIB_CAT_MISCOMPARE == res))
pr2serr("Verify/compare failed due to miscompare\n");
return (res >= 0) ? res : SG_LIB_CAT_OTHER;
diff --git a/testing/sg_scat_gath.cpp b/testing/sg_scat_gath.cpp
index fcf45dfe..832cbed1 100644
--- a/testing/sg_scat_gath.cpp
+++ b/testing/sg_scat_gath.cpp
@@ -70,7 +70,7 @@ scat_gath_list::load_from_cli(const char * cl_p, bool b_vb)
char * cp;
char * c2p;
const char * lcp;
- struct scat_gath_elem sge;
+ class scat_gath_elem sge;
if (NULL == cl_p) {
pr2serr("%s: bad arguments\n", __func__);
@@ -191,7 +191,7 @@ scat_gath_list::file2sgl_helper(FILE * fp, const char * fnp, bool def_hex,
int64_t ll;
uint64_t ull, prev_lba;
char * lcp;
- struct scat_gath_elem sge;
+ class scat_gath_elem sge;
char line[1024];
for (j = 0 ; ; ++j) {
@@ -434,7 +434,7 @@ scat_gath_list::dbg_print(bool skip_meta, const char * id_str, bool to_stdout,
(num == 1 ? "" : "s"));
if (show_sgl) {
for (k = 0; k < num; ++k) {
- const struct scat_gath_elem & sge = sgl[k];
+ const class scat_gath_elem & sge = sgl[k];
fprintf(fp, " lba: 0x%" PRIx64 ", number: 0x%" PRIx32,
sge.lba, sge.num);
@@ -467,7 +467,7 @@ scat_gath_list::sum_scan(const char * id_str, bool show_sgl, bool b_vb)
sum = 0;
for (k = 0, low = 0, high = 0; k < elems; ++k) {
- const struct scat_gath_elem & sge = sgl[k];
+ const class scat_gath_elem & sge = sgl[k];
degen = false;
t_num = sge.num;
@@ -514,7 +514,7 @@ scat_gath_list::sum_scan(const char * id_str, bool show_sgl, bool b_vb)
prev_lba = t_lba;
++k;
for ( ; k < elems; ++k) {
- const struct scat_gath_elem & sge = sgl[k];
+ const class scat_gath_elem & sge = sgl[k];
degen = false;
t_lba = sge.lba;
@@ -558,7 +558,7 @@ scat_gath_list::append_1or(int64_t extra_blks, int64_t start_lba)
int o_num = sgl.size();
const int max_nbs = MAX_SGL_NUM_VAL;
int64_t cnt = 0;
- struct scat_gath_elem sge;
+ class scat_gath_elem sge;
if ((extra_blks <= 0) || (start_lba < 0))
return o_num; /* nothing to do */
@@ -602,7 +602,7 @@ scat_gath_list::append_1or(int64_t extra_blks)
if (o_num < 1)
return append_1or(extra_blks, 0);
- struct scat_gath_elem sge = sgl[o_num - 1];
+ class scat_gath_elem sge = sgl[o_num - 1];
return append_1or(extra_blks, sge.lba + sge.num);
}
@@ -865,7 +865,7 @@ scat_gath_iter::current_lba() const
int64_t res = SG_LBA_INVALID; /* for at end or invalid (-1) */
if (it_el_ind < elems) {
- struct scat_gath_elem sge = sglist.sgl[it_el_ind];
+ class scat_gath_elem sge = sglist.sgl[it_el_ind];
if ((uint32_t)it_blk_off < sge.num)
return sge.lba + it_blk_off;
@@ -889,7 +889,7 @@ scat_gath_iter::current_lba_rem_num(int & rem_num) const
int64_t res = SG_LBA_INVALID; /* for at end or invalid (-1) */
if (it_el_ind < elems) {
- struct scat_gath_elem sge = sglist.sgl[it_el_ind];
+ class scat_gath_elem sge = sglist.sgl[it_el_ind];
if ((uint32_t)it_blk_off < sge.num) {
rem_num = sge.num - it_blk_off;
@@ -908,11 +908,11 @@ scat_gath_iter::current_lba_rem_num(int & rem_num) const
return res;
}
-struct scat_gath_elem
+class scat_gath_elem
scat_gath_iter::current_elem() const
{
const int elems = sglist.sgl.size();
- struct scat_gath_elem sge;
+ class scat_gath_elem sge;
sge.make_bad();
if (it_el_ind < elems)
@@ -946,7 +946,7 @@ scat_gath_iter::linear_for_n_blks(int max_n) const
int k, rem;
const int elems = sglist.sgl.size();
uint64_t prev_lba;
- struct scat_gath_elem sge;
+ class scat_gath_elem sge;
if (at_end() || (max_n <= 0))
return 0;
@@ -992,8 +992,8 @@ scat_gath_iter::dbg_print(const char * id_str, bool to_stdout,
* INT_MIN. Assumes iterators close enough for result to lie in range
* from (-INT_MAX) to INT_MAX (inclusive). */
int
-diff_between_iters(const struct scat_gath_iter & left,
- const struct scat_gath_iter & right)
+diff_between_iters(const class scat_gath_iter & left,
+ const class scat_gath_iter & right)
{
int res, k, r_e_ind, l_e_ind;
@@ -1028,8 +1028,8 @@ diff_between_iters(const struct scat_gath_iter & left,
* true. If no inequality but remaining lists differ in length then returns
* allow_partial. */
bool
-sgls_eq_from_iters(const struct scat_gath_iter & left,
- const struct scat_gath_iter & right,
+sgls_eq_from_iters(const class scat_gath_iter & left,
+ const class scat_gath_iter & right,
bool allow_partial)
{
return sgls_eq_off(left.sglist, left.it_el_ind, left.it_blk_off,
diff --git a/testing/sg_scat_gath.h b/testing/sg_scat_gath.h
index bda8aef7..e864bf8b 100644
--- a/testing/sg_scat_gath.h
+++ b/testing/sg_scat_gath.h
@@ -27,7 +27,8 @@
// Sizing matches largest SCSI READ and WRITE commands plus those of Unix
// read(2)s and write(2)s. User can give larger than 31 bit 'num's but they
// are split into several consecutive elements.
-struct scat_gath_elem {
+class scat_gath_elem {
+public:
uint64_t lba; // of start block
uint32_t num; // number of blocks from and including start block
@@ -89,8 +90,8 @@ public:
int64_t lowest_lba; // initialized to 0
int64_t sum; // of all 'num' elements in 'sgl'
- friend int diff_between_iters(const struct scat_gath_iter & left,
- const struct scat_gath_iter & right);
+ friend int diff_between_iters(const class scat_gath_iter & left,
+ const class scat_gath_iter & right);
private:
friend class scat_gath_iter;
@@ -111,7 +112,7 @@ public:
int64_t current_lba() const;
int64_t current_lba_rem_num(int & rem_num) const;
- struct scat_gath_elem current_elem() const;
+ class scat_gath_elem current_elem() const;
bool at_end() const;
bool is_sgl_linear() const; // the whole list
// Should return 1 or more unless max_n<=0 or at_end()
@@ -124,11 +125,11 @@ public:
void dbg_print(const char * id_str, bool to_stdout, int verbose) const;
- friend int diff_between_iters(const struct scat_gath_iter & left,
- const struct scat_gath_iter & right);
+ friend int diff_between_iters(const class scat_gath_iter & left,
+ const class scat_gath_iter & right);
- friend bool sgls_eq_from_iters(const struct scat_gath_iter & left,
- const struct scat_gath_iter & right,
+ friend bool sgls_eq_from_iters(const class scat_gath_iter & left,
+ const class scat_gath_iter & right,
bool allow_partial);
private:
diff --git a/testing/sg_tst_ioctl.c b/testing/sg_tst_ioctl.c
index 1fd91339..0dff9f1a 100644
--- a/testing/sg_tst_ioctl.c
+++ b/testing/sg_tst_ioctl.c
@@ -60,7 +60,7 @@
* later of the Linux sg driver. */
-static const char * version_str = "Version: 1.18 20200719";
+static const char * version_str = "Version: 1.19 20200825";
#define INQ_REPLY_LEN 128
#define INQ_CMD_LEN 6
@@ -110,7 +110,7 @@ static int dname_last = 0;
static int dname_pos = 0;
static int verbose = 0;
-static const char * relative_cp = NULL;
+static const char * relative_cp = "";
static char * file_name = NULL;
@@ -665,7 +665,7 @@ do_mrqs(int sg_fd, int sg_fd2, int mrqs)
mrq_h4p->flags = SGV4_FLAG_MULTIPLE_REQS;
if (mrq_immed)
mrq_h4p->flags |= SGV4_FLAG_IMMED;
- arr_v4 = calloc(mrqs, sizeof(struct sg_io_v4));
+ arr_v4 = (struct sg_io_v4 *)calloc(mrqs, sizeof(struct sg_io_v4));
if (NULL == arr_v4) {
res = ENOMEM;
goto fini;
@@ -1034,7 +1034,7 @@ dname_range_loop:
is_first = false;
if (nw_given)
- printf("Timing %dx%d calls to ioctl(SG_GET_NUM_WAITING)\n",
+ printf("Timing %d x %d calls to ioctl(SG_GET_NUM_WAITING)\n",
rang, num_sgnw);
else if (iterator_test >= 0) {
k = num_sgnw + 1000;
@@ -1144,10 +1144,10 @@ dname_range_loop:
if (num_sgnw >= 100) {
double m = (double)res_tm.tv_sec +
((double)res_tm.tv_nsec / 1000000000.0);
+ double num = num_sgnw;
if (m > 0.000001)
- printf("%sCalls per second: %.2f\n", relative_cp,
- (double)sum_nw / m);
+ printf("%sCalls per second: %.2f\n", relative_cp, num / m);
}
res = 0;
goto out;
diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp
index de1ba9aa..8221eb25 100644
--- a/testing/sgh_dd.cpp
+++ b/testing/sgh_dd.cpp
@@ -36,7 +36,7 @@
* renamed [20181221]
*/
-static const char * version_str = "1.89 20200818";
+static const char * version_str = "1.91 20200829";
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE
@@ -399,8 +399,6 @@ static int num_threads = DEF_NUM_THREADS;
static int exit_status = 0;
static bool after1 = false;
-static mutex rand_lba_mutex;
-
static const char * my_name = "sgh_dd: ";
static const char * mrq_blk_s = "mrq: ordinary blocking";
@@ -902,7 +900,7 @@ usage(int pg_num)
" [mrq=[I|O,]NRQS[,C]] [noshare=0|1] "
"[of2=OFILE2]\n"
" [ofreg=OFREG] [ofsplit=OSP] [sync=0|1] [thr=THR] "
- "[time=0|1]\n"
+ "[time=0|1|2]\n"
" [unshare=1|0] [verbose=VERB] [--dry-run] "
"[--prefetch]\n"
" [--verbose] [--verify] [--version]\n\n"
diff --git a/testing/tst_sg_lib.c b/testing/tst_sg_lib.c
index a90bcac3..eb159334 100644
--- a/testing/tst_sg_lib.c
+++ b/testing/tst_sg_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2019 Douglas Gilbert.
+ * Copyright (c) 2013-2020 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -44,7 +44,7 @@
* related to snprintf().
*/
-static const char * version_str = "1.13 20190108";
+static const char * version_str = "1.14 20200901";
#define MAX_LINE_LEN 1024
@@ -595,11 +595,11 @@ main(int argc, char * argv[])
elapsed_msecs = (end_tm.tv_sec - start_tm.tv_sec) * 1000;
elapsed_msecs += (end_tm.tv_nsec - start_tm.tv_nsec) / 1000000;
if (16 == byteswap_sz)
- printf(" count16=%u\n", count16);
+ printf(" last k=%d, last count16=%u\n", k, count16);
else if (32 == byteswap_sz)
- printf(" count32=%u\n", count32);
+ printf(" last k=%d, last count32=%u\n", k, count32);
else
- printf(" count64=%" PRIu64 "\n", count64);
+ printf(" last k=%d, last count64=%" PRIu64 "\n", k, count64);
printf("Unaligned elapsed milliseconds: %u\n", elapsed_msecs);
count16 = 0;
count32 = 0;
@@ -640,11 +640,11 @@ main(int argc, char * argv[])
elapsed_msecs = (end_tm.tv_sec - start_tm.tv_sec) * 1000;
elapsed_msecs += (end_tm.tv_nsec - start_tm.tv_nsec) / 1000000;
if (16 == byteswap_sz)
- printf(" count16=%u\n", count16);
+ printf(" last k=%d, last count16=%u\n", k, count16);
else if (32 == byteswap_sz)
- printf(" count32=%u\n", count32);
+ printf(" last k=%d, last count32=%u\n", k, count32);
else
- printf(" count64=%" PRIu64 "\n", count64);
+ printf(" last k=%d, last count64=%" PRIu64 "\n", k, count64);
printf("Byteswap/memcpy elapsed milliseconds: %u\n", elapsed_msecs);
count16 = 0;
count32 = 0;