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/sg_logs.c | |
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/sg_logs.c')
-rw-r--r-- | src/sg_logs.c | 163 |
1 files changed, 146 insertions, 17 deletions
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", |