Skip to content

Commit cc7dc18

Browse files
committed
sg_logs: add --vendor=VP; sg_vpd: improve handling of unknown pages; other fixes
git-svn-id: svn://localhost/trunk@710 6180dd3e-e324-4e3e-922d-17de1ae2f315
1 parent 3b459d8 commit cc7dc18

13 files changed

+544
-258
lines changed

ChangeLog

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
22
some description at the top of its ".c" file. All utilities in the main
33
directory have their own "man" pages. There is also a sg3_utils man page.
44

5-
Changelog for sg3_utils-1.43 [20160528] [svn: r708]
5+
Changelog for sg3_utils-1.43 [20160531] [svn: r710]
66
- sg_bg_ctl: new Background control command (spc4r08)
77
- sg_senddiag: add --timeout=SEC option
88
- sg_sanitize: add --timeout=SEC option
@@ -16,9 +16,9 @@ Changelog for sg3_utils-1.43 [20160528] [svn: r708]
1616
- accept and output on request "quad dashed" format
1717
- sg_logs: fix volume statistics lpage when subpage
1818
is zero (ssc5r02a); decode mount history log parameter
19+
- add --vendor=VP and '--pdt=DT' options
1920
- decode Requested recovery, TapeAlert response, and
2021
Service buffer information lpages for tape
21-
- add '--pdt=DT' option
2222
- add min+max 'mounted' temperature and rel. humidity
2323
fields to Environmental reporting lpage (spc5r10)
2424
- sg_inq: fix potential unbounded loop in --export
@@ -28,6 +28,7 @@ Changelog for sg3_utils-1.43 [20160528] [svn: r708]
2828
- add --force option to bypass checking supported
2929
vpd pages page and fetch requested page directly
3030
- sg_vpd: 3 party copy VPD page improvements
31+
- improve handling of unknown pages
3132
- sg_reassign+sg_write_same: fix ULONG_MAX problem
3233
- sg_rdac: add sanity checks for -f=lun value
3334
- sg_turs+sg_requests: make both accept '--num=NUM'

doc/sg_logs.8

