aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-09-26 21:41:45 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-09-26 21:41:45 +0000
commit4215af6d171de0b80bdace8448a687970209cf15 (patch)
tree404f89bd0b463f030e38680e0471f19201bcf482
parentccefa8190c1f38cb71384bcdd786599db7de570a (diff)
downloadsg3_utils-4215af6d171de0b80bdace8448a687970209cf15.tar.gz
rescan-scsi-bus.sh speed testonline()
speed testonline() function when peripheral_qualifier != 0 in the standard INQUIRY response. See: https://github.com/doug-gilbert/sg3_utils/issues/24 git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@972 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog4
-rw-r--r--doc/sg_logs.818
-rw-r--r--doc/sg_opcodes.84
-rwxr-xr-xscripts/rescan-scsi-bus.sh4
-rw-r--r--src/sg_logs.c43
5 files changed, 49 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 00fb98d1..1a9d3b40 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 pre-release sg3_utils-1.48 [20220917] [svn: r971]
+Changelog for pre-release sg3_utils-1.48 [20220926] [svn: r972]
- some utilities: add experimental --json[=JO] option
- sg_z_act_query: new utility for sending either a
Zone activate or Zone query command
@@ -27,6 +27,8 @@ Changelog for pre-release sg3_utils-1.48 [20220917] [svn: r971]
is not added
- add -no-lip-scan option
- https://github.com/doug-gilbert/sg3_utils/pull/21
+ - speed testonline() when peripheral_qualifier != 0
+ see https://github.com/doug-gilbert/sg3_utils/issues/24
- sg_rep_zones: add Report zone starting LBA granularity
field in REPORT ZONES response [zbc2r12]
- add --brief option, show part of header and last
diff --git a/doc/sg_logs.8 b/doc/sg_logs.8
index 60f4faa6..7ced1320 100644
--- a/doc/sg_logs.8
+++ b/doc/sg_logs.8
@@ -1,20 +1,20 @@
-.TH SG_LOGS "8" "April 2022" "sg3_utils\-1.48" SG3_UTILS
+.TH SG_LOGS "8" "September 2022" "sg3_utils\-1.48" SG3_UTILS
.SH NAME
sg_logs \- access log pages with SCSI LOG SENSE command
.SH SYNOPSIS
.B sg_logs
[\fI\-\-ALL\fR] [\fI\-\-all\fR] [\fI\-\-brief\fR] [\fI\-\-exclude\fR]
-[\fI\-\-filter=FL\fR] [\fI\-\-hex\fR] [\fI\-\-list\fR] [\fI\-\-maxlen=LEN\fR]
-[\fI\-\-name\fR] [\fI\-\-no_inq\fR] [\fI\-\-page=PG\fR] [\fI\-\-paramp=PP\fR]
-[\fI\-\-pcb\fR] [\fI\-\-ppc\fR] [\fI\-\-pdt=DT\fR] [\fI\-\-raw\fR]
-[\fI\-\-readonly\fR] [\fI\-\-sp\fR] [\fI\-\-temperature\fR]
+[\fI\-\-filter=FL\fR] [\fI\-\-hex\fR] [\fI\-\-json[=JO]\fR] [\fI\-\-list\fR]
+[\fI\-\-maxlen=LEN\fR] [\fI\-\-name\fR] [\fI\-\-no_inq\fR] [\fI\-\-page=PG\fR]
+[\fI\-\-paramp=PP\fR] [\fI\-\-pcb\fR] [\fI\-\-ppc\fR] [\fI\-\-pdt=DT\fR]
+[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-sp\fR] [\fI\-\-temperature\fR]
[\fI\-\-transport\fR] [\fI\-\-undefined\fR] [\fI\-\-vendor=VP\fR]
[\fI\-\-verbose\fR] \fIDEVICE\fR
.PP
.B sg_logs
\fI\-\-in=FN\fR [\fI\-\-brief\fR] [\fI\-\-exclude\fR] [\fI\-\-filter=FL\fR]
-[\fI\-\-hex\fR] [\fI\-\-name\fR] [\fI\-\-pdt=DT\fR] [\fI\-\-raw\fR]
-[\fI\-\-undefined\fR] [\fI\-\-vendor=VP\fR]
+[\fI\-\-hex\fR] [\fI\-\-json[=JO]\fR] [\fI\-\-name\fR] [\fI\-\-pdt=DT\fR]
+[\fI\-\-raw\fR] [\fI\-\-undefined\fR] [\fI\-\-vendor=VP\fR]
.PP
.B sg_logs
\fI\-\-select\fR [\fI\-\-control=PC\fR] [\fI\-\-page=PG\fR] [\fI\-\-raw\fR]
@@ -188,6 +188,10 @@ treated as binary.
For compatibility with other utilities in this package "inhex" may also be
used as this (long) option name.
.TP
+\fB\-j\fR, \fB\-\-json[\fR=\fIJO\fR]
+output is in JSON format instead of human readable form. See sg3_utils_json
+manpage or use '?' for \fIJO\fR for a summary.
+.TP
\fB\-l\fR, \fB\-\-list\fR
lists the names of the logs sense pages supported by this device. This is
done by reading the "supported log pages" log page. When used once only
diff --git a/doc/sg_opcodes.8 b/doc/sg_opcodes.8
index 26cfd1fb..21d148be 100644
--- a/doc/sg_opcodes.8
+++ b/doc/sg_opcodes.8
@@ -1,10 +1,10 @@
-.TH SG_OPCODES "8" "August 2022" "sg3_utils\-1.48" SG3_UTILS
+.TH SG_OPCODES "8" "September 2022" "sg3_utils\-1.48" SG3_UTILS
.SH NAME
sg_opcodes \- report supported SCSI commands or task management functions
.SH SYNOPSIS
.B sg_opcodes
[\fI\-\-alpha\fR] [\fI\-\-compact\fR] [\fI\-\-enumerate\fR] [\fI\-\-help\fR]
-[\fI\-\-hex\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-json[=JO\fR]] [\fI\-\-mask\fR]
+[\fI\-\-hex\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-json[=JO]\fR] [\fI\-\-mask\fR]
[\fI\-\-mlu\fR] [\fI\-\-no-inquiry\fR] [\fI\-\-opcode=OP[,SA]\fR]
[\fI\-\-pdt=DT\fR] [\fI\-\-raw\fR] [\fI\-\-rctd\fR] [\fI\-\-repd\fR]
[\fI\-\-sa=SA\fR] [\fI\-\-tmf\fR] [\fI\-\-unsorted\fR] [\fI\-\-verbose\fR]
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index e9bccbac..f0105cf8 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -4,7 +4,7 @@
# (c) 2006--2022 Hannes Reinecke, GNU GPL v2 or later
# $Id: rescan-scsi-bus.sh,v 1.57 2012/03/31 14:08:48 garloff Exp $
-VERSION="20220811"
+VERSION="20220926"
SCAN_WILD_CARD=4294967295
setcolor ()
@@ -276,7 +276,7 @@ testonline ()
# Handle in progress of becoming ready and unit attention
while [ $RC = 2 -o $RC = 6 ] && [ $ctr -lt $timeout ] ; do
- if [ $RC = 2 ] && [ "$RMB" != "1" ] ; then
+ if [ $RC = 2 ] && [ "$RMB" != "1" ] && [ sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ] ; then
echo -n "."
let LN+=1
sleep 1
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 6f5edd48..0f90d803 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -37,7 +37,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "2.00 20220816"; /* spc6r06 + sbc5r03 */
+static const char * version_str = "2.01 20220923"; /* spc6r06 + sbc5r03 */
#define MX_ALLOC_LEN (0xfffc)
#define MX_INLEN_ALLOC_LEN (0x800000)
@@ -133,6 +133,7 @@ static struct option long_options[] = {
{"hex", no_argument, 0, 'H'},
{"in", required_argument, 0, 'i'},
{"inhex", required_argument, 0, 'i'},
+ {"json", optional_argument, 0, 'j'},
{"list", no_argument, 0, 'l'},
{"maxlen", required_argument, 0, 'm'},
{"name", no_argument, 0, 'n'},
@@ -201,6 +202,7 @@ struct opts_t {
const char * pg_arg;
const char * vend_prod;
const struct log_elem * lep;
+ sgj_state json_st;
};
@@ -513,15 +515,15 @@ usage(int hval)
"[--enumerate]\n"
" [--exclude] [--filter=FL] [--help] [--hex] "
"[--in=FN]\n"
- " [--list] [--no_inq] [--maxlen=LEN] [--name] "
- "[--page=PG]\n"
- " [--paramp=PP] [--pcb] [--ppc] [--pdt=DT] "
- "[--raw]\n"
- " [--readonly] [--reset] [--select] [--sp] "
- "[--undefined]\n"
- " [--temperature] [--transport] [--vendor=VP] "
- "[--verbose]\n"
- " [--version] DEVICE\n"
+ " [--json[=JO]] [--list] [--no_inq] [--maxlen=LEN] "
+ "[--name] "
+ " [--page=PG] [--paramp=PP] [--pcb] [--ppc] "
+ "[--pdt=DT]\n"
+ " [--raw] [--readonly] [--reset] [--select] "
+ "[--sp]\n"
+ " [--undefined] [--temperature] [--transport] "
+ "[--vendor=VP]\n"
+ " [--verbose] [--version] DEVICE\n"
" where the main options are:\n"
" --ALL|-A fetch and decode all log pages and "
"subpages\n"
@@ -549,6 +551,9 @@ usage(int hval)
"in ASCII hex\n"
" or binary if --raw also given. --inhex=FN "
"also accepted\n"
+ " --json[=JO]|-jJO output in JSON instead of human "
+ "readable\n"
+ " test. Use --json=? for JSON help\n"
" --list|-l list supported log pages; twice: list "
"supported log\n"
" pages and subpages page; thrice: merge of "
@@ -944,8 +949,8 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
int c, n;
int option_index = 0;
- c = getopt_long(argc, argv, "aAbc:D:eEf:hHi:lLm:M:nNOp:P:qQrRsStTuvV"
- "xX", long_options, &option_index);
+ c = getopt_long(argc, argv, "aAbc:D:eEf:hHi:j::lLm:M:nNOp:P:qQrRsStT"
+ "uvVxX", long_options, &option_index);
if (c == -1)
break;
@@ -1015,6 +1020,20 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[])
case 'i':
op->in_fn = optarg;
break;
+ case 'j':
+ if (! sgj_init_state(&op->json_st, optarg)) {
+ int bad_char = op->json_st.first_bad_char;
+ char e[1500];
+
+ if (bad_char) {
+ pr2serr("bad argument to --json= option, unrecognized "
+ "character '%c'\n\n", bad_char);
+ }
+ sg_json_usage(0, e, sizeof(e));
+ pr2serr("%s", e);
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
case 'l':
++op->do_list;
break;