diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2017-10-03 08:03:27 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2017-10-03 08:03:27 +0000 |
commit | dc469cf010ce1c840d6a1790cc4179ea0f5912dd (patch) | |
tree | 8b8b31434fecc4226aa22ae28f1f717c89652b6e /src | |
parent | 35242f73d10cb0720c59eeb7343d437ff53fb29a (diff) | |
download | sg3_utils-dc469cf010ce1c840d6a1790cc4179ea0f5912dd.tar.gz |
add last n Inquiry/Mode_page data changed log pages; add rescan-scsi-bus.sh to install list in Makefile
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@718 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r-- | src/sg_inq.c | 6 | ||||
-rw-r--r-- | src/sg_logs.c | 163 | ||||
-rw-r--r-- | src/sg_read_attr.c | 7 | ||||
-rw-r--r-- | src/sg_vpd.c | 10 |
4 files changed, 164 insertions, 22 deletions
diff --git a/src/sg_inq.c b/src/sg_inq.c index 62b3c7df..f8d26684 100644 --- a/src/sg_inq.c +++ b/src/sg_inq.c @@ -43,7 +43,7 @@ #include "sg_unaligned.h" #include "sg_pr2serr.h" -static const char * version_str = "1.66 20170917"; /* SPC-5 rev 14 */ +static const char * version_str = "1.67 20170926"; /* SPC-5 rev 17 */ /* INQUIRY notes: * It is recommended that the initial allocation length given to a @@ -2181,6 +2181,10 @@ decode_x_inq_vpd(unsigned char * buff, int len, int do_hex) printf(" IBS=%d IAS=%d SAC=%d NRD1=%d NRD0=%d\n", !!(buff[14] & 0x80), !!(buff[14] & 0x40), !!(buff[14] & 0x4), !!(buff[14] & 0x2), !!(buff[14] & 0x1)); + printf(" Maximum inquiry change logs=%u\n", + sg_get_unaligned_be16(buff + 15)); /* spc5r17 */ + printf(" Maximum mode page change logs=%u\n", + sg_get_unaligned_be16(buff + 17)); /* spc5r17 */ } /* VPD_SOFTW_INF_ID [0x84] */ diff --git a/src/sg_logs.c b/src/sg_logs.c index 3666d4c8..8360e0f6 100644 --- a/src/sg_logs.c +++ b/src/sg_logs.c @@ -31,7 +31,7 @@ #include "sg_unaligned.h" #include "sg_pr2serr.h" -static const char * version_str = "1.50 20170917"; /* spc5r11 + sbc4r11 */ +static const char * version_str = "1.51 20171001"; /* spc5r17 + sbc4r11 */ #define MX_ALLOC_LEN (0xfffc) #define SHORT_RESP_LEN 128 @@ -59,18 +59,18 @@ static const char * version_str = "1.50 20170917"; /* spc5r11 + sbc4r11 */ #define PCT_LPAGE 0x1a #define TAPE_ALERT_LPAGE 0x2e #define IE_LPAGE 0x2f -#define NOT_SPG_SUBPG 0x0 -#define SUPP_SPGS_SUBPG 0xff -#define LOW_GRP_STATS_SUBPG 0x1 -#define PENDING_DEFECTS_SUBPG 0x1 -#define BACKGROUND_OP_SUBPG 0x2 -#define HIGH_GRP_STATS_SUBPG 0x1f -#define CACHE_STATS_SUBPG 0x20 -#define ENV_REPORTING_SUBPG 0x1 -#define UTILIZATION_SUBPG 0x1 -#define ENV_LIMITS_SUBPG 0x2 -#define LPS_MISALIGNMENT_SUBPG 0x3 -#define ZONED_BLOCK_DEV_STATS_SUBPG 0x1 +#define NOT_SPG_SUBPG 0x0 /* page: any */ +#define SUPP_SPGS_SUBPG 0xff /* page: any */ +#define PENDING_DEFECTS_SUBPG 0x1 /* page 0x15 */ +#define BACKGROUND_OP_SUBPG 0x2 /* page 0x15 */ +#define CACHE_STATS_SUBPG 0x20 /* page 0x19 */ +#define ENV_REPORTING_SUBPG 0x1 /* page 0xd */ +#define UTILIZATION_SUBPG 0x1 /* page 0xe */ +#define ENV_LIMITS_SUBPG 0x2 /* page 0xd */ +#define LPS_MISALIGNMENT_SUBPG 0x3 /* page 0x15 */ +#define ZONED_BLOCK_DEV_STATS_SUBPG 0x1 /* page 0x14 */ +#define LAST_N_INQUIRY_DATA_CH_SUBPG 0x1 /* page 0xb */ +#define LAST_N_MODE_PG_DATA_CH_SUBPG 0x2 /* page 0xb */ /* Vendor product identifiers followed by associated mask values */ #define VP_NONE (-1) @@ -214,6 +214,10 @@ static bool show_format_status_page(const uint8_t * resp, int len, const struct opts_t * op); static bool show_last_n_deferred_error_page(const uint8_t * resp, int len, const struct opts_t * op); +static bool show_last_n_inq_data_ch_page(const uint8_t * resp, int len, + const struct opts_t * op); +static bool show_last_n_mode_pg_data_ch_page(const uint8_t * resp, int len, + const struct opts_t * op); static bool show_lb_provisioning_page(const uint8_t * resp, int len, const struct opts_t * op); static bool show_sequential_access_page(const uint8_t * resp, int len, @@ -315,6 +319,12 @@ static struct log_elem log_arr[] = { show_format_status_page}, /* 0x8, 0x0 SBC */ {LAST_N_DEFERRED_LPAGE, 0, 0, -1, 0, "Last n deferred error", "lnd", show_last_n_deferred_error_page}, /* 0xb, 0x0 */ + {LAST_N_DEFERRED_LPAGE, LAST_N_INQUIRY_DATA_CH_SUBPG, 0, -1, 0, + "Last n inquiry data changed", "lnic", + show_last_n_inq_data_ch_page}, /* 0xb, 0x1 */ + {LAST_N_DEFERRED_LPAGE, LAST_N_MODE_PG_DATA_CH_SUBPG, 0, -1, 0, + "Last n mode page data changed", "lnmc", + show_last_n_mode_pg_data_ch_page}, /* 0xb, 0x2 */ {LB_PROV_LPAGE, 0, 0, 0, 0, "Logical block provisioning", "lbp", show_lb_provisioning_page}, /* 0xc, 0x0 SBC */ {0xc, 0, 0, PDT_TAPE, 0, "Sequential access device", "sad", @@ -556,10 +566,10 @@ usage(int hval) "0)\n" " --version|-V output version string then exit\n\n" "If DEVICE and --select are given, a LOG SELECT command will be " - "issued. If\nDEVICE is not given and '--in=FN' is given then FN " - "will decoded as if it\nwere a log page. The contents of FN " - "typically generated by a prior\n" - "'sg_logs -HHH ...' invocation.\nPages defined in SPC are common " + "issued.\nIf DEVICE is not given and '--in=FN' is given then FN " + "will decoded as if\nit were a log page. The contents of FN " + "generated by either a prior\n'sg_logs -HHH ...' invocation or " + "by a text editor.\nLog pages defined in SPC are common " "to all device types.\n"); } } @@ -2571,6 +2581,125 @@ show_last_n_deferred_error_page(const uint8_t * resp, int len, return true; } +/* LAST_N_INQUIRY_DATA_CH_SUBPG [0xb,0x1] introduced: SPC-5 (rev 17) */ +static bool +show_last_n_inq_data_ch_page(const uint8_t * resp, int len, + const struct opts_t * op) +{ + int j, num, pl, pc; + const uint8_t * bp; + char str[PCB_STR_LEN]; + + if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex))) + printf("Last n Inquiry data changed [0xb,0x1]\n"); + num = len - 4; + bp = &resp[0] + 4; + while (num > 3) { + pc = sg_get_unaligned_be16(bp + 0); + pl = bp[3] + 4; + if (op->filter_given) { + if (pc != op->filter) + goto skip; + if (op->do_raw) { + dStrRaw((const char *)bp, pl); + break; + } else if (op->do_hex) { + dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1)); + break; + } + } + if (0 == pc) { + if (pl < 8) { + printf(" <<expect parameter 0x%x to be at least 8 bytes " + "long, got %d, skip>>\n", pc, pl); + goto skip; + } + printf(" Generation number of Inquiry data changed indication: " + "%u\n", sg_get_unaligned_be32(bp + 4)); + if (pl > 11) + printf(" Generation number of Mode page data changed " + "indication: %u\n", sg_get_unaligned_be32(bp + 8)); + for (j = 12; j < pl; j +=4) + printf(" Generation number of indication [0x%x]: %u\n", + (j / 4), sg_get_unaligned_be32(bp + j)); + } else { + printf(" Parameter code 0x%x, ", pc); + if (1 & *(bp + 4)) + printf("VPD page 0x%x changed\n", *(bp + 5)); + else + printf("Standard Inquiry data changed\n"); + } + if (op->do_pcb) + printf(" <%s>\n", get_pcb_str(bp[2], str, sizeof(str))); + if (op->filter_given) + break; +skip: + num -= pl; + bp += pl; + } + return true; +} + +/* LAST_N_MODE_PG_DATA_CH_SUBPG [0xb,0x2] introduced: SPC-5 (rev 17) */ +static bool +show_last_n_mode_pg_data_ch_page(const uint8_t * resp, int len, + const struct opts_t * op) +{ + int j, num, pl, pc; + const uint8_t * bp; + char str[PCB_STR_LEN]; + + if (op->verbose || ((0 == op->do_raw) && (0 == op->do_hex))) + printf("Last n Mode page data changed [0xb,0x2]\n"); + num = len - 4; + bp = &resp[0] + 4; + while (num > 3) { + pc = sg_get_unaligned_be16(bp + 0); + pl = bp[3] + 4; + if (op->filter_given) { + if (pc != op->filter) + goto skip; + if (op->do_raw) { + dStrRaw((const char *)bp, pl); + break; + } else if (op->do_hex) { + dStrHex((const char *)bp, pl, ((1 == op->do_hex) ? 1 : -1)); + break; + } + } + if (0 == pc) { /* Same as LAST_N_INQUIRY_DATA_CH_SUBPG [0xb,0x1] */ + if (pl < 8) { + printf(" <<expect parameter 0x%x to be at least 8 bytes " + "long, got %d, skip>>\n", pc, pl); + goto skip; + } + printf(" Generation number of Inquiry data changed indication: " + "%u\n", sg_get_unaligned_be32(bp + 4)); + if (pl > 11) + printf(" Generation number of Mode page data changed " + "indication: %u\n", sg_get_unaligned_be32(bp + 8)); + for (j = 12; j < pl; j +=4) + printf(" Generation number of indication [0x%x]: %u\n", + (j / 4), sg_get_unaligned_be32(bp + j)); + } else { + printf(" Parameter code 0x%x, ", pc); + if (0x40 & *(bp + 5)) /* SPF bit set */ + printf("Mode page 0x%x,0%x changed\n", (0x3f & *(bp + 5)), + *(bp + 6)); + else + printf("Mode page 0x%x changed\n", (0x3f & *(bp + 5))); + } + if (op->do_pcb) + printf(" <%s>\n", get_pcb_str(bp[2], str, sizeof(str))); + if (op->filter_given) + break; +skip: + num -= pl; + bp += pl; + } + return true; +} + static const char * self_test_code[] = { "default", "background short", "background extended", "reserved", "aborted background", "foreground short", "foreground extended", diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c index 7f11be78..371b9031 100644 --- a/src/sg_read_attr.c +++ b/src/sg_read_attr.c @@ -34,7 +34,7 @@ * and decodes the response. Based on spc5r08.pdf */ -static const char * version_str = "1.03 20170917"; +static const char * version_str = "1.03 20170926"; #define MAX_RATTR_BUFF_LEN (1024 * 1024) #define DEF_RATTR_BUFF_LEN (1024 * 8) @@ -227,8 +227,9 @@ usage() " --sa=SA|-s SA SA is service action (def: 0)\n" " --verbose|-v increase verbosity\n" " --version|-V print version string and exit\n\n" - "Performs a SCSI READ ATTRIBUTE command. It is typically used " - "on tape\nsystems.\n"); + "Performs a SCSI READ ATTRIBUTE command. Even though it is " + "defined in\nSPC-3 and later it is typically used on tape " + "systems.\n"); } /* Invokes a SCSI READ ATTRIBUTE command (SPC+SMC). Return of 0 -> success, diff --git a/src/sg_vpd.c b/src/sg_vpd.c index 5fcbb918..ddb6e199 100644 --- a/src/sg_vpd.c +++ b/src/sg_vpd.c @@ -37,7 +37,7 @@ */ -static const char * version_str = "1.27 20170920"; /* spc5r16 + sbc4r14 */ +static const char * version_str = "1.28 20170926"; /* spc5r16 + sbc4r14 */ /* standard VPD pages, in ascending page number order */ #define VPD_SUPPORTED_VPDS 0x0 @@ -1327,6 +1327,10 @@ decode_x_inq_vpd(unsigned char * b, int len, int do_hex, int do_long, printf(" SAC=%d\n", !!(b[14] & 0x4)); /* spc5r09 */ printf(" NRD1=%d\n", !!(b[14] & 0x2)); /* spc5r09 */ printf(" NRD0=%d\n", !!(b[14] & 0x1)); /* spc5r09 */ + printf(" Maximum inquiry change logs=%u\n", + sg_get_unaligned_be16(b + 15)); /* spc5r17 */ + printf(" Maximum mode page change logs=%u\n", + sg_get_unaligned_be16(b + 17)); /* spc5r17 */ return; } printf(" ACTIVATE_MICROCODE=%d SPT=%d GRD_CHK=%d APP_CHK=%d " @@ -1353,6 +1357,10 @@ decode_x_inq_vpd(unsigned char * b, int len, int do_hex, int do_long, printf(" IBS=%d IAS=%d SAC=%d NRD1=%d NRD0=%d\n", !!(b[14] & 0x80), !!(b[14] & 0x40), !!(b[14] & 0x4), !!(b[14] & 0x2), !!(b[14] & 0x1)); /* added in spc5r09 */ + printf(" Maximum inquiry change logs=%u\n", + sg_get_unaligned_be16(b + 15)); /* spc5r17 */ + printf(" Maximum mode page change logs=%u\n", + sg_get_unaligned_be16(b + 17)); /* spc5r17 */ } /* VPD_SOFTW_INF_ID */ |