+54-28
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
.TH SG_LOGS "8" "March 2016" "sg3_utils\-1.43" SG3_UTILS
1+
.TH SG_LOGS "8" "May 2016" "sg3_utils\-1.43" SG3_UTILS
22
.SH NAME
33
sg_logs \- access log pages with SCSI LOG SENSE command
44
.SH SYNOPSIS
55
.B sg_logs
6-
[\fI\-\-All\fR] [\fI\-\-all\fR] [\fI\-\-brief\fR] [\fI\-\-control=PC\fR]
7-
[\fI\-\-enumerate\fR] [\fI\-\-enum_vendor\fR] [\fI\-\-filter=FL\fR]
8-
[\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-in=FN\fR] [\fI\-\-list\fR]
9-
[\fI\-\-maxlen=LEN\fR] [\fI\-\-name\fR] [\fI\-\-no_inq\fR] [\fI\-\-page=PG\fR]
10-
[\fI\-\-paramp=PP\fR] [\fI\-\-pcb\fR] [\fI\-\-ppc\fR] [\fI\-\-pdt=DT\fR]
11-
[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-reset\fR] [\fI\-\-select\fR]
6+
[\fI\-\-All\fR] [\fI\-\-all\fR] [\fI\-\-brief\fR] [\fI\-\-filter=FL\fR]
7+
[\fI\-\-hex\fR] [\fI\-\-list\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-name\fR]
8+
[\fI\-\-no_inq\fR] [\fI\-\-page=PG\fR] [\fI\-\-paramp=PP\fR] [\fI\-\-pcb\fR]
9+
[\fI\-\-ppc\fR] [\fI\-\-pdt=DT\fR] [\fI\-\-raw\fR] [\fI\-\-readonly\fR]
1210
[\fI\-\-sp\fR] [\fI\-\-temperature\fR] [\fI\-\-transport\fR]
13-
[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
11+
[\fI\-\-vendor=VP\fR] [\fI\-\-verbose\fR] \fIDEVICE\fR
12+
.PP
13+
.B sg_logs
14+
[\fI\-\-brief\fR] [\fI\-\-filter=FL\fR] [\fI\-\-hex\fR] \fI\-\-in=FN\fR
15+
[\fI\-\-name\fR] [\fI\-\-pdt=DT\fR] [\fI\-\-raw\fR] [\fI\-\-vendor=VP\fR]
16+
.PP
17+
.B sg_logs
18+
[\fI\-\-control=PC\fR] [\fI\-\-in=FN\fR] [\fI\-\-page=PG\fR] [\fI\-\-raw\fR]
19+
[\fI\-\-reset\fR] \fI\-\-select\fR [\fI\-\-sp\fR] [\fI\-\-verbose\fR]
20+
\fIDEVICE\fR
21+
.PP
22+
.B sg_logs
23+
[\fI\-\-enumerate\fR] [\fI\-\-filter=FL\fR] [\fI\-\-help\fR]
24+
[\fI\-\-vendor=VP\fR] [\fI\-\-version\fR]
1425
.PP
1526
.B sg_logs
1627
[\fI\-a\fR] [\fI\-A\fR] [\fI\-b\fR] [\fI\-D=DT\fR] [\fI\-c=PC\fR] [\fI\-e\fR]
17-
[\fI\-E\fR] [\fI\-f=FL\fR] [\fI\-h\fR] [\fI\-H\fR] [\fI\-i=FN\fR] [\fI\-l\fR]
18-
[\fI\-L\fR] [\fI\-m=LEN\fR] [\fI\-n\fR] [\fI\-p=PG\fR] [\fI\-paramp=PP\fR]
28+
[\fI\-f=FL\fR] [\fI\-h\fR] [\fI\-H\fR] [\fI\-i=FN\fR] [\fI\-l\fR] [\fI\-L\fR]
29+
[\fI\-m=LEN\fR] [\fI\-M=VP\fR] [\fI\-n\fR] [\fI\-p=PG\fR] [\fI\-paramp=PP\fR]
1930
[\fI\-pcb\fR] [\fI\-ppc\fR] [\fI\-r\fR] [\fI\-R\fR] [\fI\-select\fR]
2031
[\fI\-sp\fR] [\fI\-t\fR] [\fI\-T\fR] [\fI\-v\fR] [\fI\-V\fR] [\fI\-?\fR]
2132
[\fI\-x\fR] \fIDEVICE\fR
@@ -24,17 +35,22 @@ sg_logs \- access log pages with SCSI LOG SENSE command
2435
.PP
2536
This utility sends a SCSI LOG SENSE command to the \fIDEVICE\fR and then
2637
outputs the response. The LOG SENSE command is used to fetch log pages. Known
27-
log pages can be decoded. When the \fI\-\-reset\fR and/or \fI\-\-select\fR
28-
option is given then a SCSI LOG SELECT command is issued.
38+
log pages can be decoded. Alternatively when the \fI\-\-reset\fR and/or
39+
\fI\-\-select\fR option is given then a SCSI LOG SELECT command is issued.
2940
.PP
3041
In SPC\-4 revision 5 a subpage code was introduced to both the LOG SENSE and
3142
LOG SELECT command. At the same time a page code field was introduced to the
3243
to the LOG SELECT command. The log subpage code can range from 0 to 255 (0xff)
3344
inclusive. The subpage code value 255 can be thought of as a wildcard.
3445
.PP
35-
This utility supports two command line syntaxes, the preferred one is shown
36-
first in the synopsis and explained in this section. A later section on the
37-
old command line syntax outlines the second group of options.
46+
The SYNOPSIS section above is divided into five forms. The first form
47+
shows the options that can be used to send a LOG SENSE command to the
48+
\fIDEVICE\fR and decode its response. The second form fetches data from a
49+
file (named \fIFN\fR) and decodes it as if it were a response from a LOG
50+
SENSE command. The third form shows the options that can be used to send a
51+
LOG SELECT command. The fourth form groups various management options.
52+
The last form shows the older, deprecated command line interface which is
53+
maintaimed for backward compatibility.
3854
.SH OPTIONS
3955
Arguments to long options are mandatory for short options as well.
4056
.TP
@@ -83,20 +99,16 @@ the numeric order.
8399
The \fI\-\-filter=FL\fR and \fI\-\-verbose\fR options modify the output
84100
of the enumeration.
85101
.TP
86-
\fB\-E\fR, \fB\-\-enum_vendor\fR
87-
this option is used to output information held in internal tables about
88-
known vendor specific log pages including their names and acronyms.
89-
.TP
90102
\fB\-f\fR, \fB\-\-filter\fR=\fIFL\fR
91103
\fIFL\fR is either a parameter code when \fIDEVICE\fR is given, or a
92104
peripheral device type (pdt) (or other) if \fI\-\-enumerate\fR is given.
93105
.br
94106
In the parameter code case \fIFL\fR is a value between 0 and 65535 (0xffff)
95-
and only the parameter section matching that code is output.
96-
The \fB\-\-hex\fR option outputs log parameter in hexadecimal rather than
97-
decoding it. If the \fB\-\-hex\fR option is used twice then the leading
98-
address on each line of hex is removed. If the \fB\-\-raw\fR option is
99-
given then the log parameter is output in binary.
107+
and only the parameter section matching that code is output. If the
108+
\fB\-\-hex\fR option is given the log parameter is output in hexadecimal
109+
rather than decoding it. If the \fB\-\-hex\fR option is used twice then the
110+
leading address on each line of hex is removed. If the \fB\-\-raw\fR option
111+
is given then the log parameter is output in binary.
100112
Most log pages contain one or more log parameters. Examples of those that
101113
don't are those pages that list supported log pages.
102114
.br
@@ -259,6 +271,21 @@ may also have the current temperature (especially on older disks).
259271
outputs the transport ('Protocol specific port') log page. Equivalent to
260272
setting '\-\-page=18h'.
261273
.TP
274+
\fB\-M\fR, \fB\-\-vendor\fR=\fIVP\fR
275+
where \fIVP\fR is a vendor (e.g. "sea" for Seagate) or product (group)
276+
acronym (e.g. "lto5" for the 5th generation LTO (tape) consortium). Either
277+
the whole log page is vendor specific (e.g. page numbers 0x30 to 0x3f) or
278+
part of a T10 defined log page is vendor specific. For example SPC\-5
279+
defines parameter code 0x0 of page 0x2f (the Informational Exceptions log
280+
page) and states that the remaining parameter codes (i.e. 0x1 to 0xffff)
281+
are vendor specific. Using a \fIVP\fR of "xxx" will list the available
282+
acronyms.
283+
.br
284+
If this option is used with \fI\-\-page=PG\fR and \fIPG\fR is an acronym
285+
then this option is ignored. If \fIPG\fR is a number (e.g. 0xc0) then
286+
\fIVP\fR is used to choose the which vendor specific page (e.g. sharing
287+
page number 0xc0) to decode.
288+
.TP
262289
\fB\-v\fR, \fB\-\-verbose\fR
263290
increase level of verbosity. When used with \fI\-\-enumerate\fR, in the
264291
list of known log page names, those that have no associated decode logic
@@ -344,10 +371,6 @@ Equivalent to \fI\-\-control=PC\fR in the main description.
344371
enumerate internal tables to show information about known log pages.
345372
Equivalent to \fI\-\-enumerate\fR in the main description.
346373
.TP
347-
\fB\-E\fR
348-
enumerate internal tables to show information about known vendor specific
349-
log pages. Equivalent to \fI\-\-enum_vendor\fR in the main description.
350-
.TP
351374
\fB\-h\fR
352375
suppresses decoding of known log sense pages and prints out the
353376
response in hex instead.
@@ -375,6 +398,9 @@ interpreted as all that is available. \fILEN\fR is decimal unless it has
375398
a leading '0x' or trailing 'h'. Equivalent to \fI\-\-maxlen=LEN\fR in
376399
the main description.
377400
.TP
401+
\fB\-M\fR=\fIVP\fR
402+
Equivalent to \fI\-\-vendor=VP\fR in the main description.
403+
.TP
378404
\fB\-n\fR
379405
Equivalent to \fI\-\-name\fR in the main description.
380406
.TP

doc/sg_vpd.8

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.TH SG_VPD "8" "April 2016" "sg3_utils\-1.43" SG3_UTILS
1+
.TH SG_VPD "8" "May 2016" "sg3_utils\-1.43" SG3_UTILS
22
.SH NAME
33
sg_vpd \- fetch SCSI VPD page and/or decode its response
44
.SH SYNOPSIS
55
.B sg_vpd
6-
[\fI\-\-all\fR] [\fI\-\-enumerate\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
7-
[\fI\-\-ident\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-long\fR] [\fI\-\-maxlen=LEN\fR]
8-
[\fI\-\-page=PG\fR] [\fI\-\-quiet\fR] [\fI\-\-raw\fR] [\fI\-\-vendor=VP\fR]
9-
[\fI\-\-force\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] [\fIDEVICE\fR]
6+
[\fI\-\-all\fR] [\fI\-\-enumerate\fR] [\fI\-\-force\fR] [\fI\-\-help\fR]
7+
[\fI\-\-hex\fR] [\fI\-\-ident\fR] [\fI\-\-inhex=FN\fR] [\fI\-\-long\fR]
8+
[\fI\-\-maxlen=LEN\fR] [\fI\-\-page=PG\fR] [\fI\-\-quiet\fR] [\fI\-\-raw\fR]
9+
[\fI\-\-vendor=VP\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] [\fIDEVICE\fR]
1010
.SH DESCRIPTION
1111
.\" Add any additional description here
1212
.PP

src/sg_inq.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "sg_unaligned.h"
4444
#include "sg_pr2serr.h"
4545

46-
static const char * version_str = "1.62 20160510"; /* SPC-5 rev 10 */
46+
static const char * version_str = "1.63 20160531"; /* SPC-5 rev 10 */
4747

4848
/* INQUIRY notes:
4949
* It is recommended that the initial allocation length given to a
@@ -3087,7 +3087,7 @@ vpd_fetch_page_from_dev(int sg_fd, unsigned char * rp, int page,
30873087
static int
30883088
fetch_unit_serial_num(int sg_fd, char * obuff, int obuff_len, int verbose)
30893089
{
3090-
int len, k, res;
3090+
int len, k, res, c;
30913091
unsigned char b[DEF_ALLOC_LEN];
30923092

30933093
memset(b, 0xff, 4); /* guard against empty response */
@@ -3097,10 +3097,15 @@ fetch_unit_serial_num(int sg_fd, char * obuff, int obuff_len, int verbose)
30973097
len -= 4;
30983098
len = (len < (obuff_len - 1)) ? len : (obuff_len - 1);
30993099
if (len > 0) {
3100-
/* replace non-printable ASCII characters with space */
3101-
for (k = 0; k < len; ++k)
3102-
obuff[k] = isprint(b[4 + k]) ? b[4 + k] : ' ';
3103-
obuff[len] = '\0';
3100+
/* replace non-printable characters (except NULL) with space */
3101+
for (k = 0; k < len; ++k) {
3102+
c = b[4 + k];
3103+
if (c)
3104+
obuff[k] = isprint(c) ? c : ' ';
3105+
else
3106+
break;
3107+
}
3108+
obuff[k] = '\0';
31043109
return 0;
31053110
} else {
31063111
if (verbose > 2)

0 commit comments

Comments
 (0)