aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-08-29 20:21:51 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-08-29 20:21:51 +0000
commitbd4b51e9452bf0d5c22630cf5e21fa71477be34b (patch)
treea80711e4aa1bc4cb1c9be7d731a7a7efb1504323
parent5c18750d086d6f01c7ec167a3cde6bfe1de0acea (diff)
downloadsg3_utils-bd4b51e9452bf0d5c22630cf5e21fa71477be34b.tar.gz
sg_raw: with -vvv decode T10 CDB name; sg_lib: clean up service action string functions
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@603 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog4
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg3_utils.84
-rw-r--r--doc/sg_decode_sense.87
-rw-r--r--doc/sg_raw.815
-rw-r--r--examples/sg_tst_async.cpp53
-rw-r--r--examples/sg_tst_context.cpp86
-rw-r--r--examples/sg_tst_excl.cpp131
-rw-r--r--examples/sg_tst_excl2.cpp105
-rw-r--r--examples/sg_tst_excl3.cpp89
-rw-r--r--lib/sg_lib.c177
-rw-r--r--lib/sg_lib_data.c46
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_raw.c17
15 files changed, 387 insertions, 353 deletions
diff --git a/ChangeLog b/ChangeLog
index b91eb316..d5129a1d 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.40 [20140827] [svn: r602]
+Changelog for sg3_utils-1.40 [20140829] [svn: r603]
- sg_write_verify: new utility for WRITE AND VERIFY
- sg_senddiag: add --maxlen= option
- sg_copy_results: correct response length calculations
@@ -13,9 +13,11 @@ Changelog for sg3_utils-1.40 [20140827] [svn: r602]
- sg_vpd: add --all option
- sg_ses: fix problem with --index=sse (and ssc)
- sg_logs: refine tape drive output
+ - sg_raw: with -vvv decode T10 CDB name
- sg_sat_*: mention t_type and multiple_count fields
- win32: sg_scan: handle larger configurations
- sg_lib: trim trailing spaces in dStrHex() and friends
+ - clean up service action string functions
- sg_unaligned.h: add header for building parameters
- examples/sg_tst_async: new Linux sg test utility
diff --git a/README b/README
index eefbcf78..92b14363 100644
--- a/README
+++ b/README
@@ -411,4 +411,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-11th August 2014
+29th August 2014
diff --git a/debian/changelog b/debian/changelog
index eff48ae0..2fe42309 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.40-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Mon, 11 Aug 2014 12:00:00 +0200
+ -- Douglas Gilbert <dgilbert@interlog.com> Fri, 29 Aug 2014 13:00:00 -0400
sg3-utils (1.39-0.1) unstable; urgency=low
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 135ee467..26cd7a95 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -20,6 +20,10 @@ issue them is shown in the COVERAGE file. The sg_raw utility can be used to
send an arbitrary SCSI command (supplied on the command line) to the
given \fIDEVICE\fR.
.PP
+sg_decode_sense can be used to decode SCSI sense data given on the command
+line or in a file. sg_raw \-vvv will output the T10 name of a given SCSI
+CDB which is most often 16 bytes or less in length.
+.PP
SCSI draft standards can be found at http://www.t10.org . The standards
themselves can be purchased from ANSI and other standards organizations.
A good overview of various SCSI standards can be seen in
diff --git a/doc/sg_decode_sense.8 b/doc/sg_decode_sense.8
index 63fe4152..e68a795a 100644
--- a/doc/sg_decode_sense.8
+++ b/doc/sg_decode_sense.8
@@ -1,4 +1,4 @@
-.TH SG_DECODE_SENSE "8" "May 2014" "sg3_utils\-1.39" SG3_UTILS
+.TH SG_DECODE_SENSE "8" "August 2014" "sg3_utils\-1.40" SG3_UTILS
.SH NAME
sg_decode_sense \- decode SCSI sense data
.SH SYNOPSIS
@@ -87,6 +87,9 @@ Unlike most utilities in this package, this utility does not access a
SCSI device (logical unit). This utility accesses a library associated
with this package. Amongst other things the library decodes SCSI sense
data.
+.PP
+T10 defined SCSI command names given a CDB can be decoded using the sg_raw
+utility with the '\-vvv' option.
.SH EXAMPLES
Sense data is often printed out in kernel logs and sometimes on the
command line when verbose or debug flags are given. It will be at least
@@ -125,4 +128,4 @@ Copyright \(co 2010\-2014 Douglas Gilbert
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
-.B sg_requests(sg3_utils)
+.B sg_requests,sg_raw(sg3_utils)
diff --git a/doc/sg_raw.8 b/doc/sg_raw.8
index 2ef7dc23..0557a1a6 100644
--- a/doc/sg_raw.8
+++ b/doc/sg_raw.8
@@ -1,4 +1,4 @@
-.TH SG_RAW "8" "December 2012" "sg3_utils\-1.35" SG3_UTILS
+.TH SG_RAW "8" "August 2014" "sg3_utils\-1.40" SG3_UTILS
.SH NAME
sg_raw \- send arbitrary SCSI command to a device
.SH SYNOPSIS
@@ -77,7 +77,15 @@ Product Pages of a devices which may contain useful information.
.PP
The ability to send more than a 16 byte CDB (in some cases 12 byte CDB)
may be restricted by the pass\-through interface, the low level driver
-or the transport.
+or the transport. In the Linux series 3 kernels, the bsg driver can
+handle longer CDBs, block devices (e.g. /dev/sdc) accessed via the
+SG_IO ioctl cannot handle CDBs longer than 16 bytes, and the sg driver
+can handle longer CDBs from lk 3.17 .
+.PP
+The CDB command name defined by T10 for the given CDB is shown if
+the '\-vvv' option is given. The command line syntax still needs to be
+correct, so /dev/null may be used for the \fIDEVICE\fR since the CDB
+command name decoding is done before the \fIDEVICE\fR is checked.
.SH EXAMPLES
These examples, apart from the last one, use Linux device names. For
suitable device names in other supported Operating Systems see the
@@ -125,10 +133,9 @@ Written by Ingo van Lil
.SH "REPORTING BUGS"
Report bugs to <inguin at gmx dot de>.
.SH COPYRIGHT
-Copyright \(co 2001\-2012 Ingo van Lil
+Copyright \(co 2001\-2014 Ingo van Lil
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
.B sg_inq, sg_vpd, sg3_utils (sg3_utils), plscsi
-
diff --git a/examples/sg_tst_async.cpp b/examples/sg_tst_async.cpp
index afda6185..fa3c3769 100644
--- a/examples/sg_tst_async.cpp
+++ b/examples/sg_tst_async.cpp
@@ -57,7 +57,7 @@
#include "sg_io_linux.h"
#include "sg_unaligned.h"
-static const char * version_str = "1.06 20140824";
+static const char * version_str = "1.07 20140827";
static const char * util_name = "sg_tst_async";
/* This is a test program for checking the async usage of the Linux sg
@@ -268,16 +268,12 @@ static int
pr2serr_lk(const char * fmt, ...)
{
int n;
+ va_list args;
+ lock_guard<mutex> lg(console_mutex);
- console_mutex.lock();
- {
- va_list args;
-
- va_start(args, fmt);
- n = vfprintf(stderr, fmt, args);
- va_end(args);
- }
- console_mutex.unlock();
+ va_start(args, fmt);
+ n = vfprintf(stderr, fmt, args);
+ va_end(args);
return n;
}
@@ -285,17 +281,13 @@ static void
pr_errno_lk(int e_no, const char * fmt, ...)
{
char b[160];
-
- console_mutex.lock();
- {
va_list args;
+ lock_guard<mutex> lg(console_mutex);
- va_start(args, fmt);
- vsnprintf(b, sizeof(b), fmt, args);
- fprintf(stderr, "%s: %s\n", b, strerror(e_no));
- va_end(args);
- }
- console_mutex.unlock();
+ va_start(args, fmt);
+ vsnprintf(b, sizeof(b), fmt, args);
+ fprintf(stderr, "%s: %s\n", b, strerror(e_no));
+ va_end(args);
}
static unsigned int
@@ -304,8 +296,8 @@ get_urandom_uint(void)
unsigned int res = 0;
int n;
unsigned char b[sizeof(unsigned int)];
+ lock_guard<mutex> lg(rand_lba_mutex);
- rand_lba_mutex.lock();
int fd = open(URANDOM_DEV, O_RDONLY);
if (fd >= 0) {
n = read(fd, b, sizeof(unsigned int));
@@ -313,7 +305,6 @@ get_urandom_uint(void)
memcpy(&res, b, sizeof(unsigned int));
close(fd);
}
- rand_lba_mutex.unlock();
return res;
}
@@ -439,9 +430,10 @@ finish_sg3_cmd(int sg_fd, command2execute cmd2exe, int & pack_id, int wait_ms,
ok = 1;
break;
default: /* won't bother decoding other categories */
- console_mutex.lock();
- sg_chk_n_print3(np, &pt, 1);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+ sg_chk_n_print3(np, &pt, 1);
+ }
break;
}
return ok ? 0 : -1;
@@ -782,9 +774,10 @@ do_inquiry_prod_id(const char * dev_name, int block, char * b, int b_mlen)
ok = 1;
break;
default: /* won't bother decoding other categories */
- console_mutex.lock();
- sg_chk_n_print3("INQUIRY command error", &pt, 1);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+ sg_chk_n_print3("INQUIRY command error", &pt, 1);
+ }
break;
}
if (ok) {
@@ -844,15 +837,13 @@ do_read_capacity(const char * dev_name, int block, unsigned int * last_lba,
}
res = sg_err_category3(&io_hdr);
if (SG_LIB_CAT_UNIT_ATTENTION == res) {
- console_mutex.lock();
+ lock_guard<mutex> lg(console_mutex);
sg_chk_n_print3("read capacity", &io_hdr, 1);
- console_mutex.unlock();
close(sg_fd);
return 2; /* probably have another go ... */
} else if (SG_LIB_CAT_CLEAN != res) {
- console_mutex.lock();
+ lock_guard<mutex> lg(console_mutex);
sg_chk_n_print3("read capacity", &io_hdr, 1);
- console_mutex.unlock();
close(sg_fd);
return -1;
}
diff --git a/examples/sg_tst_context.cpp b/examples/sg_tst_context.cpp
index 86612bac..6ac99354 100644
--- a/examples/sg_tst_context.cpp
+++ b/examples/sg_tst_context.cpp
@@ -46,7 +46,7 @@
#include "sg_lib.h"
#include "sg_pt.h"
-static const char * version_str = "1.01 20131119";
+static const char * version_str = "1.02 20140828";
static const char * util_name = "sg_tst_context";
/* This is a test program for checking that file handles keep their
@@ -165,9 +165,9 @@ pt_cat_no_good(int cat, struct sg_pt_base * ptp, const unsigned char * sbp)
break;
}
if (cp) {
- console_mutex.lock();
+ lock_guard<mutex> lg(console_mutex);
+
fprintf(stderr, cp, b);
- console_mutex.unlock();
}
return -EIO /* -5 */;
}
@@ -191,11 +191,13 @@ do_tur(int pt_fd, int id)
set_scsi_pt_sense(ptp, sense_buffer, sizeof(sense_buffer));
res = do_scsi_pt(ptp, pt_fd, 20 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "TEST UNIT READY do_scsi_pt() submission error, "
- "id=%d\n", id);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "TEST UNIT READY do_scsi_pt() submission error, "
+ "id=%d\n", id);
+ }
res = pt_err(res);
- console_mutex.unlock();
goto err;
}
cat = get_scsi_pt_result_category(ptp);
@@ -206,10 +208,12 @@ do_tur(int pt_fd, int id)
res = 1024;
goto err;
}
- console_mutex.lock();
- fprintf(stderr, "TEST UNIT READY do_scsi_pt() category problem, "
- "id=%d\n", id);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "TEST UNIT READY do_scsi_pt() category problem, "
+ "id=%d\n", id);
+ }
res = pt_cat_no_good(cat, ptp, sense_buffer);
goto err;
}
@@ -237,11 +241,13 @@ do_ssu(int pt_fd, int id, bool start)
set_scsi_pt_sense(ptp, sense_buffer, sizeof(sense_buffer));
res = do_scsi_pt(ptp, pt_fd, 40 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "START STOP UNIT do_scsi_pt() submission error, "
- "id=%d\n", id);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "START STOP UNIT do_scsi_pt() submission error, "
+ "id=%d\n", id);
+ }
res = pt_err(res);
- console_mutex.unlock();
goto err;
}
cat = get_scsi_pt_result_category(ptp);
@@ -252,10 +258,12 @@ do_ssu(int pt_fd, int id, bool start)
res = 1024;
goto err;
}
- console_mutex.lock();
- fprintf(stderr, "START STOP UNIT do_scsi_pt() category problem, "
- "id=%d\n", id);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "START STOP UNIT do_scsi_pt() category problem, "
+ "id=%d\n", id);
+ }
res = pt_cat_no_good(cat, ptp, sense_buffer);
goto err;
}
@@ -278,10 +286,12 @@ work_thread(const char * dev_name, int id, int num, bool share,
bool started = true;
char ebuff[EBUFF_SZ];
- console_mutex.lock();
- cerr << "Enter work_thread id=" << id << " num=" << num << " share="
- << share << endl;
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ cerr << "Enter work_thread id=" << id << " num=" << num << " share="
+ << share << endl;
+ }
if (! share) {
int open_flags = O_RDWR;
@@ -301,9 +311,9 @@ work_thread(const char * dev_name, int id, int num, bool share,
return;
}
if (thr_ebusy_count) {
- count_mutex.lock();
+ lock_guard<mutex> lg(count_mutex);
+
ebusy_count += thr_ebusy_count;
- count_mutex.unlock();
}
}
for (k = 0; k < num; ++k) {
@@ -329,18 +339,22 @@ work_thread(const char * dev_name, int id, int num, bool share,
if (! share)
scsi_pt_close_device(pt_fd);
- count_mutex.lock();
- even_notreadys += thr_even_notreadys;
- odd_notreadys += thr_odd_notreadys;
- count_mutex.unlock();
+ {
+ lock_guard<mutex> lg(count_mutex);
- console_mutex.lock();
- if (k < num)
- cerr << "thread id=" << id << " FAILed at iteration: " << k
- << " [negated errno: " << res << "]\n";
- else
- cerr << "thread id=" << id << " normal exit" << '\n';
- console_mutex.unlock();
+ even_notreadys += thr_even_notreadys;
+ odd_notreadys += thr_odd_notreadys;
+ }
+
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ if (k < num)
+ cerr << "thread id=" << id << " FAILed at iteration: " << k
+ << " [negated errno: " << res << "]\n";
+ else
+ cerr << "thread id=" << id << " normal exit" << '\n';
+ }
}
diff --git a/examples/sg_tst_excl.cpp b/examples/sg_tst_excl.cpp
index a4a85121..5b4e6956 100644
--- a/examples/sg_tst_excl.cpp
+++ b/examples/sg_tst_excl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Douglas Gilbert.
+ * Copyright (c) 2013-2014 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,7 @@
#include "sg_lib.h"
#include "sg_io_linux.h"
-static const char * version_str = "1.08 20140710";
+static const char * version_str = "1.09 20140828";
static const char * util_name = "sg_tst_excl";
/* This is a test program for checking O_EXCL on open() works. It uses
@@ -212,17 +212,21 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
// queue up two READ_16s to same LBA
if (write(sg_fd, &pt, sizeof(pt)) < 0) {
- console_mutex.lock();
- perror("do_rd_inc_wr_twice: write(sg, READ_16)");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror("do_rd_inc_wr_twice: write(sg, READ_16)");
+ }
close(sg_fd);
return -1;
}
pt2 = pt;
if (write(sg_fd, &pt2, sizeof(pt2)) < 0) {
- console_mutex.lock();
- perror("do_rd_inc_wr_twice: write(sg, READ_16) 2");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror("do_rd_inc_wr_twice: write(sg, READ_16) 2");
+ }
close(sg_fd);
return -1;
}
@@ -238,9 +242,11 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
sleep(0); // process yield ??
}
if (res < 0) {
- console_mutex.lock();
- perror("do_rd_inc_wr_twice: read(sg, READ_16)");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror("do_rd_inc_wr_twice: read(sg, READ_16)");
+ }
close(sg_fd);
return -1;
}
@@ -251,15 +257,19 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
ok = 1;
break;
case SG_LIB_CAT_RECOVERED:
- console_mutex.lock();
- fprintf(stderr, "Recovered error on READ_16, continuing\n");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "Recovered error on READ_16, continuing\n");
+ }
ok = 1;
break;
default: /* won't bother decoding other categories */
- console_mutex.lock();
- sg_chk_n_print3("READ_16 command error", &pt, 1);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ sg_chk_n_print3("READ_16 command error", &pt, 1);
+ }
break;
}
if (ok) {
@@ -274,9 +284,11 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
sleep(0); // process yield ??
}
if (res < 0) {
- console_mutex.lock();
- perror("do_rd_inc_wr_twice: read(sg, READ_16) 2");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror("do_rd_inc_wr_twice: read(sg, READ_16) 2");
+ }
close(sg_fd);
return -1;
}
@@ -288,15 +300,20 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
ok = 1;
break;
case SG_LIB_CAT_RECOVERED:
- console_mutex.lock();
- fprintf(stderr, "Recovered error on READ_16, continuing 2\n");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "Recovered error on READ_16, continuing "
+ "2\n");
+ }
ok = 1;
break;
default: /* won't bother decoding other categories */
- console_mutex.lock();
- sg_chk_n_print3("READ_16 command error 2", &pt, 1);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ sg_chk_n_print3("READ_16 command error 2", &pt, 1);
+ }
break;
}
}
@@ -335,9 +352,11 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
pt.pack_id = id;
if (ioctl(sg_fd, SG_IO, &pt) < 0) {
- console_mutex.lock();
- perror("do_rd_inc_wr_twice: WRITE_16 SG_IO ioctl error");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror("do_rd_inc_wr_twice: WRITE_16 SG_IO ioctl error");
+ }
close(sg_fd);
return -1;
}
@@ -348,15 +367,19 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
ok = 1;
break;
case SG_LIB_CAT_RECOVERED:
- console_mutex.lock();
- fprintf(stderr, "Recovered error on WRITE_16, continuing\n");
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "Recovered error on WRITE_16, continuing\n");
+ }
ok = 1;
break;
default: /* won't bother decoding other categories */
- console_mutex.lock();
- sg_chk_n_print3("WRITE_16 command error", &pt, 1);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ sg_chk_n_print3("WRITE_16 command error", &pt, 1);
+ }
break;
}
if (! ok) {
@@ -470,10 +493,12 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
unsigned int thr_eagain_count = 0;
int k, res;
- console_mutex.lock();
- cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
- << block << endl;
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
+ << block << endl;
+ }
for (k = 0; k < num; ++k) {
res = do_rd_inc_wr_twice(dev_name, lba, block, excl, wait_ms, k,
thr_ebusy_count, thr_eagain_count);
@@ -482,18 +507,22 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
if (res)
++thr_odd_count;
}
- console_mutex.lock();
- if (k < num)
- cerr << "thread id=" << id << " FAILed at iteration: " << k << '\n';
- else
- cerr << "thread id=" << id << " normal exit" << '\n';
- console_mutex.unlock();
-
- odd_count_mutex.lock();
- odd_count += thr_odd_count;
- ebusy_count += thr_ebusy_count;
- eagain_count += thr_eagain_count;
- odd_count_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ if (k < num)
+ cerr << "thread id=" << id << " FAILed at iteration: " << k <<
+ '\n';
+ else
+ cerr << "thread id=" << id << " normal exit" << '\n';
+ }
+ {
+ lock_guard<mutex> lg(odd_count_mutex);
+
+ odd_count += thr_odd_count;
+ ebusy_count += thr_ebusy_count;
+ eagain_count += thr_eagain_count;
+ }
}
diff --git a/examples/sg_tst_excl2.cpp b/examples/sg_tst_excl2.cpp
index cec1c9e3..24d3677b 100644
--- a/examples/sg_tst_excl2.cpp
+++ b/examples/sg_tst_excl2.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Douglas Gilbert.
+ * Copyright (c) 2013-2014 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,7 @@
#include "sg_lib.h"
#include "sg_pt.h"
-static const char * version_str = "1.06 20131110";
+static const char * version_str = "1.07 20140828";
static const char * util_name = "sg_tst_excl2";
/* This is a test program for checking O_EXCL on open() works. It uses
@@ -134,6 +134,7 @@ usage(void)
"on lba (using its first 4 bytes).\n");
}
+/* Assumed a lock (mutex) held when pt_err() is called */
static int
pt_err(int res)
{
@@ -148,6 +149,7 @@ pt_err(int res)
return -1;
}
+/* Assumed a lock (mutex) held when pt_cat_no_good() is called */
static int
pt_cat_no_good(int cat, struct sg_pt_base * ptp, const unsigned char * sbp)
{
@@ -229,9 +231,11 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
if (sg_fd < 0) {
snprintf(ebuff, EBUFF_SZ,
"do_rd_inc_wr_twice: error opening file: %s", dev_name);
- console_mutex.lock();
- perror(ebuff);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror(ebuff);
+ }
return -1;
}
@@ -244,18 +248,22 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
set_scsi_pt_data_in(ptp, lb, READ16_REPLY_LEN);
res = do_scsi_pt(ptp, sg_fd, 20 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "READ_16 do_scsi_pt() submission error\n");
- res = pt_err(res);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "READ_16 do_scsi_pt() submission error\n");
+ res = pt_err(res);
+ }
goto err;
}
cat = get_scsi_pt_result_category(ptp);
if (SCSI_PT_RESULT_GOOD != cat) {
- console_mutex.lock();
- fprintf(stderr, "READ_16 do_scsi_pt() category problem\n");
- console_mutex.unlock();
- res = pt_cat_no_good(cat, ptp, sense_buffer);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "READ_16 do_scsi_pt() category problem\n");
+ res = pt_cat_no_good(cat, ptp, sense_buffer);
+ }
goto err;
}
@@ -283,18 +291,22 @@ do_rd_inc_wr_twice(const char * dev_name, unsigned int lba, int block,
set_scsi_pt_data_out(ptp, lb, WRITE16_REPLY_LEN);
res = do_scsi_pt(ptp, sg_fd, 20 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "WRITE_16 do_scsi_pt() submission error\n");
- res = pt_err(res);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "WRITE_16 do_scsi_pt() submission error\n");
+ res = pt_err(res);
+ }
goto err;
}
cat = get_scsi_pt_result_category(ptp);
if (SCSI_PT_RESULT_GOOD != cat) {
- console_mutex.lock();
- fprintf(stderr, "WRITE_16 do_scsi_pt() category problem\n");
- console_mutex.unlock();
- res = pt_cat_no_good(cat, ptp, sense_buffer);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "WRITE_16 do_scsi_pt() category problem\n");
+ res = pt_cat_no_good(cat, ptp, sense_buffer);
+ }
goto err;
}
}
@@ -352,14 +364,22 @@ do_inquiry_prod_id(const char * dev_name, int block, int wait_ms,
set_scsi_pt_data_in(ptp, inqBuff, INQ_REPLY_LEN);
res = do_scsi_pt(ptp, sg_fd, 20 /* secs timeout */, 1);
if (res) {
- fprintf(stderr, "INQUIRY do_scsi_pt() submission error\n");
- res = pt_err(res);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "INQUIRY do_scsi_pt() submission error\n");
+ res = pt_err(res);
+ }
goto err;
}
cat = get_scsi_pt_result_category(ptp);
if (SCSI_PT_RESULT_GOOD != cat) {
- fprintf(stderr, "INQUIRY do_scsi_pt() category problem\n");
- res = pt_cat_no_good(cat, ptp, sense_buffer);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "INQUIRY do_scsi_pt() category problem\n");
+ res = pt_cat_no_good(cat, ptp, sense_buffer);
+ }
goto err;
}
@@ -388,10 +408,12 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
unsigned int thr_ebusy_count = 0;
int k, res;
- console_mutex.lock();
- cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
- << block << endl;
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
+ << block << endl;
+ }
for (k = 0; k < num; ++k) {
res = do_rd_inc_wr_twice(dev_name, lba, block, excl, wait_ms,
thr_ebusy_count);
@@ -400,17 +422,22 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
if (res)
++thr_odd_count;
}
- console_mutex.lock();
- if (k < num)
- cerr << "thread id=" << id << " FAILed at iteration: " << k << '\n';
- else
- cerr << "thread id=" << id << " normal exit" << '\n';
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ if (k < num)
+ cerr << "thread id=" << id << " FAILed at iteration: " << k <<
+ '\n';
+ else
+ cerr << "thread id=" << id << " normal exit" << '\n';
+ }
+
+ {
+ lock_guard<mutex> lg(odd_count_mutex);
- odd_count_mutex.lock();
- odd_count += thr_odd_count;
- ebusy_count += thr_ebusy_count;
- odd_count_mutex.unlock();
+ odd_count += thr_odd_count;
+ ebusy_count += thr_ebusy_count;
+ }
}
diff --git a/examples/sg_tst_excl3.cpp b/examples/sg_tst_excl3.cpp
index c4052a90..6b6b880b 100644
--- a/examples/sg_tst_excl3.cpp
+++ b/examples/sg_tst_excl3.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Douglas Gilbert.
+ * Copyright (c) 2013-2014 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,7 @@
#include "sg_lib.h"
#include "sg_pt.h"
-static const char * version_str = "1.04 20131110";
+static const char * version_str = "1.05 20140828";
static const char * util_name = "sg_tst_excl3";
/* This is a test program for checking O_EXCL on open() works. It uses
@@ -140,6 +140,7 @@ usage(void)
"value is even.\n");
}
+/* Assumed a lock (mutex) held when pt_err() is called */
static int
pt_err(int res)
{
@@ -154,6 +155,7 @@ pt_err(int res)
return -1;
}
+/* Assumed a lock (mutex) held when pt_cat_no_good() is called */
static int
pt_cat_no_good(int cat, struct sg_pt_base * ptp, const unsigned char * sbp)
{
@@ -235,9 +237,11 @@ do_rd_inc_wr_twice(const char * dev_name, int read_only, unsigned int lba,
if (sg_fd < 0) {
snprintf(ebuff, EBUFF_SZ,
"do_rd_inc_wr_twice: error opening file: %s", dev_name);
- console_mutex.lock();
- perror(ebuff);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ perror(ebuff);
+ }
return -1;
}
@@ -250,18 +254,22 @@ do_rd_inc_wr_twice(const char * dev_name, int read_only, unsigned int lba,
set_scsi_pt_data_in(ptp, lb, READ16_REPLY_LEN);
res = do_scsi_pt(ptp, sg_fd, 20 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "READ_16 do_scsi_pt() submission error\n");
- res = pt_err(res);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "READ_16 do_scsi_pt() submission error\n");
+ res = pt_err(res);
+ }
goto err;
}
cat = get_scsi_pt_result_category(ptp);
if (SCSI_PT_RESULT_GOOD != cat) {
- console_mutex.lock();
- fprintf(stderr, "READ_16 do_scsi_pt() category problem\n");
- console_mutex.unlock();
- res = pt_cat_no_good(cat, ptp, sense_buffer);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "READ_16 do_scsi_pt() category problem\n");
+ res = pt_cat_no_good(cat, ptp, sense_buffer);
+ }
goto err;
}
@@ -292,18 +300,22 @@ do_rd_inc_wr_twice(const char * dev_name, int read_only, unsigned int lba,
set_scsi_pt_data_out(ptp, lb, WRITE16_REPLY_LEN);
res = do_scsi_pt(ptp, sg_fd, 20 /* secs timeout */, 1);
if (res) {
- console_mutex.lock();
- fprintf(stderr, "WRITE_16 do_scsi_pt() submission error\n");
- res = pt_err(res);
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "WRITE_16 do_scsi_pt() submission error\n");
+ res = pt_err(res);
+ }
goto err;
}
cat = get_scsi_pt_result_category(ptp);
if (SCSI_PT_RESULT_GOOD != cat) {
- console_mutex.lock();
- fprintf(stderr, "WRITE_16 do_scsi_pt() category problem\n");
- console_mutex.unlock();
- res = pt_cat_no_good(cat, ptp, sense_buffer);
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ fprintf(stderr, "WRITE_16 do_scsi_pt() category problem\n");
+ res = pt_cat_no_good(cat, ptp, sense_buffer);
+ }
goto err;
}
}
@@ -397,10 +409,12 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
int k, res;
int reader = ((id > 0) || (all_readers));
- console_mutex.lock();
- cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
- << block << " reader=" << reader << endl;
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ cerr << "Enter work_thread id=" << id << " excl=" << excl << " block="
+ << block << " reader=" << reader << endl;
+ }
for (k = 0; k < num; ++k) {
res = do_rd_inc_wr_twice(dev_name, reader, lba, block, excl,
wait_ms, thr_ebusy_count);
@@ -409,17 +423,22 @@ work_thread(const char * dev_name, unsigned int lba, int id, int block,
if (res)
++thr_odd_count;
}
- console_mutex.lock();
- if (k < num)
- cerr << "thread id=" << id << " FAILed at iteration: " << k << '\n';
- else
- cerr << "thread id=" << id << " normal exit" << '\n';
- console_mutex.unlock();
+ {
+ lock_guard<mutex> lg(console_mutex);
+
+ if (k < num)
+ cerr << "thread id=" << id << " FAILed at iteration: " << k
+ << '\n';
+ else
+ cerr << "thread id=" << id << " normal exit" << '\n';
+ }
- odd_count_mutex.lock();
- odd_count += thr_odd_count;
- ebusy_count += thr_ebusy_count;
- odd_count_mutex.unlock();
+ {
+ lock_guard<mutex> lg(odd_count_mutex);
+
+ odd_count += thr_odd_count;
+ ebusy_count += thr_ebusy_count;
+ }
}
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index abcdaa19..3894de2e 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -46,6 +46,11 @@
#define ASCQ_ATA_PT_INFO_AVAILABLE 0x1d /* corresponding ASC is 0 */
+/* The following two opcodes were renamed to 'Third party copy out/in' in
+ * spc4r34 */
+#define SG_THIRD_PARTY_COPY_OUT SG_EXTENDED_COPY
+#define SG_THIRD_PARTY_COPY_IN SG_RECEIVE_COPY
+
FILE * sg_warnings_strm = NULL; /* would like to default to stderr */
@@ -1200,12 +1205,39 @@ sg_get_command_name(const unsigned char * cmdp, int peri_type, int buff_len,
sg_get_opcode_sa_name(cmdp[0], service_action, peri_type, buff_len, buff);
}
+struct op_code2sa_t {
+ int op_code;
+ struct sg_lib_value_name_t * arr;
+ const char * prefix;
+};
+
+static struct op_code2sa_t op_code2sa_arr[] = {
+ {SG_VARIABLE_LENGTH_CMD, sg_lib_variable_length_arr, NULL},
+ {SG_MAINTENANCE_IN, sg_lib_maint_in_arr, NULL},
+ {SG_MAINTENANCE_OUT, sg_lib_maint_out_arr, NULL},
+ {SG_SERVICE_ACTION_IN_12, sg_lib_serv_in12_arr, NULL},
+ {SG_SERVICE_ACTION_OUT_12, sg_lib_serv_out12_arr, NULL},
+ {SG_SERVICE_ACTION_IN_16, sg_lib_serv_in16_arr, NULL},
+ {SG_SERVICE_ACTION_OUT_16, sg_lib_serv_out16_arr, NULL},
+ {SG_SERVICE_ACTION_BIDI, sg_lib_serv_bidi_arr, NULL},
+ {SG_PERSISTENT_RESERVE_IN, sg_lib_pr_in_arr, "Persistent reserve in"},
+ {SG_PERSISTENT_RESERVE_OUT, sg_lib_pr_out_arr, "Persistent reserve out"},
+ {SG_THIRD_PARTY_COPY_OUT, sg_lib_xcopy_sa_arr, NULL},
+ {SG_THIRD_PARTY_COPY_IN, sg_lib_rec_copy_sa_arr, NULL},
+ {SG_READ_BUFFER, sg_lib_read_buff_arr, "Read buffer"},
+ {SG_WRITE_BUFFER, sg_lib_write_buff_arr, "Write buffer"},
+ {SG_SANITIZE, sg_lib_sanitize_sa_arr, "Sanitize"},
+ {0xffff, NULL, NULL},
+};
+
void
sg_get_opcode_sa_name(unsigned char cmd_byte0, int service_action,
int peri_type, int buff_len, char * buff)
{
const struct sg_lib_value_name_t * vnp;
+ const struct op_code2sa_t * osp;
+ char b[80];
if ((NULL == buff) || (buff_len < 1))
return;
@@ -1213,133 +1245,26 @@ sg_get_opcode_sa_name(unsigned char cmd_byte0, int service_action,
buff[0] = '\0';
return;
}
- switch ((int)cmd_byte0) {
- case SG_VARIABLE_LENGTH_CMD:
- vnp = get_value_name(sg_lib_variable_length_arr, service_action,
- peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Variable length service action=0x%x",
- service_action);
- break;
- case SG_MAINTENANCE_IN:
- vnp = get_value_name(sg_lib_maint_in_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Maintenance in service action=0x%x",
- service_action);
- break;
- case SG_MAINTENANCE_OUT:
- vnp = get_value_name(sg_lib_maint_out_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Maintenance out service action=0x%x",
- service_action);
- break;
- case SG_SERVICE_ACTION_IN_12:
- vnp = get_value_name(sg_lib_serv_in12_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Service action in(12)=0x%x",
- service_action);
- break;
- case SG_SERVICE_ACTION_OUT_12:
- vnp = get_value_name(sg_lib_serv_out12_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Service action out(12)=0x%x",
- service_action);
- break;
- case SG_SERVICE_ACTION_IN_16:
- vnp = get_value_name(sg_lib_serv_in16_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Service action in(16)=0x%x",
- service_action);
- break;
- case SG_SERVICE_ACTION_OUT_16:
- vnp = get_value_name(sg_lib_serv_out16_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Service action out(16)=0x%x",
- service_action);
- break;
- case SG_PERSISTENT_RESERVE_IN:
- vnp = get_value_name(sg_lib_pr_in_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Persistent reserve in, service "
- "action=0x%x", service_action);
- break;
- case SG_PERSISTENT_RESERVE_OUT:
- vnp = get_value_name(sg_lib_pr_out_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Persistent reserve out, service "
- "action=0x%x", service_action);
- break;
- case SG_EXTENDED_COPY:
- /* 'Extended copy' was renamed 'Third party copy out' in spc4r34 */
- vnp = get_value_name(sg_lib_xcopy_sa_arr, service_action, peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Third party copy out, service "
- "action=0x%x", service_action);
- break;
- case SG_RECEIVE_COPY:
- /* 'Receive copy results' was renamed 'Third party copy in' in
- * spc4r34 */
- vnp = get_value_name(sg_lib_rec_copy_sa_arr, service_action,
- peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Third party copy in, service "
- "action=0x%x", service_action);
- break;
- case SG_READ_BUFFER:
- /* spc4r34 requested treating mode as service action */
- vnp = get_value_name(sg_lib_read_buff_arr, service_action,
- peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "Read buffer, %s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Read buffer, mode=0x%x",
- service_action);
- break;
- case SG_WRITE_BUFFER:
- /* spc4r34 requested treating mode as service action */
- vnp = get_value_name(sg_lib_write_buff_arr, service_action,
- peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "Write buffer, %s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Write buffer, mode=0x%x",
- service_action);
- break;
- case SG_SANITIZE:
- vnp = get_value_name(sg_lib_sanitize_sa_arr, service_action,
- peri_type);
- if (vnp)
- my_snprintf(buff, buff_len, "%s", vnp->name);
- else
- my_snprintf(buff, buff_len, "Sanitize, service action=0x%x",
- service_action);
- break;
- default:
- sg_get_opcode_name(cmd_byte0, peri_type, buff_len, buff);
- break;
+
+ for (osp = op_code2sa_arr; osp->arr; ++osp) {
+ if ((int)cmd_byte0 == osp->op_code) {
+ vnp = get_value_name(osp->arr, service_action, peri_type);
+ if (vnp) {
+ if (osp->prefix)
+ my_snprintf(buff, buff_len, "%s, %s", osp->prefix,
+ vnp->name);
+ else
+ my_snprintf(buff, buff_len, "%s", vnp->name);
+ } else {
+ sg_get_opcode_name(cmd_byte0, peri_type, sizeof(b), b);
+ my_snprintf(buff, buff_len, "%s service action=0x%x",
+ b, service_action);
+ }
+ return;
+ }
}
+
+ sg_get_opcode_name(cmd_byte0, peri_type, buff_len, buff);
}
void
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 22c00462..c96633b2 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -17,7 +17,7 @@
#endif
-const char * sg_lib_version_str = "2.04 20140812"; /* spc4r37, sbc4r02 */
+const char * sg_lib_version_str = "2.05 20140828"; /* spc4r37a, sbc4r02 */
#ifdef SG_SCSI_STRINGS
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
@@ -213,7 +213,7 @@ struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0xffff, 0, NULL},
};
-/* Read buffer [0x3c] service actions */
+/* Read buffer [0x3c] service actions, need prefix */
struct sg_lib_value_name_t sg_lib_read_buff_arr[] = {
{0x0, 0, "combined header and data [or multiple modes]"},
{0x2, 0, "data"},
@@ -225,7 +225,7 @@ struct sg_lib_value_name_t sg_lib_read_buff_arr[] = {
{0xffff, 0, NULL},
};
-/* Write buffer [0x3b] service actions */
+/* Write buffer [0x3b] service actions, need prefix */
struct sg_lib_value_name_t sg_lib_write_buff_arr[] = {
{0x0, 0, "combined header and data [or multiple modes]"},
{0x2, 0, "data"},
@@ -273,12 +273,12 @@ struct sg_lib_value_name_t sg_lib_maint_out_arr[] = {
{0xffff, 0, NULL},
};
-/* Sanitize [0x48] service actions */
+/* Sanitize [0x48] service actions, need prefix */
struct sg_lib_value_name_t sg_lib_sanitize_sa_arr[] = {
- {0x1, 0, "Sanitize, overwrite"},
- {0x2, 0, "Sanitize, block erase"},
- {0x3, 0, "Sanitize, cryptographic erase"},
- {0x1f, 0, "Sanitize, exit failure mode"},
+ {0x1, 0, "overwrite"},
+ {0x2, 0, "block erase"},
+ {0x3, 0, "cryptographic erase"},
+ {0x1f, 0, "exit failure mode"},
{0xffff, 0, NULL},
};
@@ -317,26 +317,26 @@ struct sg_lib_value_name_t sg_lib_serv_bidi_arr[] = {
{0xffff, 0, NULL},
};
-/* Persistent reserve in [0x5e] service actions */
+/* Persistent reserve in [0x5e] service actions, need prefix */
struct sg_lib_value_name_t sg_lib_pr_in_arr[] = {
- {0x0, 0, "Persistent reserve in, read keys"},
- {0x1, 0, "Persistent reserve in, read reservation"},
- {0x2, 0, "Persistent reserve in, report capabilities"},
- {0x3, 0, "Persistent reserve in, read full status"},
+ {0x0, 0, "read keys"},
+ {0x1, 0, "read reservation"},
+ {0x2, 0, "report capabilities"},
+ {0x3, 0, "read full status"},
{0xffff, 0, NULL},
};
-/* Persistent reserve out [0x5f] service actions */
+/* Persistent reserve out [0x5f] service actions, need prefix */
struct sg_lib_value_name_t sg_lib_pr_out_arr[] = {
- {0x0, 0, "Persistent reserve out, register"},
- {0x1, 0, "Persistent reserve out, reserve"},
- {0x2, 0, "Persistent reserve out, release"},
- {0x3, 0, "Persistent reserve out, clear"},
- {0x4, 0, "Persistent reserve out, preempt"},
- {0x5, 0, "Persistent reserve out, preempt and abort"},
- {0x6, 0, "Persistent reserve out, register and ignore existing key"},
- {0x7, 0, "Persistent reserve out, register and move"},
- {0x8, 0, "Persistent reserve out, replace lost reservation"},
+ {0x0, 0, "register"},
+ {0x1, 0, "reserve"},
+ {0x2, 0, "release"},
+ {0x3, 0, "clear"},
+ {0x4, 0, "preempt"},
+ {0x5, 0, "preempt and abort"},
+ {0x6, 0, "register and ignore existing key"},
+ {0x7, 0, "register and move"},
+ {0x8, 0, "replace lost reservation"},
{0xffff, 0, NULL},
};
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 89ba264b..548a27b7 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Mon Aug 11 2014 - dgilbert at interlog dot com
+* Fri Aug 29 2014 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.40
diff --git a/src/sg_raw.c b/src/sg_raw.c
index 9380d32c..6b2d01bc 100644
--- a/src/sg_raw.c
+++ b/src/sg_raw.c
@@ -27,7 +27,7 @@
#include "sg_lib.h"
#include "sg_pt.h"
-#define SG_RAW_VERSION "0.4.9 (2014-05-14)"
+#define SG_RAW_VERSION "0.4.10 (2014-08-29)"
#ifdef SG_LIB_WIN32
#ifndef HAVE_SYSCONF
@@ -242,7 +242,20 @@ process_cl(struct opts_t * op, int argc, char *argv[])
fprintf(stderr, "CDB too short (min. %d bytes)\n", MIN_SCSI_CDBSZ);
return SG_LIB_SYNTAX_ERROR;
}
-
+ if (op->do_verbose > 2) {
+ int sa;
+ char b[80];
+
+ if (op->cdb_length > 16) {
+ sa = (op->cdb[8] << 8) + op->cdb[9];
+ if (0x7f != op->cdb[0])
+ printf(">>> Unlikely to be SCSI CDB since all over 16 "
+ "bytes long should\n>>> start with 0x7f\n");
+ } else
+ sa = op->cdb[1] & 0x1f;
+ sg_get_opcode_sa_name(op->cdb[0], sa, 0, sizeof(b), b);
+ printf("Attempt to decode cdb name: %s\n", b);
+ }
return 0;
}