aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2021-11-05 23:31:50 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2021-11-05 23:31:50 +0000
commit02beb6330465dfd55ce605206c35780f3c390d6b (patch)
tree74e0ba4e59cf863711fdc63fe839684b6c979040 /src
parent901931cfdad6f06e22c24beba339bb08d2265498 (diff)
downloadsg3_utils-02beb6330465dfd55ce605206c35780f3c390d6b.tar.gz
sgp_dd: add check for stdatomic.h presence in configure.ac; scripts: 55-scsi-sg3_id.rules remove outdated rule
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@918 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in10
-rw-r--r--src/sg_decode_sense.c31
-rw-r--r--src/sg_get_elem_status.c6
-rw-r--r--src/sg_get_lba_status.c6
-rw-r--r--src/sgp_dd.c61
5 files changed, 65 insertions, 49 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 41d760f7..5ae4625e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.4 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -498,8 +498,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -515,6 +513,8 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
@@ -525,6 +525,7 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETOPT_O_FILES = @GETOPT_O_FILES@
@@ -1245,7 +1246,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index e3db2094..a21ceb47 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -30,7 +30,7 @@
#include "sg_unaligned.h"
-static const char * version_str = "1.23 20211001";
+static const char * version_str = "1.24 20211104";
#define MAX_SENSE_LEN 1024 /* max descriptor format actually: 255+8 */
@@ -43,6 +43,8 @@ static struct option long_options[] = {
{"file", required_argument, 0, 'f'},
{"help", no_argument, 0, 'h'},
{"hex", no_argument, 0, 'H'},
+ {"in", required_argument, 0, 'i'}, /* don't advertise */
+ {"inhex", required_argument, 0, 'i'}, /* same as --file */
{"nospace", no_argument, 0, 'n'},
{"status", required_argument, 0, 's'},
{"verbose", no_argument, 0, 'v'},
@@ -80,9 +82,10 @@ usage()
{
pr2serr("Usage: sg_decode_sense [--binary=BFN] [--cdb] [--err=ES] "
"[--file=HFN]\n"
- " [--help] [--hex] [--nospace] [--status=SS] "
- "[--verbose]\n"
- " [--version] [--write=WFN] H1 H2 H3 ...\n"
+ " [--help] [--hex] [--inhex=HFN] [--nospace] "
+ "[--status=SS]\n"
+ " [--verbose] [--version] [--write=WFN] H1 "
+ "H2 H3 ...\n"
" where:\n"
" --binary=BFN|-b BFN BFN is a file name to read sense "
"data in\n"
@@ -101,6 +104,7 @@ usage()
"write out\n"
" C language style ASCII hex (instead "
"of binary)\n"
+ " --inhex=HFN|-i HFN same as action as --file=HFN\n"
" --nospace|-n no spaces or other separators between "
"pairs of\n"
" hex digits (e.g. '3132330A')\n"
@@ -129,15 +133,15 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
char *endptr;
while (1) {
- c = getopt_long(argc, argv, "b:ce:f:hHns:vVw:", long_options, NULL);
+ c = getopt_long(argc, argv, "b:ce:f:hHi:ns:vVw:", long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'b':
if (op->fname) {
- pr2serr("expect only one '--binary=BFN' or '--file=BFN' "
- "option\n");
+ pr2serr("expect only one '--binary=BFN', '--file=HFN' or "
+ "'--inhex=HFN' option\n");
return SG_LIB_CONTRADICT;
}
op->do_binary = true;
@@ -157,8 +161,8 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
break;
case 'f':
if (op->fname) {
- pr2serr("expect only one '--binary=HFN' or '--file=HFN' "
- "option\n");
+ pr2serr("expect only one '--binary=BFN', '--file=HFN' or "
+ "'--inhex=HFN' option\n");
return SG_LIB_CONTRADICT;
}
op->file_given = true;
@@ -168,6 +172,15 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[])
case '?':
op->do_help = true;
return 0;
+ case 'i':
+ if (op->fname) {
+ pr2serr("expect only one '--binary=BFN', '--file=HFN' or "
+ "'--inhex=HFN' option\n");
+ return SG_LIB_CONTRADICT;
+ }
+ op->file_given = true;
+ op->fname = optarg;
+ break;
case 'H':
op->do_hex = true;
break;
diff --git a/src/sg_get_elem_status.c b/src/sg_get_elem_status.c
index 61533c7b..c60d984e 100644
--- a/src/sg_get_elem_status.c
+++ b/src/sg_get_elem_status.c
@@ -37,7 +37,7 @@
* given SCSI device.
*/
-static const char * version_str = "1.06 20210831"; /* sbc5r01 */
+static const char * version_str = "1.07 20211104"; /* sbc5r01 */
#ifndef UINT32_MAX
@@ -101,9 +101,9 @@ usage()
"elements\n"
" --help|-h print out usage message\n"
" --hex|-H output in hexadecimal\n"
- " --inhex=FN input taken from file FN rather than "
+ " --inhex=FN|-i FN input taken from file FN rather than "
"DEVICE,\n"
- " assumed to be ASCII hex or, if --raw, "
+ " assumed to be ASCII hex or, if --raw, "
"in binary\n"
" --maxlen=LEN|-m LEN max response length (allocation "
"length in cdb)\n"
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 001d6d73..4ce9b2ca 100644
--- a/src/sg_get_lba_status.c
+++ b/src/sg_get_lba_status.c
@@ -35,7 +35,7 @@
* device.
*/
-static const char * version_str = "1.22 20210803"; /* sbc4r15 */
+static const char * version_str = "1.23 20211104"; /* sbc4r15 */
#ifndef UINT32_MAX
#define UINT32_MAX ((uint32_t)-1)
@@ -94,9 +94,9 @@ usage()
"(def: 0)\n"
" --help|-h print out usage message\n"
" --hex|-H output in hexadecimal\n"
- " --inhex=FN input taken from file FN rather than "
+ " --inhex=FN|-i FN input taken from file FN rather than "
"DEVICE,\n"
- " assumed to be ASCII hex or, if --raw, "
+ " assumed to be ASCII hex or, if --raw, "
"in binary\n"
" --lba=LBA|-l LBA starting LBA (logical block address) "
"(def: 0)\n"
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index adf4c2ec..2b2d4e5c 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -59,8 +59,12 @@
#include <linux/major.h> /* for MEM_MAJOR, SCSI_GENERIC_MAJOR, etc */
#include <linux/fs.h> /* for BLKSSZGET and friends */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#ifdef __STDC_VERSION__
-#if __STDC_VERSION__ >= 201112L
+#if __STDC_VERSION__ >= 201112L && defined(HAVE_STDATOMIC_H)
#ifndef __STDC_NO_ATOMICS__
#define HAVE_C11_ATOMICS
@@ -74,9 +78,6 @@
#warning "Don't have C11 Atomics, using mutex with pack_id"
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
#include "sg_lib.h"
#include "sg_cmds_basic.h"
#include "sg_io_linux.h"
@@ -84,7 +85,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "5.82 20211027";
+static const char * version_str = "5.83 20211105";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -175,12 +176,11 @@ struct opts_t
int dry_run;
};
-typedef struct thread_arg
+struct thread_arg
{ /* pointer to this argument passed to thread */
int id;
int64_t seek_skip;
- struct opts_t * clp;
-} Thread_arg;
+};
typedef struct request_element
{ /* one instance per worker thread */
@@ -188,6 +188,7 @@ typedef struct request_element
bool in_stop;
bool in_err;
bool out_err;
+ bool use_no_dxfer;
int infd;
int outfd;
int64_t blk;
@@ -215,10 +216,11 @@ static const char * proc_allow_dio = "/proc/scsi/sg/allow_dio";
static void sg_in_operation(struct opts_t * clp, Rq_elem * rep);
static void sg_out_operation(struct opts_t * clp, Rq_elem * rep,
- bool bump_out_blk);
-static void normal_in_operation(struct opts_t * clp, Rq_elem * rep, int blocks);
-static void normal_out_operation(struct opts_t * clp, Rq_elem * rep, int blocks,
- bool bump_out_blk);
+ bool bump_out_blk);
+static void normal_in_operation(struct opts_t * clp, Rq_elem * rep,
+ int blocks);
+static void normal_out_operation(struct opts_t * clp, Rq_elem * rep,
+ int blocks, bool bump_out_blk);
static int sg_start_io(Rq_elem * rep);
static int sg_finish_io(bool wr, Rq_elem * rep, pthread_mutex_t * a_mutp);
@@ -259,7 +261,7 @@ GET_NEXT_PACK_ID(unsigned int val)
static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER;
static pthread_t threads[MAX_NUM_THREADS];
-static Thread_arg thr_arg_a[MAX_NUM_THREADS];
+static struct thread_arg thr_arg_a[MAX_NUM_THREADS];
static bool shutting_down = false;
static bool do_sync = false;
@@ -681,11 +683,11 @@ sg_out_open(const char * fnp, struct flags_t * flagp, int bs, int bpt)
static void *
read_write_thread(void * v_tap)
{
- Thread_arg * tap = (Thread_arg *)v_tap;
- struct opts_t * clp;
+ struct thread_arg * tap = (struct thread_arg *)v_tap;
+ struct opts_t * clp = &my_opts;
Rq_elem rel;
Rq_elem * rep = &rel;
- volatile bool stop_after_write, b;
+ volatile bool stop_after_write, bb;
bool enforce_write_ordering;
int sz, c_addr;
int64_t out_blk, out_count;
@@ -693,7 +695,6 @@ read_write_thread(void * v_tap)
int blocks, status;
stop_after_write = false;
- clp = tap->clp;
enforce_write_ordering = (FT_DEV_NULL != clp->out_type) &&
(FT_SG != clp->out_type);
c_addr = clp->chkaddr;
@@ -724,6 +725,7 @@ read_write_thread(void * v_tap)
rep->cdbsz_out = clp->cdbsz_out;
rep->in_flags = clp->in_flags;
rep->out_flags = clp->out_flags;
+ rep->use_no_dxfer = (FT_DEV_NULL == clp->out_type);
if (clp->mmap_active) {
int fd = clp->in_flags.mmap ? rep->infd : rep->outfd;
@@ -742,11 +744,11 @@ read_write_thread(void * v_tap)
status = pthread_mutex_lock(&clp->inout_mutex);
if (0 != status) err_exit(status, "lock inout_mutex");
#ifdef HAVE_C11_ATOMICS
- b = atomic_load(&exit_threads);
+ bb = atomic_load(&exit_threads);
#else
- b = exit_threads;
+ bb = exit_threads;
#endif
- if (b || (clp->in_count <= 0)) {
+ if (bb || (clp->in_count <= 0)) {
/* no more to do, exit loop then thread */
status = pthread_mutex_unlock(&clp->inout_mutex);
if (0 != status) err_exit(status, "unlock inout_mutex");
@@ -807,11 +809,11 @@ read_write_thread(void * v_tap)
status = pthread_mutex_lock(&clp->inout_mutex);
if (0 != status) err_exit(status, "lock inout_mutex");
#ifdef HAVE_C11_ATOMICS
- b = atomic_load(&exit_threads);
+ bb = atomic_load(&exit_threads);
#else
- b = exit_threads;
+ bb = exit_threads;
#endif
- while ((! b) && (out_blk != clp->out_blk)) {
+ while ((! bb) && (out_blk != clp->out_blk)) {
/* if write would be out of sequence then wait */
pthread_cleanup_push(cleanup_out, (void *)clp);
status = pthread_cond_wait(&clp->out_sync_cv,
@@ -824,11 +826,11 @@ read_write_thread(void * v_tap)
}
#ifdef HAVE_C11_ATOMICS
- b = atomic_load(&exit_threads);
+ bb = atomic_load(&exit_threads);
#else
- b = exit_threads;
+ bb = exit_threads;
#endif
- if (b || (out_count <= 0))
+ if (bb || (out_count <= 0))
break;
rep->wr = true;
@@ -1174,6 +1176,7 @@ sg_start_io(Rq_elem * rep)
bool dpo = rep->wr ? rep->out_flags.dpo : rep->in_flags.dpo;
bool dio = rep->wr ? rep->out_flags.dio : rep->in_flags.dio;
bool mmap = rep->wr ? rep->out_flags.mmap : rep->in_flags.mmap;
+ bool no_dxfer = rep->wr ? false : rep->use_no_dxfer;
int cdbsz = rep->wr ? rep->cdbsz_out : rep->cdbsz_in;
int res;
@@ -1200,6 +1203,8 @@ sg_start_io(Rq_elem * rep)
hp->flags |= SG_FLAG_DIRECT_IO;
if (mmap)
hp->flags |= SG_FLAG_MMAP_IO;
+ if (no_dxfer)
+ hp->flags |= SG_FLAG_NO_DXFER;
if (rep->debug > 8) {
pr2serr("%s: SCSI %s, blk=%" PRId64 " num_blks=%d\n", __func__,
rep->wr ? "WRITE" : "READ", rep->blk, rep->num_blks);
@@ -1285,8 +1290,8 @@ sg_finish_io(bool wr, Rq_elem * rep, pthread_mutex_t * a_mutp)
sg_chk_n_print3(ebuff, hp, false);
status = pthread_mutex_unlock(a_mutp);
if (0 != status) err_exit(status, "unlock inout_mutex");
- return res;
}
+ return res;
}
#if 0
if (0 == (++testing % 100)) return -1;
@@ -1878,7 +1883,6 @@ main(int argc, char * argv[])
seek_skip = clp->seek - clp->skip;
thr_arg_a[0].id = 0;
thr_arg_a[0].seek_skip = seek_skip;
- thr_arg_a[0].clp = clp;
status = pthread_create(&threads[0], NULL, read_write_thread,
(void *)(thr_arg_a + 0));
if (0 != status) err_exit(status, "pthread_create");
@@ -1898,7 +1902,6 @@ main(int argc, char * argv[])
thr_arg_a[k].id = k;
thr_arg_a[k].seek_skip = seek_skip;
- thr_arg_a[k].clp = clp;
status = pthread_create(&threads[k], NULL, read_write_thread,
(void *)(thr_arg_a + k));
if (0 != status) err_exit(status, "pthread_create");