aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2012-03-17 11:19:11 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2012-03-17 11:19:11 +0000
commitdf6eb4025bee46e2f5ec70561d58a2cb27d211a9 (patch)
tree22a2ff3246ad47369c97464e274ed8bff92da45d /src
parent60c487d370cfbfa7d91bc777eba4277c00536430 (diff)
downloadsg3_utils-df6eb4025bee46e2f5ec70561d58a2cb27d211a9.tar.gz
sync with spc4r35; start on sat fixed sense
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@445 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/sg_inq_data.c4
-rw-r--r--src/sg_luns.c36
-rw-r--r--src/sg_sat_identify.c40
3 files changed, 56 insertions, 24 deletions
diff --git a/src/sg_inq_data.c b/src/sg_inq_data.c
index fb4e875a..aa9e12d2 100644
--- a/src/sg_inq_data.c
+++ b/src/sg_inq_data.c
@@ -48,7 +48,7 @@ struct sg_version_descriptor {
const char * name;
};
-/* table from SPC-4 revision 34 [sorted numerically (from Annex E.9)] */
+/* table from SPC-4 revision 35 [sorted numerically (from Annex E.9)] */
/* Can also be obtained from : http://www.t10.org/lists/stds.txt */
#ifdef SG_SCSI_STRINGS
struct sg_version_descriptor sg_version_descriptor_arr[] = {
@@ -201,6 +201,7 @@ struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0x500, "ADC-3 (no version claimed)"},
{0x502, "ADC-3 T10/1895-D revision 04"},
{0x504, "ADC-3 T10/1895-D revision 05"},
+ {0x506, "ADC-3 T10/1895-D revision 05a"},
{0x520, "SSC-4 (no version claimed)"},
{0x523, "SSC-4 T10/2123-D revision 2"},
{0x560, "OSD-3 (no version claimed)"},
@@ -445,6 +446,7 @@ struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0x1ec8, "SAT-2 T10/1826-D revision 09"},
{0x1eca, "SAT-2 ANSI INCITS 465-2010"},
{0x1ee0, "SAT-3 (no version claimed)"},
+ {0x1ee2, "SAT-3 T10/2126-D revision 4"},
{0x1f00, "SAT-4 (no version claimed)"},
{0x20a0, "SPL (no version claimed)"},
{0x20a3, "SPL T10/2124-D revision 6a"},
diff --git a/src/sg_luns.c b/src/sg_luns.c
index bc330512..0870577f 100644
--- a/src/sg_luns.c
+++ b/src/sg_luns.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2011 Douglas Gilbert.
+ * Copyright (c) 2004-2012 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.
@@ -23,10 +23,11 @@
/* A utility program originally written for the Linux OS SCSI subsystem.
*
*
- * This program issues the SCSI REPORT LUNS command to the given SCSI device.
+ * This program issues the SCSI REPORT LUNS command to the given SCSI device
+ * and decodes the response.
*/
-static char * version_str = "1.16 20110825";
+static char * version_str = "1.17 20120314";
#define MAX_RLUNS_BUFF_LEN (1024 * 64)
#define DEF_RLUNS_BUFF_LEN (1024 * 8)
@@ -77,13 +78,15 @@ usage()
);
}
-/* Decoded according to SAM-4 rev 4. Note that one draft: BCC rev 0,
+/* Decoded according to SAM-5 rev 10. Note that one draft: BCC rev 0,
* defines its own "bridge addressing method" in place of the SAM-3
* "logical addressing method". */
static void
decode_lun(const char * leadin, unsigned char * lunp)
{
- int k, j, x, a_method, bus_id, target, lun, len, e_a_method, next_level;
+ int k, j, x, a_method, bus_id, target, lun, len_fld, e_a_method;
+ int next_level;
+ unsigned int u;
unsigned char not_spec[8] = {0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff};
char l_leadin[128];
@@ -127,10 +130,10 @@ decode_lun(const char * leadin, unsigned char * lunp)
"lun=%d\n", l_leadin, bus_id, target, lun);
break;
case 3: /* extended logical unit addressing method */
- len = (lunp[0] & 0x30) >> 4;
+ len_fld = (lunp[0] & 0x30) >> 4;
e_a_method = lunp[0] & 0xf;
x = lunp[1];
- if ((0 == len) && (1 == e_a_method)) {
+ if ((0 == len_fld) && (1 == e_a_method)) {
switch (x) {
case 1:
printf("%sREPORT LUNS well known logical unit\n",
@@ -152,23 +155,28 @@ decode_lun(const char * leadin, unsigned char * lunp)
printf("%swell known logical unit %d\n", l_leadin, x);
break;
}
- } else if ((1 == len) && (2 == e_a_method)) {
+ } else if ((1 == len_fld) && (2 == e_a_method)) {
x = (lunp[1] << 16) + (lunp[2] << 8) + lunp[3];
printf("%sExtended flat space logical unit addressing: "
"value=0x%x\n", l_leadin, x);
- } else if ((3 == len) && (0xf == e_a_method))
+ } else if ((2 == len_fld) && (2 == e_a_method)) {
+ u = (lunp[1] << 24) + (lunp[2] << 16) + (lunp[3] << 8) +
+ lunp[4];
+ printf("%sLong extended flat space logical unit addressing: "
+ "value=0x%x\n", l_leadin, u);
+ } else if ((3 == len_fld) && (0xf == e_a_method))
printf("%sLogical unit _not_ specified addressing\n",
l_leadin);
else {
- if (len < 2) {
- if (1 == len)
+ if (len_fld < 2) {
+ if (1 == len_fld)
x = (lunp[1] << 16) + (lunp[2] << 8) + lunp[3];
printf("%sExtended logical unit addressing: length=%d, "
- "e.a. method=%d, value=0x%x\n", l_leadin, len,
+ "e.a. method=%d, value=0x%x\n", l_leadin, len_fld,
e_a_method, x);
} else {
ull = 0;
- x = (2 == len) ? 5 : 7;
+ x = (2 == len_fld) ? 5 : 7;
for (j = 0; j < x; ++j) {
if (j > 0)
ull <<= 8;
@@ -176,7 +184,7 @@ decode_lun(const char * leadin, unsigned char * lunp)
}
printf("%sExtended logical unit addressing: length=%d, "
"e. a. method=%d, value=0x%" PRIx64 "\n",
- l_leadin, len, e_a_method, ull);
+ l_leadin, len_fld, e_a_method, ull);
}
}
break;
diff --git a/src/sg_sat_identify.c b/src/sg_sat_identify.c
index 31d6d9d0..c7c2ba16 100644
--- a/src/sg_sat_identify.c
+++ b/src/sg_sat_identify.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2011 Douglas Gilbert.
+ * Copyright (c) 2006-2012 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.
@@ -45,7 +45,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.08 20110513";
+static char * version_str = "1.09 20120314";
static struct option long_options[] = {
{"ck_cond", no_argument, 0, 'c'},
@@ -107,6 +107,7 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
int resid = 0;
int got_ard = 0; /* got ATA result descriptor */
+ int got_fixsense = 0; /* got ATA result in fixed format sense */
int sb_sz;
struct sg_scsi_sense_hdr ssh;
unsigned char inBuff[ID_RESPONSE_LEN];
@@ -177,14 +178,25 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
case SPC_SK_RECOVERED_ERROR:
if ((0x0 == ssh.asc) &&
(ASCQ_ATA_PT_INFO_AVAILABLE == ssh.ascq)) {
- if (SAT_ATA_RETURN_DESC != ata_return_desc[0]) {
- if (verbose)
- fprintf(stderr, "did not find ATA Return "
- "(sense) Descriptor\n");
- return SG_LIB_CAT_RECOVERED;
+ if (0x72 == ssh.response_code) {
+ if (SAT_ATA_RETURN_DESC != ata_return_desc[0]) {
+ if (verbose)
+ fprintf(stderr, "did not find ATA Return "
+ "(sense) Descriptor\n");
+ return SG_LIB_CAT_RECOVERED;
+ }
+ got_ard = 1;
+ break;
+ } else if (0x70 == ssh.response_code) {
+ got_fixsense = 1;
+ break;
+ } else {
+ if (verbose < 2)
+ fprintf(stderr, "ATA PASS-THROUGH (%d), "
+ "unexpected response_code=0x%x\n",
+ ssh.response_code, cdb_len);
+ return SG_LIB_CAT_RECOVERED;
}
- got_ard = 1;
- break;
} else if (SPC_SK_RECOVERED_ERROR == ssh.sense_key)
return SG_LIB_CAT_RECOVERED;
else {
@@ -250,6 +262,16 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
}
ok = 1;
}
+ if (got_fixsense) {
+ if (0x4 & sense_buffer[3]) { /* Error is MSB of Info field */
+ fprintf(stderr, "error indication in returned FIS: aborted "
+ "command\n");
+ fprintf(stderr, " try again with%s '-p' option\n",
+ (do_packet ? "out" : ""));
+ return SG_LIB_CAT_ABORTED_COMMAND;
+ }
+ ok = 1;
+ }
if (ok) { /* output result if it is available */
if (do_raw)