aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2011-10-28 20:00:18 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2011-10-28 20:00:18 +0000
commit98db1f0aadb3aef7e069f18e869a346e4188663a (patch)
treea8cec627849208197b73284f44cc7d347d8cffb8
parentbd319e2f17642153808171b9c8c8f70526bf9d86 (diff)
downloadsg3_utils-98db1f0aadb3aef7e069f18e869a346e4188663a.tar.gz
sg_ses: with get,set,clear work out which page acronym is in; some spc4r33 work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@422 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog2
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_ses.852
-rw-r--r--lib/sg_lib_data.c21
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_inq.c2
-rw-r--r--src/sg_inq_data.c6
-rw-r--r--src/sg_ses.c212
9 files changed, 210 insertions, 91 deletions
diff --git a/ChangeLog b/ChangeLog
index 7121de39..9fb12c30 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.33 [20111025] [svn: r421]
+Changelog for sg3_utils-1.33 [20111028] [svn: r422]
- win: change DataBufferOffset type per MSDN; caused
problem with 64 bit machines (buffered interface)
- sg_inq, sg_vpd: sync with spc4r32
diff --git a/README b/README
index 6458295e..fb4a8a78 100644
--- a/README
+++ b/README
@@ -354,4 +354,4 @@ See http://sg.danny.cz/sg/tools.html
Doug Gilbert
-12th October 2011
+28th October 2011
diff --git a/debian/changelog b/debian/changelog
index f8082a2a..a2fa6e26 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.33-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Wed, 12 Oct 2011 12:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Fri, 28 Oct 2011 10:00:00 -0400
sg3-utils (1.32-0.1) unstable; urgency=low
diff --git a/doc/sg_ses.8 b/doc/sg_ses.8
index 26e908d2..53aa235c 100644
--- a/doc/sg_ses.8
+++ b/doc/sg_ses.8
@@ -4,8 +4,8 @@ sg_ses \- fetch status from a SCSI Enclosure Services (SES) device
.SH SYNOPSIS
.B sg_ses
[\fI\-\-byte1=B1\fR] [\fI\-\-clear=STR\fR] [\fI\-\-control\fR]
-[\fI\-\-data=H,H...\fR] [\fI\-\-descriptor=DN\fR] [\fI\-\-filter\fR]
-[\fI\-\-get=STR\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
+[\fI\-\-data=H,H...\fR] [\fI\-\-descriptor=DN\fR] [\fI\-\-enumerate\fR]
+[\fI\-\-filter\fR] [\fI\-\-get=STR\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
[\fI\-\-index=IIE\fR | \fI\-\-index=OIE,II\fR] [\fI\-\-inner\-hex\fR]
[\fI\-\-join\fR] [\fI\-\-list\fR] [\fI\-\-page=PG\fR] [\fI\-\-raw\fR]
[\fI\-\-set=STR\fR] [\fI\-\-status\fR] [\fI\-\-verbose\fR]
@@ -85,6 +85,13 @@ by a backslash). Some elements (e.g. overall elements) may not have
descriptor names. Useful with the \fI\-\-join\fR option as well as the
\fI\-\-clear=STR\fR, \fI\-\-get=STR\fR and \fI\-\-set=STR\fR options.
.TP
+\fB\-e\fR, \fB\-\-enumerate\fR
+enumerate all known diagnostic page names and SES elements when this option
+is given once. If \fI\-\-enumerate\fR is given twice, then the recognized
+acronyms for the \fI\-\-clear=STR\fR, \fI\-\-get=STR\fR and \fI\-\-set=STR\fR
+options are listed. The utility exits after listing this information (so most
+other options and \fIDEVICE\fR are ignored).
+.TP
\fB\-f\fR, \fB\-\-filter\fR
cuts down on the amount of output from the enclosure status diagnostic
page and the additional element status page. When this option is given, any
@@ -112,32 +119,31 @@ in hexadecimal. Ignored with some options (e.g. \fI\-\-join\fR).
\fB\-i\fR, \fB\-\-inner\-hex\fR
the outer levels of a status diagnostic page are decoded and printed out
but the innermost level (e.g. the element status descriptor) is output in
-hex. Implemented for the more complex diagnostic pages.
+hex. Also active with the additional element descriptor and threshold in
+pages. Can be used with \fI\-\-index=...\fR and/or \fI\-\-join\fR options.
.TP
\fB\-I\fR, \fB\-\-index\fR=\fIIIE\fR
where \fIIIE\fR is either an individual index or an element type abbreviation.
-See the INDEXES section below. To list the available element type
-abbreviations use the \fI\-\-list\fR option.
+See the INDEXES section below. Useful with the \fI\-\-join\fR or
+\fI\-\-page=PG\fR option. To enumerate the available element type
+abbreviations use the \fI\-\-enumerate\fR option.
.TP
\fB\-I\fR, \fB\-\-index\fR=\fIOIE,II\fR
where \fIOIE,II\fR is an overall index (or element type abbreviation)
-followed by an individual index. See the INDEXES section below. To list the
-available element type abbreviations use the \fI\-\-list\fR option.
+followed by an individual index. See the INDEXES section below. Useful with
+the \fI\-\-join\fR or \fI\-\-page=PG\fR option. To enumerate the available
+element type abbreviations use the \fI\-\-enumerate\fR option.
.TP
\fB\-j\fR, \fB\-\-join\fR
group elements from the element descriptor, enclosure status and additional
element status pages. If this option is given twice then elements from
the threshold in page are also grouped. The order is dictated by the
-configuration page. All elements are output unless the \fI\-\-index=IND\fR
+configuration page. All elements are output unless the \fI\-\-index=\fR
option is given, in which case only the matching element is output, or
no element is output if there is no match. See the INDEXES section below.
.TP
\fB\-l\fR, \fB\-\-list\fR
-list all known diagnostic page names and SES elements when \fI\-\-list\fR
-is given once. If \fI\-\-list\fR is given twice, then the recognized acronyms
-for the \fI\-\-clear=STR\fR, \fI\-\-get=STR\fR and \fI\-\-set=STR\fR options
-are listed. The utility exits after listing this information (so most
-other options and \fIDEVICE\fR are ignored).
+This option is equivalent to \fI\-\-enumerate\fR. See that option.
.TP
\fB\-p\fR, \fB\-\-page\fR=\fIPG\fR
where \fIPG\fR is a page code. Assumed to be in decimal unless prefixed by
@@ -206,17 +212,19 @@ can be given.
.PP
One of two command lines variants can be used to specify indexes:
\fI\-\-index=OIE,II\fR where \fIOIE\fR is either an overall index (OI) or
-an element type abbreviation (e.g. "ps" or "ps1"). \fIII\fR is the sub\-index
-and is either an individual index or "-1" to specify the overall element.
-The second variant is \fI\-\-index=IIE\fR where \fIIIE\fR is either an
-individual index (II) that is equivalent to \fI\-\-index=0,II\fR or an
-element type abbreviation that is equivalent to \fI\-\-index=E,-1\fR.
+an element type abbreviation (E) (e.g. "ps" or "ps1"). \fIII\fR is the
+sub\-index and is either an individual index or "-1" to specify the overall
+element. The second variant is \fI\-\-index=IIE\fR where \fIIIE\fR is
+either an individual index (II) or an element type abbreviation (E). When
+\fIIIE\fR is an individual index then the option is equivalent to
+\fI\-\-index=0,II\fR. When \fIIIE\fR is an element type abbreviation then
+the option is equivalent to \fI\-\-index=E,-1\fR.
.PP
For example if the first type header in the Configuration page has array
device slot element type then \fI\-\-index=0,-1\fR is equivalent to
\fI\-\-index=arr\fR. Also \fI\-\-index=arr,3\fR is equivalent to
-\fI\-\-index=3\fR. In the latter case if the "number of possible elements"
-is less than 4 then nothing is addressed.
+\fI\-\-index=3\fR. In the latter case, if the "number of possible elements"
+is less than 4 then nothing is addressed (since 3 would be out of bounds).
.PP
Note that if the element descriptor page is available then the
\fI\-\-descriptor=DN\fR option may be an alternative to the
@@ -242,8 +250,8 @@ The <value> is optional but is ignored if provided to \fI\-\-get=STR\fR.
For \fI\-\-set=STR\fR the default <value> is 1 while for \fI\-\-clear=STR\fR
the default value is 0 .
.PP
-The supported list of <acronym>s can be viewed by using the \fI\-\-list\fR
-option twice (or "\-ll").
+The supported list of <acronym>s can be viewed by using the
+\fI\-\-enumerate\fR option twice (or "\-ee").
.SH CHANGING STATE
This utility has various techniques for changing the state of a SES device.
As noted above this is typically a read\-modify\-write type operation.
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 1572e694..49c17314 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -15,7 +15,7 @@
#endif
-const char * sg_lib_version_str = "1.70 20111075"; /* spc4r32, sbc3r29 */
+const char * sg_lib_version_str = "1.71 20111025"; /* spc4r33, sbc3r29 */
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0, 0, "Test Unit Ready"},
@@ -1091,15 +1091,16 @@ const char * sg_lib_pdt_strs[] = {
const char * sg_lib_transport_proto_strs[] =
{
- "Fibre Channel (FCP-2)",
- "Parallel SCSI (SPI-5)",
- "SSA (SSA-S3P)",
- "IEEE 1394 (SBP-3)",
- "Remote Direct Memory Access (RDMA)",
+ "Fibre Channel Protocol for SCSI (FCP-2)",
+ "SCSI Parallel Interface (SPI-5)",
+ "Serial Storage Architecture SCSI-3 Protocol (SSA-S3P)",
+ "Serial Bus Protocol for IEEE 1394 (SBP-3)",
+ "SCSI RDMA Protocol (SRP)",
"Internet SCSI (iSCSI)",
- "Serial Attached SCSI (SPL)",
- "Automation/Drive Interface (ADT-2)",
- "ATA Packet Interface (ACS-2)",
- "Ox9", "Oxa", "Oxb", "Oxc", "Oxd", "Oxe",
+ "Serial Attached SCSI Protocol (SPL-2)",
+ "Automation/Drive Interface Transport (ADT-2)",
+ "AT Attachment Interface (ACS-2)",
+ "USB Attached SCSI (UAS-2)",
+ "Oxa", "Oxb", "Oxc", "Oxd", "Oxe",
"No specific protocol"
};
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 7df8b5e0..1c4210a5 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Wed Oct 12 2011 - dgilbert at interlog dot com
+* Fri Oct 28 2011 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.33
diff --git a/src/sg_inq.c b/src/sg_inq.c
index d6fe1a29..f7781fc6 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -66,7 +66,7 @@
* information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes.
*/
-static char * version_str = "1.02 20111025"; /* SPC-4 rev 32 */
+static char * version_str = "1.02 20111025"; /* SPC-4 rev 33 */
#define VPD_SUPPORTED_VPDS 0x0
diff --git a/src/sg_inq_data.c b/src/sg_inq_data.c
index 3afe47be..83a77768 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 32 [sorted numerically (from Annex D.8)] */
+/* table from SPC-4 revision 33 [sorted numerically (from Annex D.8)] */
/* Can also be obtained from : http://www.t10.org/lists/stds.txt */
struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0x0, "Version Descriptor not supported or No standard identified"},
@@ -198,6 +198,7 @@ struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0x500, "ADC-3 (no version claimed)"},
{0x502, "ADC-3 T10/1895-D revision 04"},
{0x520, "SSC-4 (no version claimed)"},
+ {0x523, "SSC-4 T10/2123-D revision 2"},
{0x560, "OSD-3 (no version claimed)"},
{0x580, "SES-3 (no version claimed)"},
{0x820, "SSA-TL2 (no version claimed)"},
@@ -365,6 +366,7 @@ struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0xf00, "FC-LS-2 (no version claimed)"},
{0xf03, "FC-LS-2 T11/2103-D revision 2.11"},
{0xf05, "FC-LS-2 T11/2103-D revision 2.21"},
+ {0xf07, "FC-LS-2 ANSI INCITS 477-2011"},
{0xf20, "FC-PI-5 (no version claimed)"},
{0xf27, "FC-PI-5 T11/2118-D revision 2.00"},
{0xf28, "FC-PI-5 T11/2118-D revision 3.00"},
@@ -433,11 +435,13 @@ 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)"},
+ {0x1f00, "SAT-4 (no version claimed)"},
{0x20a0, "SPL (no version claimed)"},
{0x20a3, "SPL T10/2124-D revision 6a"},
{0x20a5, "SPL T10/2124-D revision 7"},
{0x20a7, "SPL SPL ANSI INCITS 476-2011"},
{0x20c0, "SPL-2 (no version claimed)"},
+ {0x20e0, "SPL-3 (no version claimed)"},
{0x21e0, "SOP (no version claimed)"},
{0x2200, "PQI (no version claimed)"},
{0xffc0, "IEEE 1667 (no version claimed)"},
diff --git a/src/sg_ses.c b/src/sg_ses.c
index ad53d2fc..7302b1d5 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -27,7 +27,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static char * version_str = "1.60 20111016"; /* ses3r03 */
+static char * version_str = "1.61 20111028"; /* ses3r03 */
#define MX_ALLOC_LEN 4096
#define MX_ELEM_HDR 1024
@@ -96,6 +96,7 @@ struct opts_t {
int byte1_given;
int do_control;
int do_data;
+ int do_enumerate;
int do_filter;
int do_help;
int do_hex;
@@ -245,6 +246,30 @@ static struct diag_page_code in_dpc_arr[] = {
{-1, NULL},
};
+/* Diagnostic page names, for control (or out) pages */
+static struct diag_page_code out_dpc_arr[] = {
+ {DPC_SUPPORTED, "?? [Supported diagnostic pages]"}, /* 0 */
+ {DPC_CONFIGURATION, "?? [Configuration (SES)]"},
+ {DPC_ENC_CONTROL, "Enclosure control (SES)"},
+ {DPC_HELP_TEXT, "Help text (SES)"},
+ {DPC_STRING, "String Out (SES)"},
+ {DPC_THRESHOLD, "Threshold Out (SES)"},
+ {0x6, "Array Control (SES, obsolete)"},
+ {DPC_ELEM_DESC, "?? [Element descriptor (SES)]"},
+ {DPC_SHORT_ENC_STATUS, "?? [Short enclosure status (SES)]"}, /* 8 */
+ {DPC_ENC_BUSY, "?? [Enclosure busy (SES-2)]"},
+ {DPC_ADD_ELEM_STATUS, "?? [Additional element status (SES-2)]"},
+ {DPC_SUBENC_HELP_TEXT, "?? [Subenclosure help text (SES-2)]"},
+ {DPC_SUBENC_STRING, "Subenclosure string Out (SES-2)"},
+ {DPC_SUPPORTED_SES, "?? [Supported SES diagnostic pages (SES-2)]"},
+ {DPC_DOWNLOAD_MICROCODE, "Download microcode (SES-2)"},
+ {DPC_SUBENC_NICKNAME, "Subenclosure nickname (SES-2)"},
+ {0x3f, "Protocol specific (SAS transport)"},
+ {0x40, "Translate address (SBC)"},
+ {0x41, "Device status (SBC)"},
+ {-1, NULL},
+};
+
/* Names of element types used by the Enclosure Control/Status diagnostic
* page. */
static struct element_type_t element_type_arr[] = {
@@ -353,6 +378,7 @@ static struct option long_options[] = {
{"clear", 1, 0, 'C'},
{"data", 1, 0, 'd'},
{"descriptor", 1, 0, 'D'},
+ {"enumerate", 0, 0, 'e'},
{"filter", 0, 0, 'f'},
{"get", 1, 0, 'G'},
{"help", 0, 0, 'h'},
@@ -379,13 +405,13 @@ usage()
{
fprintf(stderr, "Usage: "
"sg_ses [--byte1=B1] [--clear=STR] [--control] [--data=H,H...]\n"
- " [--descriptor=DN] [--filter] [--get=STR] [--help] "
- "[--hex]\n"
- " [--index=IIE | --index=OIE,II] [--inner-hex] "
- "[--join]\n"
- " [--list] [--page=PG] [--raw] [--set=STR] "
- "[--status]\n"
- " [--verbose] [--version] DEVICE\n"
+ " [--descriptor=DN] [--enumerate] [--filter] "
+ "[--get=STR]\n"
+ " [--help] [--hex] [--index=IIE | --index=OIE,II]\n"
+ " [--inner-hex] [--join] [--list] [--page=PG] "
+ "[--raw]\n"
+ " [--set=STR] [--status] [--verbose] [--version]\n"
+ " DEVICE\n"
" where:\n"
" --byte1=B1|-b B1 byte 1 (2nd byte) of control page set "
"to B1\n"
@@ -398,12 +424,16 @@ usage()
"stdin\n"
" --descriptor=DN|-D DN descriptor name, alternative to "
"--index=IND\n"
+ " --enumerate|-e enumerate page names + element types "
+ "(ignore\n"
+ " DEVICE), use twice for clear,get,set "
+ "acronyms\n"
" --filter|-f filter out enclosure status clear "
"flags\n"
" --get=STR|-G STR get value of field by acronym or "
"position\n"
" --help|-h print out usage message\n"
- " --hex|-H print status response in hex\n"
+ " --hex|-H print page response in hex\n"
" --index=IIE|-I IIE individual index ('-1' for overall) "
"or element\n"
" type abbreviation (e.g. 'arr')\n"
@@ -422,12 +452,10 @@ usage()
" and additional element status pages. "
"Use twice\n"
" to add threshold in page\n"
- " --list|-l list page names + element types (ignore"
- " DEVICE)\n"
- " use twice to list clear,get,set "
- "acronyms\n"
+ " --list|-l same as '--enumerate' option\n"
" --page=PG|-p PG SES page code PG (prefix with '0x' "
- "for hex; def: 0)\n"
+ "for hex)\n"
+ " (def: 0 (supported diagnostic pages))\n"
" --raw|-r print status page in ASCII hex suitable "
"for '-d';\n"
" when used twice outputs page in binary "
@@ -438,8 +466,9 @@ usage()
"action)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
- "Fetches status or sends control data to a SCSI enclosure. STR "
- "can be\n'<acronym>[=val]' or '<start_byte>:<start_bit>"
+ "Fetches status or sends control data to a SCSI enclosure. If "
+ "no options\ngiven outputs DEVICE's supported diagnostic pages. "
+ "STR can be\n'<acronym>[=val]' or '<start_byte>:<start_bit>"
"[:<num_bits>][=<val>]'.\nElement type abbreviations may be "
"followed by a number (e.g. 'ps1' is the\nsecond power supply "
"element type).\n"
@@ -458,7 +487,7 @@ process_cl(struct opts_t *op, int argc, char *argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "b:cC:d:D:fG:hHiI:jlp:rsS:vV",
+ c = getopt_long(argc, argv, "b:cC:d:D:efG:hHiI:jlp:rsS:vV",
long_options, &option_index);
if (c == -1)
break;
@@ -490,6 +519,9 @@ process_cl(struct opts_t *op, int argc, char *argv[])
case 'D':
op->desc_name = optarg;
break;
+ case 'e':
+ ++op->do_enumerate;
+ break;
case 'f':
op->do_filter = 1;
break;
@@ -568,7 +600,7 @@ process_cl(struct opts_t *op, int argc, char *argv[])
}
if (NULL == etp->desc) {
fprintf(stderr, "bad element type abbreviation [%s] for "
- "'--index'\nuse '--list' to see possibles\n", b);
+ "'--index'\nuse '--enumerate' to see possibles\n", b);
return SG_LIB_SYNTAX_ERROR;
}
if ((int)strlen(b) > n) {
@@ -649,7 +681,7 @@ process_cl(struct opts_t *op, int argc, char *argv[])
"not both\n");
return SG_LIB_SYNTAX_ERROR;
}
- if (op->do_list)
+ if (op->do_list || op->do_enumerate)
return 0;
if (op->do_control && op->do_status) {
fprintf(stderr, "cannot have both '--control' and '--status'\n");
@@ -770,6 +802,21 @@ parse_cgs_str(char * buff, struct tuple_acronym_val * tavp)
}
return 0;
}
+
+/* Fetch diagnostic page name (control or out). Returns NULL if not found. */
+static const char *
+find_out_diag_page_desc(int page_num)
+{
+ const struct diag_page_code * pcdp;
+
+ for (pcdp = out_dpc_arr; pcdp->desc; ++pcdp) {
+ if (page_num == pcdp->page_code)
+ return pcdp->desc;
+ else if (page_num < pcdp->page_code)
+ return NULL;
+ }
+ return NULL;
+}
/* Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> Send diagnostic not
* supported, SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
@@ -779,6 +826,18 @@ static int
do_senddiag(int sg_fd, int pf_bit, void * outgoing_pg, int outgoing_len,
int noisy, int verbose)
{
+ const char * cp;
+ int page_num;
+
+ if (outgoing_pg && (verbose > 2)) {
+ page_num = ((const char *)outgoing_pg)[0];
+ cp = find_out_diag_page_desc(page_num);
+ if (cp)
+ fprintf(stderr, " Send diagnostic cmd name: %s\n", cp);
+ else
+ fprintf(stderr, " Send diagnostic cmd number: 0x%x\n",
+ page_num);
+ }
return sg_ll_send_diag(sg_fd, 0 /* sf_code */, pf_bit, 0 /* sf_bit */,
0 /* devofl_bit */, 0 /* unitofl_bit */,
0 /* long_duration */, outgoing_pg, outgoing_len,
@@ -2806,8 +2865,44 @@ strcase_eq(const char * s1p, const char * s2p)
return 1;
}
+static int
+is_acronym_in_status_ctl(const struct tuple_acronym_val * tavp)
+{
+ const struct acronym2tuple * a2tp;
+
+ for (a2tp = ecs_a2t_arr; a2tp->acron; ++ a2tp) {
+ if (strcase_eq(tavp->acron, a2tp->acron))
+ break;
+ }
+ return (a2tp->acron ? 1 : 0);
+}
+
+static int
+is_acronym_in_threshold(const struct tuple_acronym_val * tavp)
+{
+ const struct acronym2tuple * a2tp;
+
+ for (a2tp = th_a2t_arr; a2tp->acron; ++ a2tp) {
+ if (strcase_eq(tavp->acron, a2tp->acron))
+ break;
+ }
+ return (a2tp->acron ? 1 : 0);
+}
+
+static int
+is_acronym_in_additional(const struct tuple_acronym_val * tavp)
+{
+ const struct acronym2tuple * a2tp;
+
+ for (a2tp = ae_sas_a2t_arr; a2tp->acron; ++ a2tp) {
+ if (strcase_eq(tavp->acron, a2tp->acron))
+ break;
+ }
+ return (a2tp->acron ? 1 : 0);
+}
+
/* Do clear/get/set (cgs) on Enclosure Control/Status page. Return 0 for ok
- * else -1 . */
+ * -2 for acronym not found, else -1 . */
static int
cgs_enc_ctl_stat(int sg_fd, const struct join_row_t * jrp,
const struct tuple_acronym_val * tavp,
@@ -2832,11 +2927,8 @@ cgs_enc_ctl_stat(int sg_fd, const struct join_row_t * jrp,
s_byte = a2tp->start_byte;
s_bit = a2tp->start_bit;
n_bits = a2tp->num_bits;
- } else {
- fprintf(stderr, "acroynm %s not found for Enclosure "
- "Control/Status page (try '-ll' option)\n", tavp->acron);
- return -1;
- }
+ } else
+ return -2;
}
if (op->get_str) {
ui = get_big_endian(jrp->enc_statp + s_byte, s_bit, n_bits);
@@ -2861,8 +2953,8 @@ cgs_enc_ctl_stat(int sg_fd, const struct join_row_t * jrp,
return 0;
}
-/* Do clear/get/set (cgs) on Threshold In/Out page. Return 0 for ok else
- * -1 . */
+/* Do clear/get/set (cgs) on Threshold In/Out page. Return 0 for ok,
+ * -2 for acronym not found, else -1 . */
static int
cgs_threshold(int sg_fd, const struct join_row_t * jrp,
const struct tuple_acronym_val * tavp,
@@ -2891,11 +2983,8 @@ cgs_threshold(int sg_fd, const struct join_row_t * jrp,
s_byte = a2tp->start_byte;
s_bit = a2tp->start_bit;
n_bits = a2tp->num_bits;
- } else {
- fprintf(stderr, "acroynm %s not found for Threshold In/Out "
- "page (try '-ll' option)\n", tavp->acron);
- return -1;
- }
+ } else
+ return -2;
}
if (op->get_str) {
ui = get_big_endian(jrp->thresh_inp + s_byte, s_bit, n_bits);
@@ -2918,8 +3007,8 @@ cgs_threshold(int sg_fd, const struct join_row_t * jrp,
return 0;
}
-/* Do clear/get/set (cgs) on Additional element status page. Return 0 for
- * ok else -1 . */
+/* Do get (cgs) on Additional element status page. Return 0 for ok,
+ * -2 for acronym not found, else -1 . */
static int
cgs_additional_el(const struct join_row_t * jrp,
const struct tuple_acronym_val * tavp,
@@ -2948,11 +3037,8 @@ cgs_additional_el(const struct join_row_t * jrp,
s_byte = a2tp->start_byte;
s_bit = a2tp->start_bit;
n_bits = a2tp->num_bits;
- } else {
- fprintf(stderr, "acroynm %s not found for Additional element "
- "status page (try '-ll' option)\n", tavp->acron);
- return -1;
- }
+ } else
+ return -2;
}
if (op->get_str) {
ui = get_big_endian(jrp->add_elem_statp + s_byte, s_bit, n_bits);
@@ -2974,10 +3060,26 @@ static int
ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
struct opts_t * op)
{
- int ret, k, desc_len, dn_len;
+ int ret, k, desc_len, dn_len, in_page;
const struct join_row_t * jrp;
const unsigned char * ed_ucp;
+ in_page = 0;
+ if (is_acronym_in_status_ctl(tavp)) {
+ in_page = DPC_ENC_STATUS;
+ op->page_code = DPC_ENC_CONTROL;
+ } else if (is_acronym_in_threshold(tavp)) {
+ in_page = DPC_THRESHOLD;
+ op->page_code = DPC_THRESHOLD;
+ } else if (is_acronym_in_additional(tavp)) {
+ in_page = DPC_ADD_ELEM_STATUS;
+ op->page_code = DPC_ADD_ELEM_STATUS;
+ }
+ if (0 == in_page) {
+ fprintf(stderr, "acroynm %s not found (try '-ee' option)\n",
+ tavp->acron);
+ return -1;
+ }
ret = process_join(sg_fd, op, 0);
if (ret)
return ret;
@@ -3000,7 +3102,7 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
desc_len))
continue;
}
- if ((0 == op->page_code_given) || (DPC_ENC_CONTROL == op->page_code))
+ if (DPC_ENC_CONTROL == op->page_code)
ret = cgs_enc_ctl_stat(sg_fd, jrp, tavp, op);
else if (DPC_THRESHOLD == op->page_code)
ret = cgs_threshold(sg_fd, jrp, tavp, op);
@@ -3027,19 +3129,22 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
return 0;
}
-/* Output from --list option. Note it is different when given twice. */
+/* Output from --enumerate or --list option. Note that the output is
+ * different when the option is given twice. */
static void
-process_do_list(const struct opts_t * op)
+process_do_enumerate(const struct opts_t * op)
{
+ int num;
const struct diag_page_code * pcdp;
const struct element_type_t * etp;
const struct acronym2tuple * a2tp;
const char * cp;
if (op->device_name)
- printf(">>> DEVICE %s ignored when --list option given.\n",
- op->device_name);
- if (op->do_list < 2) {
+ printf(">>> DEVICE %s ignored when --%s option given.\n",
+ op->device_name, (op->do_list ? "list" : "enumerate"));
+ num = op->do_enumerate + op->do_list;
+ if (num < 2) {
printf("Diagnostic pages (followed by page code):\n");
for (pcdp = dpc_arr; pcdp->desc; ++pcdp)
printf(" %s [0x%x]\n", pcdp->desc, pcdp->page_code);
@@ -3049,22 +3154,23 @@ process_do_list(const struct opts_t * op)
printf(" %s [%s] [0x%x]\n", etp->desc, etp->abbrev,
etp->elem_type_code);
} else {
+ /* command line has multiple --enumerate and/or --list options */
printf("--clear, --get, --set acronyms for enclosure status/control "
- "page:\n");
+ "[0x2] page:\n");
for (a2tp = ecs_a2t_arr; a2tp->acron; ++a2tp) {
cp = (a2tp->etype < 0) ? "*" : find_element_tname(a2tp->etype);
printf(" %s [%s] [%d:%d:%d]\n", a2tp->acron, (cp ? cp : "??"),
a2tp->start_byte, a2tp->start_bit, a2tp->num_bits);
}
printf("\n--clear, --get, --set acronyms for threshold in/out "
- "page:\n");
+ "[0x5] page:\n");
for (a2tp = th_a2t_arr; a2tp->acron; ++a2tp) {
cp = (a2tp->etype < 0) ? "*" : find_element_tname(a2tp->etype);
printf(" %s [%s] [%d:%d:%d]\n", a2tp->acron, (cp ? cp : "??"),
a2tp->start_byte, a2tp->start_bit, a2tp->num_bits);
}
- printf("\n--clear, --get, --set acronyms for additional element "
- "status page (SAS EIP=1):\n");
+ printf("\n--get acronyms for additional element status [0xa] page "
+ "(SAS EIP=1):\n");
for (a2tp = ae_sas_a2t_arr; a2tp->acron; ++a2tp) {
cp = (a2tp->etype < 0) ? "*" : find_element_tname(a2tp->etype);
printf(" %s [%s] [%d:%d:%d]\n", a2tp->acron, (cp ? cp : "??"),
@@ -3099,8 +3205,8 @@ main(int argc, char * argv[])
usage();
return 0;
}
- if (opts.do_list) {
- process_do_list(&opts);
+ if (opts.do_enumerate || opts.do_list) {
+ process_do_enumerate(&opts);
return 0;
}
if (opts.clear_str || opts.get_str || opts.set_str) {
@@ -3115,7 +3221,7 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (opts.get_str && tav.val_str)
- fprintf(stderr, "eith --get option ignoring =<val> at the end "
+ fprintf(stderr, "--get option ignoring =<val> at the end "
"of STR argument\n");
if ((0 == opts.ind_given) && (! opts.desc_name)) {
fprintf(stderr, "with --clear, --get or --set option need "