aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-11-04 15:43:37 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-11-04 15:43:37 +0000
commit20f3fcb175b72c06464965a4bce7d0a5eaef47b9 (patch)
tree8c41fd7b2b61e624620c3eb377c54c073a02cc99
parent44e90986b1aea4296ba69198130fd37a9ffca082 (diff)
downloadsg3_utils-20f3fcb175b72c06464965a4bce7d0a5eaef47b9.tar.gz
add two new exit status values: SG_LIB_CAT_STANDBY and SG_LIB_CAT_UNAVAILABLE which refine the 'not ready' exit status
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@980 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog7
-rw-r--r--doc/sg3_utils.89
-rw-r--r--include/sg_lib.h8
-rw-r--r--lib/sg_cmds_basic.c2
-rw-r--r--lib/sg_lib.c4
-rw-r--r--lib/sg_lib_data.c4
-rw-r--r--src/sg_turs.c14
7 files changed, 44 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 823fd921..9719309d 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 [20221103] [svn: r979]
+Changelog for pre-release sg3_utils-1.48 [20221104] [svn: r980]
- some utilities: add experimental --json[=JO] option
- sg_z_act_query: new utility for sending either a
Zone activate or Zone query command
@@ -69,6 +69,7 @@ Changelog for pre-release sg3_utils-1.48 [20221103] [svn: r979]
- sg_ses: add exp_sas_addr acronym for getting expander's
SAS address
- sg_turs: change nanosleep() to Sleep() in MinGW
+ - see sg_lib below for two new exit status values
- sg_stream_ctl: fix --get indexing
- sg_read_block_limits: fix granularity value
- add --mloi option
@@ -86,6 +87,10 @@ Changelog for pre-release sg3_utils-1.48 [20221103] [svn: r979]
for ata-passthrough (lba field), see:
https://github.com/doug-gilbert/sg3_utils/pull/25
- add sg_ll_read_block_limits_v2() for MLOI bit
+ - https://github.com/doug-gilbert/sg3_utils/pull/32 added
+ with tweaks; adds SG_LIB_CAT_STANDBY and
+ SG_LIB_CAT_UNAVAILABLE which refine the 'not ready'
+ exit status. Useful for sg_turs
- initialize all sense buffers to 0
- linux: replace references to /proc/scsi/sg with
/sys/module/sg/parameters/
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index c65af9aa..d038cb51 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -318,6 +318,7 @@ the \fIDEVICE\fR reports that it is not ready for the operation requested.
The \fIDEVICE\fR may be in the process of becoming ready (e.g. spinning up
but not at speed) so the utility may work after a wait. In Linux the
\fIDEVICE\fR may be temporarily blocked while error recovery is taking place.
+See exit status values 12 and 13 below which refine this exit value.
.TP
.B 3
the \fIDEVICE\fR reports a medium or hardware error (or a blank check). For
@@ -356,6 +357,14 @@ the \fIDEVICE\fR reports an aborted command. In some cases aborted
commands can be retried immediately (e.g. if the transport aborted
the command due to congestion).
.TP
+.B 12
+the \fIDEVICE\fR reports a sense key of not ready together with an
+additional sense code of "target port in standby state".
+.TP
+.B 13
+the \fIDEVICE\fR reports a sense key of not ready together with an
+additional sense code of "target port in unavailable state".
+.TP
.B 14
the \fIDEVICE\fR reports a miscompare sense key. VERIFY and COMPARE AND
WRITE commands may report this.
diff --git a/include/sg_lib.h b/include/sg_lib.h
index e6a267d5..41545ee9 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -488,8 +488,8 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char * b);
#define SG_LIB_CAT_CLEAN 0 /* No errors or other information */
#define SG_LIB_OK_TRUE SG_LIB_CAT_CLEAN /* No error, reporting true */
/* Value 1 left unused for utilities to use SG_LIB_SYNTAX_ERROR */
-#define SG_LIB_CAT_NOT_READY 2 /* sense key, unit stopped?
- * [sk,asc,ascq: 0x2,*,*] */
+#define SG_LIB_CAT_NOT_READY 2 /* sense key: not ready, see 12 and 13
+ * [sk,asc,ascq: 0x2,<most>,<most>] */
#define SG_LIB_CAT_MEDIUM_HARD 3 /* medium or hardware error, blank check
* [sk,asc,ascq: 0x3/0x4/0x8,*,*] */
#define SG_LIB_CAT_ILLEGAL_REQ 5 /* Illegal request (other than invalid
@@ -505,6 +505,10 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char * b);
* [sk,asc,ascq: 0xa,*,*] */
#define SG_LIB_CAT_ABORTED_COMMAND 11 /* interpreted from sense buffer
* [sk,asc,ascq: 0xb,! 0x10,*] */
+#define SG_LIB_CAT_STANDBY 12 /* sense key: not ready, special case
+ * [sk,asc, ascq: 0x2, 0x4, 0xb] */
+#define SG_LIB_CAT_UNAVAILABLE 13 /* sense key: not ready, special case
+ * [sk,asc, ascq: 0x2, 0x4, 0xc] */
#define SG_LIB_CAT_MISCOMPARE 14 /* sense key, probably verify
* [sk,asc,ascq: 0xe,*,*] */
#define SG_LIB_FILE_ERROR 15 /* device or other file problem */
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 4dffe1ce..01ca55c1 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -126,6 +126,8 @@ sg_cmds_process_helper(const char * leadin, int req_din_x, int act_din_x,
case SG_LIB_CAT_PROTECTION:
case SG_LIB_CAT_NO_SENSE:
case SG_LIB_CAT_MISCOMPARE:
+ case SG_LIB_CAT_STANDBY:
+ case SG_LIB_CAT_UNAVAILABLE:
n = false;
break;
case SG_LIB_CAT_RECOVERED:
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index f0ed986f..36fcf5cd 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -2244,6 +2244,10 @@ sg_err_category_sense(const uint8_t * sbp, int sb_len)
case SPC_SK_RECOVERED_ERROR:
return SG_LIB_CAT_RECOVERED;
case SPC_SK_NOT_READY:
+ if ((0x04 == ssh.asc) && (0x0b == ssh.ascq))
+ return SG_LIB_CAT_STANDBY;
+ if ((0x04 == ssh.asc) && (0x0c == ssh.ascq))
+ return SG_LIB_CAT_UNAVAILABLE;
return SG_LIB_CAT_NOT_READY;
case SPC_SK_MEDIUM_ERROR:
case SPC_SK_HARDWARE_ERROR:
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 944c86c3..f875fabc 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -19,7 +19,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "2.94 20221007";
+const char * sg_lib_version_str = "2.95 20221104";
/* spc6r06, sbc5r03, zbc2r13 */
@@ -1911,6 +1911,8 @@ struct sg_value_2names_t sg_exit_str_arr[] = {
{10, "Copy aborted", "type: sense key"},
{11, "Aborted command",
"type: sense key, other than protection related (asc=0x10)"},
+ {12, "Device not ready, standby", "type: sense key"},
+ {13, "Device not ready, unavailable", "type: sense key"},
{14, "Miscompare", "type: sense key"},
{15, "File error", NULL},
{17, "Illegal request with Info field", NULL},
diff --git a/src/sg_turs.c b/src/sg_turs.c
index 02612ed1..2d473c48 100644
--- a/src/sg_turs.c
+++ b/src/sg_turs.c
@@ -430,6 +430,20 @@ loop_turs(struct sg_pt_base * ptvp, struct loop_res_t * resp,
resp->reported = true;
}
break;
+ case SG_LIB_CAT_STANDBY:
+ ++resp->num_errs;
+ if (vb) {
+ pr2serr("Ignoring standby device (sense key)\n");
+ resp->reported = true;
+ }
+ break;
+ case SG_LIB_CAT_UNAVAILABLE:
+ ++resp->num_errs;
+ if (vb) {
+ pr2serr("Ignoring unavailable device (sense key)\n");
+ resp->reported = true;
+ }
+ break;
default:
++resp->num_errs;
if (1 == op->do_number) {