diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2022-08-12 02:12:48 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2022-08-12 02:12:48 +0000 |
commit | 048bd1272b7256331117b0e7b1ab5d22cf308067 (patch) | |
tree | 3f86090e36f01551afc2aa8132ce3660d878d57a /src | |
parent | 4ea97e60c544ad44ee7396c815064d87f0d25874 (diff) | |
download | sg3_utils-048bd1272b7256331117b0e7b1ab5d22cf308067.tar.gz |
sg_inq+sg_vpd: more JSON work (add SG_C_CPP_ZERO_INIT)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@966 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
43 files changed, 1034 insertions, 1209 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b4b6bc71..021100d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,6 +65,7 @@ AM_CFLAGS = -Wall -W $(DBG_CFLAGS) # AM_CFLAGS = -Wall -W -pedantic -std=c++14 # AM_CFLAGS = -Wall -W -pedantic -std=c++1z # AM_CFLAGS = -Wall -W -pedantic -std=c++20 +# AM_CFLAGS = -Wall -W -pedantic -std=c++23 sg_bg_ctl_LDADD = ../lib/libsgutils2.la @@ -90,7 +91,7 @@ sg_ident_LDADD = ../lib/libsgutils2.la sginfo_LDADD = ../lib/libsgutils2.la -sg_inq_SOURCES = sg_inq.c sg_inq_data.c sg_vpd_common.c +sg_inq_SOURCES = sg_inq.c sg_inq_data.c sg_vpd_vendor.c sg_vpd_common.c sg_inq_LDADD = ../lib/libsgutils2.la sg_logs_LDADD = ../lib/libsgutils2.la diff --git a/src/Makefile.in b/src/Makefile.in index c07b0124..f8b5a25d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -188,7 +188,7 @@ sg_ident_SOURCES = sg_ident.c sg_ident_OBJECTS = sg_ident.$(OBJEXT) sg_ident_DEPENDENCIES = ../lib/libsgutils2.la am_sg_inq_OBJECTS = sg_inq.$(OBJEXT) sg_inq_data.$(OBJEXT) \ - sg_vpd_common.$(OBJEXT) + sg_vpd_vendor.$(OBJEXT) sg_vpd_common.$(OBJEXT) sg_inq_OBJECTS = $(am_sg_inq_OBJECTS) sg_inq_DEPENDENCIES = ../lib/libsgutils2.la sg_logs_SOURCES = sg_logs.c @@ -667,6 +667,7 @@ AM_CFLAGS = -Wall -W $(DBG_CFLAGS) # AM_CFLAGS = -Wall -W -pedantic -std=c++14 # AM_CFLAGS = -Wall -W -pedantic -std=c++1z # AM_CFLAGS = -Wall -W -pedantic -std=c++20 +# AM_CFLAGS = -Wall -W -pedantic -std=c++23 sg_bg_ctl_LDADD = ../lib/libsgutils2.la sg_compare_and_write_LDADD = ../lib/libsgutils2.la sg_copy_results_LDADD = ../lib/libsgutils2.la @@ -679,7 +680,7 @@ sg_get_elem_status_LDADD = ../lib/libsgutils2.la sg_get_lba_status_LDADD = ../lib/libsgutils2.la sg_ident_LDADD = ../lib/libsgutils2.la sginfo_LDADD = ../lib/libsgutils2.la -sg_inq_SOURCES = sg_inq.c sg_inq_data.c sg_vpd_common.c +sg_inq_SOURCES = sg_inq.c sg_inq_data.c sg_vpd_vendor.c sg_vpd_common.c sg_inq_LDADD = ../lib/libsgutils2.la sg_logs_LDADD = ../lib/libsgutils2.la sg_luns_LDADD = ../lib/libsgutils2.la diff --git a/src/sg_bg_ctl.c b/src/sg_bg_ctl.c index 0e61d38e..81e43bd4 100644 --- a/src/sg_bg_ctl.c +++ b/src/sg_bg_ctl.c @@ -93,7 +93,7 @@ sg_ll_background_control(int sg_fd, unsigned int bo_ctl, unsigned int bo_time, uint8_t bcCDB[16] = {SG_SERVICE_ACTION_IN_16, BACKGROUND_CONTROL_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (bo_ctl) diff --git a/src/sg_compare_and_write.c b/src/sg_compare_and_write.c index 89bb18b8..b8ed82df 100644 --- a/src/sg_compare_and_write.c +++ b/src/sg_compare_and_write.c @@ -355,7 +355,7 @@ sg_ll_compare_and_write(int sg_fd, uint8_t * buff, int blocks, uint64_t ull = 0; struct sg_pt_base * ptvp; uint8_t cawCmd[COMPARE_AND_WRITE_CDB_SIZE]; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; if (sg_build_scsi_cdb(cawCmd, blocks, lba, flags)) { pr2serr(ME "bad cdb build, lba=0x%" PRIx64 ", blocks=%d\n", diff --git a/src/sg_dd.c b/src/sg_dd.c index 9e0b6931..cd8eb4b2 100644 --- a/src/sg_dd.c +++ b/src/sg_dd.c @@ -717,7 +717,7 @@ sg_read_low(int sg_fd, uint8_t * buff, int blocks, int64_t from_block, int res, slen; const uint8_t * sbp; uint8_t rdCmd[MAX_SCSI_CDBSZ]; - uint8_t senseBuff[SENSE_BUFF_LEN] = {0}; + uint8_t senseBuff[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; if (sg_build_scsi_cdb(rdCmd, ifp->cdbsz, blocks, from_block, do_verify, @@ -1126,7 +1126,7 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block, uint64_t io_addr = 0; const char * op_str = do_verify ? "verifying" : "writing"; uint8_t wrCmd[MAX_SCSI_CDBSZ]; - uint8_t senseBuff[SENSE_BUFF_LEN] = {0}; + uint8_t senseBuff[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; if (sg_build_scsi_cdb(wrCmd, ofp->cdbsz, blocks, to_block, do_verify, diff --git a/src/sg_format.c b/src/sg_format.c index 8703b1d5..4f3793bd 100644 --- a/src/sg_format.c +++ b/src/sg_format.c @@ -40,7 +40,7 @@ #include "sg_pr2serr.h" #include "sg_pt.h" -static const char * version_str = "1.67 20220607"; +static const char * version_str = "1.68 20220609"; #define RW_ERROR_RECOVERY_PAGE 1 /* can give alternate with --mode=MP */ @@ -267,7 +267,7 @@ sg_ll_format_medium(int sg_fd, bool verify, bool immed, int format, int ret, res, sense_cat; uint8_t fm_cdb[SG_FORMAT_MEDIUM_CMDLEN] = {SG_FORMAT_MEDIUM_CMD, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (verify) @@ -332,7 +332,7 @@ sg_ll_format_with_preset(int sg_fd, bool immed, bool fmtmaxlba, int ret, res, sense_cat; uint8_t fwp_cdb[SG_FORMAT_WITH_PRESET_CMDLEN] = {SG_FORMAT_WITH_PRESET_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (immed) diff --git a/src/sg_get_elem_status.c b/src/sg_get_elem_status.c index 1aab2244..574052ce 100644 --- a/src/sg_get_elem_status.c +++ b/src/sg_get_elem_status.c @@ -37,7 +37,7 @@ * given SCSI device. */ -static const char * version_str = "1.14 20220729"; /* sbc5r03 */ +static const char * version_str = "1.15 20220807"; /* sbc5r03 */ #define MY_NAME "sg_get_elem_status" @@ -153,7 +153,7 @@ sg_ll_get_phy_elem_status(int sg_fd, uint32_t starting_elem, uint8_t filter, uint8_t gpesCmd[16] = {SG_SERVICE_ACTION_IN_16, GET_PHY_ELEM_STATUS_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; static const char * const cmd_name = "Get physical element status"; @@ -300,7 +300,7 @@ main(int argc, char * argv[]) sgj_opaque_p jo2p; sgj_opaque_p jap = NULL; struct gpes_desc_t a_ped; - sgj_state json_st = {0}; + sgj_state json_st SG_C_CPP_ZERO_INIT; sgj_state * jsp = &json_st; char b[80]; static const int blen = sizeof(b); @@ -556,12 +556,12 @@ start_response: goto fini; } - sgj_hr_js_vi(jsp, jop, 0, "Number of descriptors", - SGJ_SEP_COLON_1_SPACE, num_desc, true); - sgj_hr_js_vi(jsp, jop, 0, "Number of descriptors returned", - SGJ_SEP_COLON_1_SPACE, num_desc_ret, true); - sgj_hr_js_vi(jsp, jop, 0, "Identifier of element being depopulated", - SGJ_SEP_COLON_1_SPACE, id_elem_depop, true); + sgj_haj_vi(jsp, jop, 0, "Number of descriptors", + SGJ_SEP_COLON_1_SPACE, num_desc, true); + sgj_haj_vi(jsp, jop, 0, "Number of descriptors returned", + SGJ_SEP_COLON_1_SPACE, num_desc_ret, true); + sgj_haj_vi(jsp, jop, 0, "Identifier of element being depopulated", + SGJ_SEP_COLON_1_SPACE, id_elem_depop, true); if (rlen < 64) { sgj_pr_hr(jsp, "No complete physical element status descriptors " "available\n"); diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c index 3acf07b0..97b967dd 100644 --- a/src/sg_get_lba_status.c +++ b/src/sg_get_lba_status.c @@ -35,7 +35,7 @@ * device. */ -static const char * version_str = "1.30 20220729"; /* sbc5r01 */ +static const char * version_str = "1.31 20220807"; /* sbc5r03 */ #define MY_NAME "sg_get_lba_status" @@ -249,7 +249,7 @@ main(int argc, char * argv[]) sgj_opaque_p jop = NULL; sgj_opaque_p jo2p = NULL; sgj_opaque_p jap = NULL; - sgj_state json_st = {0}; + sgj_state json_st SG_C_CPP_ZERO_INIT; sgj_state * jsp = &json_st; char b[144]; static const size_t blen = sizeof(b); @@ -563,8 +563,8 @@ start_response: num_descs = (rlen - 8) / 16; completion_cond = (*(glbasBuffp + 7) >> 1) & 7; /* added sbc4r14 */ if (do_brief) - sgj_hr_js_vi(jsp, jop, 0, compl_cond_s, SGJ_SEP_EQUAL_NO_SPACE, - completion_cond, true); + sgj_haj_vi(jsp, jop, 0, compl_cond_s, SGJ_SEP_EQUAL_NO_SPACE, + completion_cond, true); else { switch (completion_cond) { case 0: @@ -590,8 +590,8 @@ start_response: sgj_js_nv_istr(jsp, jop, compl_cond_s, completion_cond, NULL /* "meaning" */, b); } - sgj_hr_js_vi(jsp, jop, 0, "RTP", SGJ_SEP_EQUAL_NO_SPACE, - *(glbasBuffp + 7) & 0x1, true); /* added sbc4r12 */ + sgj_haj_vi(jsp, jop, 0, "RTP", SGJ_SEP_EQUAL_NO_SPACE, + *(glbasBuffp + 7) & 0x1, true); /* added sbc4r12 */ if (verbose) pr2serr("%d complete LBA status descriptors found\n", num_descs); if (jsp->pr_as_json) diff --git a/src/sg_inq.c b/src/sg_inq.c index 9745c0ec..681073fe 100644 --- a/src/sg_inq.c +++ b/src/sg_inq.c @@ -53,7 +53,7 @@ #include "sg_vpd_common.h" /* for shared VPD page processing with sg_vpd */ -static const char * version_str = "2.27 20220806"; /* spc6r06, sbc5r03 */ +static const char * version_str = "2.28 20220811"; /* spc6r06, sbc5r03 */ #define MY_NAME "sg_inq" @@ -84,6 +84,9 @@ static const char * version_str = "2.27 20220806"; /* spc6r06, sbc5r03 */ * information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes. */ +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< TESTING +// #undef SG_SCSI_STRINGS +// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< TESTING #ifndef SG_NVME_VPD_NICR #define SG_NVME_VPD_NICR 0xde @@ -168,6 +171,9 @@ static struct svpd_values_name_t t10_vpd_pg[] = { {VPD_FORMAT_PRESETS, 0, 0, "fp", "Format presets"}, {VPD_LB_PROVISIONING, 0, 0, "lbpv", "Logical block provisioning " "(SBC)"}, + {VPD_MAN_ASS_SN, 0, 1, "mas", "Manufacturer assigned serial number (SSC)"}, + {VPD_MAN_ASS_SN, 0, 0x12, "masa", + "Manufacturer assigned serial number (ADC)"}, {VPD_MAN_NET_ADDR, 0, -1, "mna", "Management network addresses"}, {VPD_MODE_PG_POLICY, 0, -1, "mpp", "Mode page policy"}, {VPD_POWER_CONDITION, 0, -1, "po", "Power condition"}, @@ -424,18 +430,18 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) #ifdef SG_LIB_LINUX #ifdef SG_SCSI_STRINGS - c = getopt_long(argc, argv, "aB:cdeEfhHiI:j::l:Lm:NoOp:Q:rsuvVx", + c = getopt_long(argc, argv, "aB:cdeEfhHiI:j::l:Lm:M:NoOp:Q:rsuvVx", long_options, &option_index); #else - c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:op:Q:rsuvVx", + c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:M:op:Q:rsuvVx", long_options, &option_index); #endif /* SG_SCSI_STRINGS */ #else /* SG_LIB_LINUX */ #ifdef SG_SCSI_STRINGS - c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:NoOp:Q:rsuvVx", + c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:M:NoOp:Q:rsuvVx", long_options, &option_index); #else - c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:op:Q:rsuvVx", + c = getopt_long(argc, argv, "B:cdeEfhHiI:j::l:Lm:M:op:Q:rsuvVx", long_options, &option_index); #endif /* SG_SCSI_STRINGS */ #endif /* SG_LIB_LINUX */ @@ -531,6 +537,14 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) } op->maxlen = n; break; + case 'M': + if (op->vend_prod) { + pr2serr("only one '--vendor=' option permitted\n"); + usage(); + return SG_LIB_SYNTAX_ERROR; + } else + op->vend_prod = optarg; + break; case 'L': ++op->do_long; break; @@ -1080,8 +1094,8 @@ svpd_inhex_decode_all(struct opts_t * op, sgj_opaque_p jop) static void -decode_supported_vpd(uint8_t * buff, int len, struct opts_t * op, - sgj_opaque_p jap) +decode_supported_vpd_4inq(uint8_t * buff, int len, struct opts_t * op, + sgj_opaque_p jap) { int vpd, k, rlen, pdt; sgj_state * jsp = &op->json_st; @@ -1149,12 +1163,6 @@ vpd_page_is_supported(uint8_t * vpd_pg0, int v0_len, int pg_num, int vb) return false; } -static bool -vpd_page_not_supported(uint8_t * vpd_pg0, int v0_len, int pg_num, int vb) -{ - return ! vpd_page_is_supported(vpd_pg0, v0_len, pg_num, vb); -} - /* ASCII Information VPD pages (page numbers: 0x1 to 0x7f) */ static void decode_ascii_inf(uint8_t * buff, int len, int do_hex) @@ -1205,8 +1213,8 @@ decode_id_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_opaque_p jap) /* VPD_SCSI_PORTS 0x88 ["sp"] */ static void -decode_scsi_ports_vpd(uint8_t * buff, int len, struct opts_t * op, - sgj_opaque_p jap) +decode_scsi_ports_vpd_4inq(uint8_t * buff, int len, struct opts_t * op, + sgj_opaque_p jap) { int k, bump, rel_port, ip_tid_len, tpd_len; uint8_t * bp; @@ -1949,27 +1957,33 @@ export_dev_ids(uint8_t * buff, int len, int verbose) /* Sequential access device characteristics, ssc+smc */ /* OSD information, osd */ static void -decode_b0_vpd(uint8_t * buff, int len, int do_hex) +decode_b0_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_opaque_p jop) { - int pdt; + int pdt = PDT_MASK & buff[0]; + sgj_state * jsp = &op->json_st; - if (do_hex) { - hex2stdout(buff, len, (1 == do_hex) ? 0 : -1); + if (op->do_hex) { + hex2stdout(buff, len, (1 == op->do_hex) ? 0 : -1); return; } - pdt = PDT_MASK & buff[0]; switch (pdt) { - case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_ZBC: - /* done by decode_block_limits_vpd() */ - break; - case PDT_TAPE: case PDT_MCHANGER: - printf(" WORM=%d\n", !!(buff[4] & 0x1)); - break; - case PDT_OSD: - default: - printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); - hex2stdout(buff, len, 0); - break; + case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_ZBC: + /* done by decode_block_limits_vpd() */ + break; + case PDT_TAPE: case PDT_MCHANGER: + sgj_haj_vi_nex(jsp, jop, 2, "TSMC", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[4] & 0x2), false, "Tape Stream Mirror " + "Capable"); + sgj_haj_vi_nex(jsp, jop, 2, "WORM", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[4] & 0x1), false, "Write Once Read Multple " + "supported"); + + break; + case PDT_OSD: + default: + printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); + hex2stdout(buff, len, 0); + break; } } @@ -2581,82 +2595,6 @@ std_inq_decode(struct opts_t * op, sgj_opaque_p jop, int off) } } -/* When sg_fd >= 0 fetch VPD page from device; mxlen is command line - * --maxlen=LEN option (def: 0) or -1 for a VPD page with a short length - * field (1 byte). When sg_fd < 0 then mxlen bytes have been read from - * --inhex=FN file. Returns 0 for success. */ -static int -vpd_fetch_page_from_dev(int sg_fd, uint8_t * rp, int page, - int mxlen, int vb, int * rlenp) -{ - int res, resid, rlen, len, n; - - if (sg_fd < 0) { - len = sg_get_unaligned_be16(rp + 2) + 4; - if (vb && (len > mxlen)) - pr2serr("warning: VPD page's length (%d) > bytes in --inhex=FN " - "file (%d)\n", len , mxlen); - if (rlenp) - *rlenp = (len < mxlen) ? len : mxlen; - return 0; - } - if (mxlen > MX_ALLOC_LEN) { - pr2serr("--maxlen=LEN too long: %d > %d\n", mxlen, MX_ALLOC_LEN); - return SG_LIB_SYNTAX_ERROR; - } - n = (mxlen > 0) ? mxlen : DEF_ALLOC_LEN; - res = sg_ll_inquiry_v2(sg_fd, true, page, rp, n, DEF_PT_TIMEOUT, &resid, - true, vb); - if (res) - return res; - rlen = n - resid; - if (rlen < 4) { - pr2serr("VPD response too short (len=%d)\n", rlen); - return SG_LIB_CAT_MALFORMED; - } - if (page != rp[1]) { - pr2serr("invalid VPD response; probably a STANDARD INQUIRY " - "response\n"); - return SG_LIB_CAT_MALFORMED; - } else if ((0x80 == page) && (0x2 == rp[2]) && (0x2 == rp[3])) { - /* could be a Unit Serial number VPD page with a very long - * length of 4+514 bytes; more likely standard response for - * SCSI-2, RMB=1 and a response_data_format of 0x2. */ - pr2serr("invalid Unit Serial Number VPD response; probably a " - "STANDARD INQUIRY response\n"); - return SG_LIB_CAT_MALFORMED; - } - if (mxlen < 0) - len = rp[3] + 4; - else - len = sg_get_unaligned_be16(rp + 2) + 4; - if (len <= rlen) { - if (rlenp) - *rlenp = len; - return 0; - } else if (mxlen) { - if (rlenp) - *rlenp = rlen; - return 0; - } - if (len > MX_ALLOC_LEN) { - pr2serr("response length too long: %d > %d\n", len, MX_ALLOC_LEN); - return SG_LIB_CAT_MALFORMED; - } else { - /* First response indicated that not enough bytes of response were - * requested, so try again, this time requesting more. */ - res = sg_ll_inquiry_v2(sg_fd, true, page, rp, len, DEF_PT_TIMEOUT, - &resid, true, vb); - if (res) - return res; - rlen = len - resid; - /* assume it is well behaved: hence page and len still same */ - if (rlenp) - *rlenp = rlen; - return 0; - } -} - /* Returns 0 if Unit Serial Number VPD page contents found, else see * sg_ll_inquiry_v2() return values */ static int @@ -2671,22 +2609,22 @@ fetch_unit_serial_num(int sg_fd, char * obuff, int obuff_len, int verbose) pr2serr("%s: unable to allocate on heap\n", __func__); return sg_convert_errno(ENOMEM); } - res = vpd_fetch_page_from_dev(sg_fd, b, VPD_SUPPORTED_VPDS, - -1 /* 1 byte alloc_len */, verbose, &len); + res = vpd_fetch_page(sg_fd, b, VPD_SUPPORTED_VPDS, + -1 /* 1 byte alloc_len */, false, verbose, &len); if (res) { if (verbose > 2) pr2serr("%s: no supported VPDs page\n", __func__); res = SG_LIB_CAT_MALFORMED; goto fini; } - if (vpd_page_not_supported(b, len, VPD_UNIT_SERIAL_NUM, verbose)) { + if (! vpd_page_is_supported(b, len, VPD_UNIT_SERIAL_NUM, verbose)) { res = sg_convert_errno(EDOM); /* was SG_LIB_CAT_ILLEGAL_REQ */ goto fini; } memset(b, 0xff, 4); /* guard against empty response */ - res = vpd_fetch_page_from_dev(sg_fd, b, VPD_UNIT_SERIAL_NUM, -1, verbose, - &len); + res = vpd_fetch_page(sg_fd, b, VPD_UNIT_SERIAL_NUM, -1, false, verbose, + &len); if ((0 == res) && (len > 3)) { len -= 4; len = (len < (obuff_len - 1)) ? len : (obuff_len - 1); @@ -2947,15 +2885,15 @@ vpd_mainly_hex(int sg_fd, struct opts_t * op, sgj_opaque_p jap, int off) res = 0; } else { memset(rp, 0, DEF_ALLOC_LEN); - res = vpd_fetch_page_from_dev(sg_fd, rp, op->vpd_pn, op->maxlen, - op->verbose, &len); + res = vpd_fetch_page(sg_fd, rp, op->vpd_pn, op->maxlen, + op->do_quiet, op->verbose, &len); } if (0 == res) { if (op->do_raw) dStrRaw((const char *)rp, len); else { if (0 == op->vpd_pn) - decode_supported_vpd(rp, len, op, jap); + decode_supported_vpd_4inq(rp, len, op, jap); else { if (op->verbose) { cp = sg_get_pdt_str(rp[0] & PDT_MASK, sizeof(b), b); @@ -2988,6 +2926,7 @@ static int vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) { bool bad = false; + bool qt = op->do_quiet; int len, pdt, pn, vb /*, pqual */; int res = 0; sgj_state * jsp = &op->json_st; @@ -3005,11 +2944,11 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) else pn = op->vpd_pn; if (sg_fd != -1 && !op->do_force && pn != VPD_SUPPORTED_VPDS) { - res = vpd_fetch_page_from_dev(sg_fd, rp, VPD_SUPPORTED_VPDS, - op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, VPD_SUPPORTED_VPDS, op->maxlen, + qt, vb, &len); if (res) goto out; - if (vpd_page_not_supported(rp, len, pn, vb)) { + if (! vpd_page_is_supported(rp, len, pn, vb)) { if (vb) pr2serr("Given VPD page not in supported list, use --force " "to override this check\n"); @@ -3022,7 +2961,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Supported VPD pages VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3035,14 +2974,14 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) jap = sgj_named_subarray_r(jsp, jo2p, "supported_vpd_page_list"); } - decode_supported_vpd(rp, len, op, jap); + decode_supported_vpd_4inq(rp, len, op, jap); } break; case VPD_UNIT_SERIAL_NUM: /* 0x80 ["sn"] */ np = "Unit serial number VPD page"; if (! op->do_raw && ! op->do_export && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3089,7 +3028,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Device Identification VPD page"; if (! op->do_raw && ! op->do_export && (op->do_hex < 3)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3111,7 +3050,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Software interface identification VPD page"; if (! op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3129,7 +3068,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Management network addresses page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3150,7 +3089,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Extended INQUIRY data"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s page\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3165,7 +3104,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Mode page policy"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3183,7 +3122,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "SCSI Ports VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3194,14 +3133,14 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) jap = sgj_named_subarray_r(jsp, jo2p, "scsi_ports_descriptor_list"); } - decode_scsi_ports_vpd(rp, len, op, jap); + decode_scsi_ports_vpd_4inq(rp, len, op, jap); } break; case VPD_ATA_INFO: /* 0x89 ["ai"] */ np = "ATA information VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; /* format output for 'hdparm --Istdin' with '-rr' or '-HHH' */ @@ -3222,7 +3161,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Power condition VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3237,7 +3176,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Power consumption VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3248,14 +3187,14 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) jap = sgj_named_subarray_r(jsp, jo2p, "power_consumption_descriptor_list"); } - decode_power_consumption(rp, len, jop, jap); + decode_power_consumption(rp, len, op, jap); } break; case VPD_DEVICE_CONSTITUENTS: /* 0x8b ["dc"] */ np = "Device constituents page VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3273,7 +3212,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Third party copy VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3291,7 +3230,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Protocol specific logical unit information VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3309,7 +3248,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "Protocol specific port information VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3327,7 +3266,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) np = "SCSI Feature sets VPD page"; if (!op->do_raw && (op->do_hex < 2)) sgj_pr_hr(jsp, "VPD INQUIRY: %s\n", np); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3343,7 +3282,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) break; case 0xb0: /* VPD pages in B0h to BFh range depend on pdt */ np = NULL; - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool bl = false; bool sad = false; @@ -3385,13 +3324,13 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) jo2p = sg_vpd_js_hdr(jsp, jop, np, rp); if (bl) decode_block_limits_vpd(rp, len, op, jo2p); - else if (sad || oi) // more work here <<<<<<<<<< - decode_b0_vpd(rp, len, op->do_hex); + else if (sad || oi) + decode_b0_vpd(rp, len, op, jop); } else if (! op->do_raw) pr2serr("VPD INQUIRY: page=0xb0\n"); break; case 0xb1: /* VPD pages in B0h to BFh range depend on pdt */ - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool bdc = false; static const char * masn = @@ -3441,7 +3380,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off) pr2serr("VPD INQUIRY: page=0xb1\n"); break; case 0xb2: /* VPD pages in B0h to BFh range depend on pdt */ - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool lbpv = false; @@ -3487,7 +3426,7 @@ xxxxx return vpd_mainly_hex(sg_fd, op, NULL, off); #endif case 0xb3: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool ref = false; @@ -3523,7 +3462,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb3\n"); break; case 0xb4: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool sbl = false; @@ -3562,7 +3501,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb4\n"); break; case 0xb5: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool bdce = false; @@ -3598,7 +3537,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb5\n"); break; case 0xb6: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool zbdch = false; @@ -3634,7 +3573,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb6\n"); break; case 0xb7: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool ble = false; @@ -3670,7 +3609,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb7\n"); break; case 0xb8: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool fp = false; @@ -3709,7 +3648,7 @@ xxxxx pr2serr("VPD INQUIRY: page=0xb8\n"); break; case 0xb9: - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { bool cpr = false; @@ -3751,7 +3690,7 @@ xxxxx case VPD_UPR_EMC: /* 0xc0 */ if (!op->do_raw && (op->do_hex < 2)) printf("VPD INQUIRY: Unit Path Report Page (EMC)\n"); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, -1, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, -1, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3762,7 +3701,7 @@ xxxxx case VPD_RDAC_VERS: /* 0xc2 */ if (!op->do_raw && (op->do_hex < 2)) printf("VPD INQUIRY: Software Version (RDAC)\n"); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, -1, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, -1, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3773,7 +3712,7 @@ xxxxx case VPD_RDAC_VAC: /* 0xc9 */ if (!op->do_raw && (op->do_hex < 2)) printf("VPD INQUIRY: Volume Access Control (RDAC)\n"); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, -1, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, -1, qt, vb, &len); if (res) break; if (op->do_raw) @@ -3790,7 +3729,7 @@ xxxxx if (!op->do_raw && (op->do_hex < 2)) printf("VPD INQUIRY: ASCII information page, FRU code=0x%x\n", pn); - res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len); + res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len); if (0 == res) { if (op->do_raw) dStrRaw((const char *)rp, len); @@ -4197,18 +4136,20 @@ main(int argc, char * argv[]) int res, n, err; int sg_fd = -1; int ret = 0; + int subvalue = 0; int inhex_len = 0; int inraw_len = 0; + const char * cp; const struct svpd_values_name_t * vnp; sgj_state * jsp; sgj_opaque_p jop = NULL; - struct opts_t opts; + struct opts_t opts SG_C_CPP_ZERO_INIT; struct opts_t * op; op = &opts; - memset(op, 0, sizeof(opts)); op->invoker = SG_VPD_INV_SG_INQ; op->vpd_pn = -1; + op->vend_prod_num = -1; op->page_pdt = -1; op->do_block = -1; /* use default for OS */ res = parse_cmd_line(op, argc, argv); @@ -4243,13 +4184,17 @@ main(int argc, char * argv[]) pr2serr("Version string: %s\n", version_str); return 0; } + jsp = &op->json_st; + as_json = jsp->pr_as_json; if (op->page_str) { if (op->vpd_pn >= 0) { pr2serr("Given '-p' option and another option that " "implies a page\n"); return SG_LIB_CONTRADICT; } - if (isalpha((uint8_t)op->page_str[0])) { + if ('-' == op->page_str[0]) + op->vpd_pn = VPD_NOPE_WANT_STD_INQ; + else if (isalpha((uint8_t)op->page_str[0])) { vnp = sdp_find_vpd_by_acron(op->page_str); if (NULL == vnp) { #ifdef SG_SCSI_STRINGS @@ -4270,9 +4215,58 @@ main(int argc, char * argv[]) if ((1 != op->do_hex) && (0 == op->do_raw)) op->do_decode = true; op->vpd_pn = vnp->value; + subvalue = vnp->subvalue; op->page_pdt = vnp->pdt; - } else if ('-' == op->page_str[0]) - op->vpd_pn = VPD_NOPE_WANT_STD_INQ; + } else { + cp = strchr(op->page_str, ','); + if (cp && op->vend_prod) { + pr2serr("the --page=pg,vp and the --vendor=vp forms overlap, " + "choose one or the other\n"); + ret = SG_LIB_SYNTAX_ERROR; + goto err_out; + } + op->vpd_pn = sg_get_num_nomult(op->page_str); + if ((op->vpd_pn < 0) || (op->vpd_pn > 255)) { + pr2serr("Bad page code value after '-p' option\n"); + printf("Available standard VPD pages:\n"); + enumerate_vpds(/* 1, 1 */); + ret = SG_LIB_SYNTAX_ERROR; + goto err_out; + } + if (cp) { + if (isdigit((uint8_t)*(cp + 1))) + op->vend_prod_num = sg_get_num_nomult(cp + 1); + else + op->vend_prod_num = svpd_find_vp_num_by_acron(cp + 1); + if ((op->vend_prod_num < 0) || (op->vend_prod_num > 255)) { + pr2serr("Bad vendor/product acronym after comma in '-p' " + "option\n"); + if (op->vend_prod_num < 0) + svpd_enumerate_vendor(-1); + ret = SG_LIB_SYNTAX_ERROR; + goto err_out; + } + subvalue = op->vend_prod_num; + } else if (op->vend_prod) { + if (isdigit((uint8_t)op->vend_prod[0])) + op->vend_prod_num = sg_get_num_nomult(op->vend_prod); + else + op->vend_prod_num = + svpd_find_vp_num_by_acron(op->vend_prod); + if ((op->vend_prod_num < 0) || (op->vend_prod_num > 255)) { + pr2serr("Bad vendor/product acronym after '--vendor=' " + "option\n"); + svpd_enumerate_vendor(-1); + ret = SG_LIB_SYNTAX_ERROR; + goto err_out; + } + subvalue = op->vend_prod_num; + } + } + if (op->verbose > 3) + pr2serr("'--page=' matched pn=%d [0x%x], subvalue=%d\n", + op->vpd_pn, op->vpd_pn, subvalue); +#if 0 else { #ifdef SG_SCSI_STRINGS if (op->opt_new) { @@ -4311,9 +4305,21 @@ main(int argc, char * argv[]) #endif /* SG_SCSI_STRINGS */ op->vpd_pn = n; } +#endif + } else if (op->vend_prod) { + if (isdigit((uint8_t)op->vend_prod[0])) + op->vend_prod_num = sg_get_num_nomult(op->vend_prod); + else + op->vend_prod_num = svpd_find_vp_num_by_acron(op->vend_prod); + if ((op->vend_prod_num < 0) || (op->vend_prod_num > 255)) { + pr2serr("Bad vendor/product acronym after '--vendor=' " + "option\n"); + svpd_enumerate_vendor(-1); + ret = SG_LIB_SYNTAX_ERROR; + goto err_out; + } + subvalue = op->vend_prod_num; } - jsp = &op->json_st; - as_json = jsp->pr_as_json; if (as_json) jop = sgj_start_r(MY_NAME, version_str, argc, argv, jsp); diff --git a/src/sg_logs.c b/src/sg_logs.c index 66665b4a..32bfc721 100644 --- a/src/sg_logs.c +++ b/src/sg_logs.c @@ -7253,7 +7253,7 @@ main(int argc, char * argv[]) uint8_t * free_parr = NULL; struct opts_t * op; struct sg_simple_inquiry_resp inq_out; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; uint8_t supp_pgs_rsp[256]; op = &opts; diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c index bb092065..41eb274c 100644 --- a/src/sg_opcodes.c +++ b/src/sg_opcodes.c @@ -217,7 +217,7 @@ do_rsoc(struct sg_pt_base * ptvp, bool rctd, int rep_opts, int rq_opcode, int ret, res, sense_cat; uint8_t rsoc_cdb[RSOC_CMD_LEN] = {SG_MAINTENANCE_IN, RSOC_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; if (rctd) rsoc_cdb[2] |= 0x80; @@ -281,7 +281,7 @@ do_rstmf(struct sg_pt_base * ptvp, bool repd, void * resp, int mx_resp_len, int ret, res, sense_cat; uint8_t rstmf_cdb[RSTMF_CMD_LEN] = {SG_MAINTENANCE_IN, RSTMF_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; if (repd) rstmf_cdb[2] = 0x80; diff --git a/src/sg_raw.c b/src/sg_raw.c index 19ab56f9..a0254cd9 100644 --- a/src/sg_raw.c +++ b/src/sg_raw.c @@ -543,7 +543,7 @@ main(int argc, char *argv[]) uint16_t sct_sc; uint32_t result; struct sg_pt_base *ptvp = NULL; - uint8_t sense_buffer[32] = {0}; + uint8_t sense_buffer[32] SG_C_CPP_ZERO_INIT; uint8_t * dinp = NULL; uint8_t * doutp = NULL; uint8_t * free_buf_out = NULL; diff --git a/src/sg_rbuf.c b/src/sg_rbuf.c index 180c19bc..d37cc259 100644 --- a/src/sg_rbuf.c +++ b/src/sg_rbuf.c @@ -368,8 +368,8 @@ main(int argc, char * argv[]) struct opts_t * op; uint8_t * rbBuff = NULL; void * rawp = NULL; - uint8_t sense_buffer[32] = {0}; - uint8_t rb_cdb [RB_CMD_LEN] = {0}; + uint8_t sense_buffer[32] SG_C_CPP_ZERO_INIT; + uint8_t rb_cdb [RB_CMD_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; struct timeval start_tm, end_tm; struct opts_t opts; diff --git a/src/sg_read.c b/src/sg_read.c index 52304970..4c48b474 100644 --- a/src/sg_read.c +++ b/src/sg_read.c @@ -298,7 +298,7 @@ sg_bread(int sg_fd, uint8_t * buff, int blocks, int64_t from_block, int bs, bool no_dxfer) { uint8_t rdCmd[MAX_SCSI_CDBSZ]; - uint8_t senseBuff[SENSE_BUFF_LEN] = {0}; + uint8_t senseBuff[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; if (sg_build_scsi_cdb(rdCmd, cdbsz, blocks, from_block, false, fua, diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c index b0bcedb0..89ca26da 100644 --- a/src/sg_read_attr.c +++ b/src/sg_read_attr.c @@ -249,7 +249,7 @@ sg_ll_read_attr(int sg_fd, void * resp, int * residp, bool noisy, uint8_t ra_cdb[SG_READ_ATTRIBUTE_CMDLEN] = {SG_READ_ATTRIBUTE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; ra_cdb[1] = 0x1f & op->sa; diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c index 232b94cd..8dbd1703 100644 --- a/src/sg_read_buffer.c +++ b/src/sg_read_buffer.c @@ -200,7 +200,7 @@ sg_ll_read_buffer_10(void * resp, int * residp, bool noisy, int ret, res, sense_cat; uint8_t rb10_cb[SG_READ_BUFFER_10_CMDLEN] = {SG_READ_BUFFER_10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; rb10_cb[1] = (uint8_t)(op->rb_mode & 0x1f); @@ -267,7 +267,7 @@ sg_ll_read_buffer_16(void * resp, int * residp, bool noisy, uint8_t rb16_cb[SG_READ_BUFFER_16_CMDLEN] = {SG_READ_BUFFER_16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; rb16_cb[1] = (uint8_t)(op->rb_mode & 0x1f); @@ -506,7 +506,7 @@ main(int argc, char * argv[]) uint8_t * resp = NULL; uint8_t * free_resp = NULL; const struct mode_s * mp; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; struct opts_t * op = &opts; op->sg_fd = -1; diff --git a/src/sg_rem_rest_elem.c b/src/sg_rem_rest_elem.c index 46af7287..c2ed6012 100644 --- a/src/sg_rem_rest_elem.c +++ b/src/sg_rem_rest_elem.c @@ -102,7 +102,7 @@ sg_ll_rem_rest_elem(int sg_fd, int sa, uint64_t req_cap, uint32_t e_id, uint8_t sai16_cdb[16] = {SG_SERVICE_ACTION_IN_16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; const char * cmd_name; sai16_cdb[1] = 0x1f & sa; diff --git a/src/sg_rep_density.c b/src/sg_rep_density.c index 5c68b679..afe6f299 100644 --- a/src/sg_rep_density.c +++ b/src/sg_rep_density.c @@ -113,7 +113,7 @@ sg_ll_report_density(int sg_fd, bool media, bool m_type, void * resp, int ret, res, sense_cat; uint8_t rds_cdb[REPORT_DENSITY_SUPPORT_CMDLEN] = {REPORT_DENSITY_SUPPORT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (media) diff --git a/src/sg_rep_pip.c b/src/sg_rep_pip.c index d3ed0852..beadaa23 100644 --- a/src/sg_rep_pip.c +++ b/src/sg_rep_pip.c @@ -102,7 +102,7 @@ sg_ll_report_pip(int sg_fd, void * resp, int mx_resp_len, int * residp, uint8_t rpip_cdb[SG_MAINT_IN_CMDLEN] = {SG_MAINTENANCE_IN, REPORT_PROVISIONING_INITIALIZATION_PATTERN_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; sg_put_unaligned_be32((uint32_t)mx_resp_len, rpip_cdb + 6); diff --git a/src/sg_rep_zones.c b/src/sg_rep_zones.c index d6c03e7c..536f619c 100644 --- a/src/sg_rep_zones.c +++ b/src/sg_rep_zones.c @@ -40,7 +40,7 @@ * Based on zbc2r12.pdf */ -static const char * version_str = "1.41 20220717"; +static const char * version_str = "1.42 20220807"; #define MY_NAME "sg_rep_zones" @@ -264,7 +264,7 @@ sg_ll_report_zzz(int sg_fd, enum zone_report_sa_e serv_act, uint64_t zs_lba, uint8_t rz_cdb[SG_ZONING_IN_CMDLEN] = {SG_ZONING_IN, REPORT_ZONES_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; rz_cdb[1] = (uint8_t)serv_act; @@ -398,12 +398,12 @@ prt_a_zn_desc(const uint8_t *bp, const struct opts_t * op, zone_condition_str(zc, b, sizeof(b), op->vb); sgj_pr_hr(jsp, " Zone condition: %s\n", b); sgj_js_nv_istr(jsp, jop, "zone_condition", zc, meaning_s, b); - sgj_hr_js_vi(jsp, jop, 3, "PUEP", SGJ_SEP_COLON_1_SPACE, - !!(bp[1] & 0x4), false); - sgj_hr_js_vi(jsp, jop, 3, "NON_SEQ", SGJ_SEP_COLON_1_SPACE, - !!(bp[1] & 0x2), false); - sgj_hr_js_vi(jsp, jop, 3, "RESET", SGJ_SEP_COLON_1_SPACE, - !!(bp[1] & 0x1), false); + sgj_haj_vi(jsp, jop, 3, "PUEP", SGJ_SEP_COLON_1_SPACE, + !!(bp[1] & 0x4), false); + sgj_haj_vi(jsp, jop, 3, "NON_SEQ", SGJ_SEP_COLON_1_SPACE, + !!(bp[1] & 0x2), false); + sgj_haj_vi(jsp, jop, 3, "RESET", SGJ_SEP_COLON_1_SPACE, + !!(bp[1] & 0x1), false); len = sg_get_unaligned_be64(bp + 8); sgj_pr_hr(jsp, " Zone Length: 0x%" PRIx64 "\n", len); sgj_js_nv_ihex(jsp, jop, "zone_length", (int64_t)len); @@ -552,10 +552,10 @@ decode_rep_realms(const uint8_t * rzBuff, int act_len, nr_locator = sg_get_unaligned_be64(rzBuff + 12); else nr_locator = 0; - sgj_hr_js_vi(jsp, jop, 0, "Realms_count", SGJ_SEP_EQUAL_NO_SPACE, - realms_count, true); - sgj_hr_js_vi(jsp, jop, 0, "Realms_descriptor_length", - SGJ_SEP_EQUAL_NO_SPACE, r_desc_len, true); + sgj_haj_vi(jsp, jop, 0, "Realms_count", SGJ_SEP_EQUAL_NO_SPACE, + realms_count, true); + sgj_haj_vi(jsp, jop, 0, "Realms_descriptor_length", + SGJ_SEP_EQUAL_NO_SPACE, r_desc_len, true); sgj_pr_hr(jsp, "Next_realm_locator=0x%" PRIx64 "\n", nr_locator); sgj_js_nv_ihex(jsp, jop, "Next_realm_locator", nr_locator); if ((realms_count < 1) || (act_len < (64 + 16)) || (r_desc_len < 16)) { @@ -596,8 +596,8 @@ decode_rep_realms(const uint8_t * rzBuff, int act_len, sgj_opaque_p jo2p; jo2p = sgj_new_unattached_object_r(jsp); - sgj_hr_js_vi(jsp, jo2p, 1, "Realms_id", SGJ_SEP_EQUAL_NO_SPACE, - sg_get_unaligned_be32(bp + 0), true); + sgj_haj_vi(jsp, jo2p, 1, "Realms_id", SGJ_SEP_EQUAL_NO_SPACE, + sg_get_unaligned_be32(bp + 0), true); if (op->do_hex) { hex2stdout(bp, r_desc_len, -1); continue; @@ -605,8 +605,8 @@ decode_rep_realms(const uint8_t * rzBuff, int act_len, restrictions = sg_get_unaligned_be16(bp + 4); sgj_pr_hr(jsp, " realm_restrictions=0x%hu\n", restrictions); sgj_js_nv_ihex(jsp, jo2p, "realm_restrictions", restrictions); - sgj_hr_js_vi(jsp, jo2p, 3, "active_zone_domain_id", - SGJ_SEP_EQUAL_NO_SPACE, bp[7], true); + sgj_haj_vi(jsp, jo2p, 3, "active_zone_domain_id", + SGJ_SEP_EQUAL_NO_SPACE, bp[7], true); ja2p = sgj_named_subarray_r(jsp, jo2p, "realm_start_end_descriptors_list"); @@ -654,12 +654,12 @@ decode_rep_zdomains(const uint8_t * rzBuff, int act_len, zd_locator = sg_get_unaligned_be64(rzBuff + 16); else zd_locator = 0; - sgj_hr_js_vi(jsp, jop, 0, "Zone_domains_returned_list_length=", - SGJ_SEP_EQUAL_NO_SPACE, zd_ret_len, true); - sgj_hr_js_vi(jsp, jop, 0, "Zone_domains_supported", - SGJ_SEP_EQUAL_NO_SPACE, zdoms_sup, true); - sgj_hr_js_vi(jsp, jop, 0, "Zone_domains_reported", - SGJ_SEP_EQUAL_NO_SPACE, zdoms_rep, true); + sgj_haj_vi(jsp, jop, 0, "Zone_domains_returned_list_length=", + SGJ_SEP_EQUAL_NO_SPACE, zd_ret_len, true); + sgj_haj_vi(jsp, jop, 0, "Zone_domains_supported", + SGJ_SEP_EQUAL_NO_SPACE, zdoms_sup, true); + sgj_haj_vi(jsp, jop, 0, "Zone_domains_reported", + SGJ_SEP_EQUAL_NO_SPACE, zdoms_rep, true); sgj_pr_hr(jsp, "Reporting_options=0x%x\n", zd_rep_opts); sgj_js_nv_ihex(jsp, jop, "Reporting_options", zd_rep_opts); sgj_pr_hr(jsp, "Zone_domain_locator=0x%" PRIx64 "\n", zd_locator); @@ -676,8 +676,8 @@ decode_rep_zdomains(const uint8_t * rzBuff, int act_len, sgj_opaque_p jo2p; jo2p = sgj_new_unattached_object_r(jsp); - sgj_hr_js_vi(jsp, jo2p, 3, "zone_domain", - SGJ_SEP_EQUAL_NO_SPACE, bp[0], true); + sgj_haj_vi(jsp, jo2p, 3, "zone_domain", + SGJ_SEP_EQUAL_NO_SPACE, bp[0], true); lba = sg_get_unaligned_be64(bp + 16); sgj_pr_hr(jsp, " zone_count=%" PRIu64 "\n", lba); sgj_js_nv_ihex(jsp, jo2p, "zone_count", lba); @@ -689,10 +689,10 @@ decode_rep_zdomains(const uint8_t * rzBuff, int act_len, sgj_js_nv_ihex(jsp, jo2p, "ending_lba", lba); sgj_pr_hr(jsp, " zone_domain_zone_type=0x%x\n", bp[40]); sgj_js_nv_ihex(jsp, jo2p, "zone_domain_zone_type", bp[40]); - sgj_hr_js_vi(jsp, jo2p, 5, "VZDZT", SGJ_SEP_EQUAL_NO_SPACE, - !!(0x2 & bp[42]), false); - sgj_hr_js_vi(jsp, jo2p, 5, "SRB", SGJ_SEP_EQUAL_NO_SPACE, - !!(0x1 & bp[42]), false); + sgj_haj_vi(jsp, jo2p, 5, "VZDZT", SGJ_SEP_EQUAL_NO_SPACE, + !!(0x2 & bp[42]), false); + sgj_haj_vi(jsp, jo2p, 5, "SRB", SGJ_SEP_EQUAL_NO_SPACE, + !!(0x1 & bp[42]), false); sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); } return 0; @@ -844,7 +844,7 @@ gather_statistics(int sg_fd, uint8_t * rzBuff, const char * cmd_name, uint64_t mx_lba = 0; uint64_t zs_lba, zwp, z_blks; const uint8_t * bp = rzBuff; - struct statistics_t st = {0}; + struct statistics_t st SG_C_CPP_ZERO_INIT; char b[96]; if (op->serv_act != REPORT_ZONES_SA) { @@ -1151,7 +1151,7 @@ main(int argc, char * argv[]) sgj_state * jsp; sgj_opaque_p jop = NULL; char b[80]; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; struct opts_t * op = &opts; op->serv_act = REPORT_ZONES_SA; diff --git a/src/sg_requests.c b/src/sg_requests.c index 903c7ce8..2779cbd0 100644 --- a/src/sg_requests.c +++ b/src/sg_requests.c @@ -141,7 +141,7 @@ main(int argc, char * argv[]) char b[256]; uint8_t rs_cdb[REQUEST_SENSE_CMDLEN] = {REQUEST_SENSE_CMD, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; #ifndef SG_LIB_MINGW bool do_time = false; struct timeval start_tm, end_tm; diff --git a/src/sg_reset_wp.c b/src/sg_reset_wp.c index f3e76b3b..1580c843 100644 --- a/src/sg_reset_wp.c +++ b/src/sg_reset_wp.c @@ -88,7 +88,7 @@ sg_ll_reset_write_pointer(int sg_fd, uint64_t zid, uint16_t zc, bool all, int ret, res, sense_cat; uint8_t rwp_cdb[SG_ZONING_OUT_CMDLEN] = {SG_ZONING_OUT, RESET_WRITE_POINTER_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; sg_put_unaligned_be64(zid, rwp_cdb + 2); diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c index 74c33f2f..89108fed 100644 --- a/src/sg_sanitize.c +++ b/src/sg_sanitize.c @@ -173,7 +173,7 @@ do_sanitize(int sg_fd, const struct opts_t * op, const void * param_lstp, bool immed; int ret, res, sense_cat, timeout; uint8_t san_cdb[SANITIZE_OP_LEN]; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (op->early || op->wait) diff --git a/src/sg_sat_identify.c b/src/sg_sat_identify.c index ef9b3197..7a8d8251 100644 --- a/src/sg_sat_identify.c +++ b/src/sg_sat_identify.c @@ -136,15 +136,15 @@ do_identify_dev(int sg_fd, bool do_packet, int cdb_len, bool ck_cond, uint64_t ull; struct sg_scsi_sense_hdr ssh; uint8_t inBuff[ID_RESPONSE_LEN]; - uint8_t sense_buffer[64] = {0}; - uint8_t ata_return_desc[16] = {0}; + uint8_t sense_buffer[64] SG_C_CPP_ZERO_INIT; + uint8_t ata_return_desc[16] SG_C_CPP_ZERO_INIT; uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] = {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t apt12_cdb[SAT_ATA_PASS_THROUGH12_LEN] = {SAT_ATA_PASS_THROUGH12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t apt32_cdb[SAT_ATA_PASS_THROUGH32_LEN] = {0}; + uint8_t apt32_cdb[SAT_ATA_PASS_THROUGH32_LEN] SG_C_CPP_ZERO_INIT; const unsigned short * usp; sb_sz = sizeof(sense_buffer); diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c index 55230b84..b7e9d53d 100644 --- a/src/sg_sat_phy_event.c +++ b/src/sg_sat_phy_event.c @@ -177,8 +177,8 @@ do_read_log_ext(int sg_fd, int log_addr, int page_in_log, int feature, int resid = 0; int sb_sz; struct sg_scsi_sense_hdr ssh; - uint8_t sense_buffer[64] = {0}; - uint8_t ata_return_desc[16] = {0}; + uint8_t sense_buffer[64] SG_C_CPP_ZERO_INIT; + uint8_t ata_return_desc[16] SG_C_CPP_ZERO_INIT; uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] = {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; diff --git a/src/sg_sat_read_gplog.c b/src/sg_sat_read_gplog.c index 7006563d..a1afc828 100644 --- a/src/sg_sat_read_gplog.c +++ b/src/sg_sat_read_gplog.c @@ -139,8 +139,8 @@ do_read_gplog(int sg_fd, int ata_cmd, uint8_t *inbuff, int resid = 0; int sb_sz; struct sg_scsi_sense_hdr ssh; - uint8_t sense_buffer[64] = {0}; - uint8_t ata_return_desc[16] = {0}; + uint8_t sense_buffer[64] SG_C_CPP_ZERO_INIT; + uint8_t ata_return_desc[16] SG_C_CPP_ZERO_INIT; uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] = {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; diff --git a/src/sg_sat_set_features.c b/src/sg_sat_set_features.c index e914b23a..3a6712ab 100644 --- a/src/sg_sat_set_features.c +++ b/src/sg_sat_set_features.c @@ -125,8 +125,8 @@ do_set_features(int sg_fd, int feature, int count, uint64_t lba, int resid = 0; int sb_sz; struct sg_scsi_sense_hdr ssh; - uint8_t sense_buffer[64] = {0}; - uint8_t ata_return_desc[16] = {0}; + uint8_t sense_buffer[64] SG_C_CPP_ZERO_INIT; + uint8_t ata_return_desc[16] SG_C_CPP_ZERO_INIT; uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] = {SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; diff --git a/src/sg_scan_linux.c b/src/sg_scan_linux.c index b0bc52dd..0dddaa83 100644 --- a/src/sg_scan_linux.c +++ b/src/sg_scan_linux.c @@ -399,10 +399,9 @@ int sg3_inq(int sg_fd, uint8_t * inqBuff, bool do_extra) { bool ok; int err, sg_io; - uint8_t sense_buffer[32] = {0}; - struct sg_io_hdr io_hdr; + uint8_t sense_buffer[32] SG_C_CPP_ZERO_INIT; + struct sg_io_hdr io_hdr SG_C_CPP_ZERO_INIT; - memset(&io_hdr, 0, sizeof(struct sg_io_hdr)); memset(inqBuff, 0, INQ_REPLY_LEN); inqBuff[0] = 0x7f; io_hdr.interface_id = 'S'; diff --git a/src/sg_stream_ctl.c b/src/sg_stream_ctl.c index eede6e8f..6a07afc0 100644 --- a/src/sg_stream_ctl.c +++ b/src/sg_stream_ctl.c @@ -116,7 +116,7 @@ sg_ll_get_stream_status(int sg_fd, uint16_t s_str_id, uint8_t * resp, int k, ret, res, sense_cat; uint8_t gssCdb[16] = {SG_SERVICE_ACTION_IN_16, GET_STREAM_STATUS_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; static const char * const cmd_name = "Get stream status"; @@ -184,7 +184,7 @@ sg_ll_stream_control(int sg_fd, uint32_t str_ctl, uint16_t str_id, int k, ret, res, sense_cat; uint8_t scCdb[16] = {SG_SERVICE_ACTION_IN_16, STREAM_CONTROL_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; static const char * const cmd_name = "Stream control"; diff --git a/src/sg_sync.c b/src/sg_sync.c index a5d6ce8d..86d817d5 100644 --- a/src/sg_sync.c +++ b/src/sg_sync.c @@ -101,7 +101,7 @@ sg_ll_sync_cache_16(int sg_fd, bool sync_nv, bool immed, int group, uint8_t sc_cdb[SYNCHRONIZE_CACHE16_CMDLEN] = {SYNCHRONIZE_CACHE16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; if (sync_nv) diff --git a/src/sg_timestamp.c b/src/sg_timestamp.c index b9da385c..fdb68fdc 100644 --- a/src/sg_timestamp.c +++ b/src/sg_timestamp.c @@ -197,7 +197,7 @@ sg_ll_rep_timestamp(int sg_fd, void * resp, int mx_resp_len, int * residp, int k, ret, res, sense_cat; uint8_t rt_cdb[REP_TIMESTAMP_CMDLEN] = {SG_MAINTENANCE_IN, REP_TIMESTAMP_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; sg_put_unaligned_be32((uint32_t)mx_resp_len, rt_cdb + 6); @@ -260,7 +260,7 @@ sg_ll_set_timestamp(int sg_fd, void * paramp, int param_len, bool noisy, uint8_t st_cdb[SET_TIMESTAMP_CMDLEN] = {SG_MAINTENANCE_OUT, SET_TIMESTAMP_SA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; sg_put_unaligned_be32(param_len, st_cdb + 6); diff --git a/src/sg_turs.c b/src/sg_turs.c index e665fe44..02612ed1 100644 --- a/src/sg_turs.c +++ b/src/sg_turs.c @@ -386,7 +386,7 @@ loop_turs(struct sg_pt_base * ptvp, struct loop_res_t * resp, int packet_id = 0; int vb = op->verbose; char b[80]; - uint8_t sense_b[32] = {0}; + uint8_t sense_b[32] SG_C_CPP_ZERO_INIT; if (op->do_low) { int rs, n, sense_cat; diff --git a/src/sg_vpd.c b/src/sg_vpd.c index 50f2c8a7..0cb6f7ed 100644 --- a/src/sg_vpd.c +++ b/src/sg_vpd.c @@ -42,7 +42,7 @@ */ -static const char * version_str = "1.79 20220806"; /* spc6r06 + sbc5r03 */ +static const char * version_str = "1.80 20220811"; /* spc6r06 + sbc5r03 */ #define MY_NAME "sg_vpd" @@ -180,7 +180,7 @@ usage() " [--ident] [--inhex=FN] [--long] [--maxlen=LEN] " "[--page=PG]\n" " [--quiet] [--raw] [--sinq_inraw=RFN] " - "[--vendor=VP] [--verbose] " + "[--vendor=VP] [--verbose]\n" " [--version] DEVICE\n"); pr2serr(" where:\n" " --all|-a output all pages listed in the supported " @@ -233,83 +233,6 @@ usage() "INQUIRY response.\n"); } -/* mxlen is command line --maxlen=LEN option (def: 0) or -1 for a VPD page - * with a short length (1 byte). Returns 0 for success. */ -int /* global: use by sg_vpd_vendor.c */ -vpd_fetch_page(int sg_fd, uint8_t * rp, int page, int mxlen, bool qt, - int vb, int * rlenp) -{ - int res, resid, rlen, len, n; - - if (sg_fd < 0) { - len = sg_get_unaligned_be16(rp + 2) + 4; - if (vb && (len > mxlen)) - pr2serr("warning: VPD page's length (%d) > bytes in --inhex=FN " - "file (%d)\n", len , mxlen); - if (rlenp) - *rlenp = (len < mxlen) ? len : mxlen; - return 0; - } - if (mxlen > MX_ALLOC_LEN) { - pr2serr("--maxlen=LEN too long: %d > %d\n", mxlen, MX_ALLOC_LEN); - return SG_LIB_SYNTAX_ERROR; - } - n = (mxlen > 0) ? mxlen : DEF_ALLOC_LEN; - res = sg_ll_inquiry_v2(sg_fd, true, page, rp, n, DEF_PT_TIMEOUT, &resid, - ! qt, vb); - if (res) - return res; - rlen = n - resid; - if (rlen < 4) { - pr2serr("VPD response too short (len=%d)\n", rlen); - return SG_LIB_CAT_MALFORMED; - } - if (page != rp[1]) { - pr2serr("invalid VPD response; probably a STANDARD INQUIRY " - "response\n"); - n = (rlen < 32) ? rlen : 32; - if (vb) { - pr2serr("First %d bytes of bad response\n", n); - hex2stderr(rp, n, 0); - } - return SG_LIB_CAT_MALFORMED; - } else if ((0x80 == page) && (0x2 == rp[2]) && (0x2 == rp[3])) { - /* could be a Unit Serial number VPD page with a very long - * length of 4+514 bytes; more likely standard response for - * SCSI-2, RMB=1 and a response_data_format of 0x2. */ - pr2serr("invalid Unit Serial Number VPD response; probably a " - "STANDARD INQUIRY response\n"); - return SG_LIB_CAT_MALFORMED; - } - if (mxlen < 0) - len = rp[3] + 4; - else - len = sg_get_unaligned_be16(rp + 2) + 4; - if (len <= rlen) { - if (rlenp) - *rlenp = len; - return 0; - } else if (mxlen) { - if (rlenp) - *rlenp = rlen; - return 0; - } - if (len > MX_ALLOC_LEN) { - pr2serr("response length too long: %d > %d\n", len, MX_ALLOC_LEN); - return SG_LIB_CAT_MALFORMED; - } else { - res = sg_ll_inquiry_v2(sg_fd, true, page, rp, len, DEF_PT_TIMEOUT, - &resid, ! qt, vb); - if (res) - return res; - rlen = len - resid; - /* assume it is well behaved: hence page and len still same */ - if (rlenp) - *rlenp = rlen; - return 0; - } -} - static const struct svpd_values_name_t * sdp_get_vpd_detail(int page_num, int subvalue, int pdt) { @@ -521,10 +444,79 @@ device_id_vpd_variants(uint8_t * buff, int len, int subvalue, } } +static void /* VPD_SUPPORTED_VPDS ["sv"] */ +decode_supported_vpd_4vpd(uint8_t * buff, int len, struct opts_t * op, + sgj_opaque_p jap) +{ + uint8_t pn; + int k, rlen, pdt; + sgj_state * jsp = &op->json_st; + sgj_opaque_p jo2p; + const struct svpd_values_name_t * vnp; + uint8_t * bp; + char b[144]; + static const int blen = sizeof(b); + static const char * svps = "Supported VPD pages"; + + if ((1 == op->do_hex) || (op->do_hex > 2)) { + hex2stdout(buff, len, (1 == op->do_hex) ? 0 : -1); + return; + } + pdt = PDT_MASK & buff[0]; + rlen = buff[3] + 4; + if (rlen > len) + pr2serr("%s VPD page truncated, indicates %d, got %d\n", svps, rlen, + len); + else + len = rlen; + if (len < 4) { + pr2serr("%s VPD page length too short=%d\n", svps, len); + return; + } + len -= 4; + bp = buff + 4; + + for (k = 0; k < len; ++k) { + pn = bp[k]; + snprintf(b, blen, "0x%02x", pn); + vnp = sdp_get_vpd_detail(pn, -1, pdt); + if (vnp) { + if (op->do_long) + sgj_pr_hr(jsp, " %s %s [%s]\n", b, vnp->name, vnp->acron); + else + sgj_pr_hr(jsp, " %s [%s]\n", vnp->name, vnp->acron); + } else if (op->vend_prod_num >= 0) { + vnp = svpd_find_vendor_by_num(pn, op->vend_prod_num); + if (vnp) { + if (op->do_long) + sgj_pr_hr(jsp, " %s %s [%s]\n", b, vnp->name, + vnp->acron); + else + sgj_pr_hr(jsp, " %s [%s]\n", vnp->name, vnp->acron); + } else + sgj_pr_hr(jsp, " %s\n", b); + } else + sgj_pr_hr(jsp, " %s\n", b); + if (jsp->pr_as_json) { + jo2p = sgj_new_unattached_object_r(jsp); + sgj_js_nv_i(jsp, jo2p, "i", pn); + sgj_js_nv_s(jsp, jo2p, "hex", b + 2); + if (vnp) { + sgj_js_nv_s(jsp, jo2p, "name", vnp->name); + sgj_js_nv_s(jsp, jo2p, "acronym", vnp->acron); + } else { + sgj_js_nv_s(jsp, jo2p, "name", "unknown"); + sgj_js_nv_s(jsp, jo2p, "acronym", "unknown"); + } + sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); + } + } +} + /* VPD_SCSI_PORTS 0x88 ["sp"] */ static void -decode_scsi_ports_vpd(uint8_t * buff, int len, struct opts_t * op, - sgj_opaque_p jap) +decode_scsi_ports_vpd_4vpd(uint8_t * buff, int len, struct opts_t * op, + sgj_opaque_p jap) { int k, bump, rel_port, ip_tid_len, tpd_len; sgj_state * jsp = &op->json_st; @@ -878,134 +870,26 @@ filter_dev_ids(const char * print_if_found, int num_leading, uint8_t * buff, /* VPD_SA_DEV_CAP ssc */ /* VPD_OSD_INFO osd */ static void -decode_b0_vpd(uint8_t * buff, int len, int do_hex, int pdt) +decode_b0_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_opaque_p jop) { - unsigned int u; - uint64_t ull; - bool ugavalid; + int pdt = PDT_MASK & buff[0]; + sgj_state * jsp = &op->json_st; - if (do_hex) { - hex2stdout(buff, len, (1 == do_hex) ? 0 : -1); + if (op->do_hex) { + hex2stdout(buff, len, (1 == op->do_hex) ? 0 : -1); return; } switch (pdt) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_ZBC: - if (len < 16) { - pr2serr("Block limits VPD page length too short=%d\n", len); - return; - } - printf(" Write same non-zero (WSNZ): %d\n", !!(buff[4] & 0x1)); - u = buff[5]; - printf(" Maximum compare and write length: "); - if (0 == u) - printf("0 blocks [Command not implemented]\n"); - else - printf("%u blocks\n", buff[5]); - u = sg_get_unaligned_be16(buff + 6); - printf(" Optimal transfer length granularity: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - u = sg_get_unaligned_be32(buff + 8); - printf(" Maximum transfer length: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - u = sg_get_unaligned_be32(buff + 12); - printf(" Optimal transfer length: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - if (len > 19) { /* added in sbc3r09 */ - u = sg_get_unaligned_be32(buff + 16); - printf(" Maximum prefetch transfer length: "); - if (0 == u) - printf("0 blocks [ignored]\n"); - else - printf("%u blocks\n", u); - } - if (len > 27) { /* added in sbc3r18 */ - u = sg_get_unaligned_be32(buff + 20); - printf(" Maximum unmap LBA count: "); - if (0 == u) - printf("0 [Unmap command not implemented]\n"); - else if (SG_LIB_UNBOUNDED_32BIT == u) - printf("-1 [unbounded]\n"); - else - printf("%u\n", u); - u = sg_get_unaligned_be32(buff + 24); - printf(" Maximum unmap block descriptor count: "); - if (0 == u) - printf("0 [Unmap command not implemented]\n"); - else if (SG_LIB_UNBOUNDED_32BIT == u) - printf("-1 [unbounded]\n"); - else - printf("%u\n", u); - } - if (len > 35) { /* added in sbc3r19 */ - u = sg_get_unaligned_be32(buff + 28); - printf(" Optimal unmap granularity: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - - ugavalid = !!(buff[32] & 0x80); - printf(" Unmap granularity alignment valid: %s\n", - ugavalid ? "true" : "false"); - u = 0x7fffffff & sg_get_unaligned_be32(buff + 32); - printf(" Unmap granularity alignment: %u%s\n", u, - ugavalid ? "" : " [invalid]"); - } - if (len > 43) { /* added in sbc3r26 */ - ull = sg_get_unaligned_be64(buff + 36); - printf(" Maximum write same length: "); - if (0 == ull) - printf("0 blocks [not reported]\n"); - else - printf("0x%" PRIx64 " blocks\n", ull); - } - if (len > 44) { /* added in sbc4r02 */ - u = sg_get_unaligned_be32(buff + 44); - printf(" Maximum atomic transfer length: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - u = sg_get_unaligned_be32(buff + 48); - printf(" Atomic alignment: "); - if (0 == u) - printf("0 [unaligned atomic writes permitted]\n"); - else - printf("%u\n", u); - u = sg_get_unaligned_be32(buff + 52); - printf(" Atomic transfer length granularity: "); - if (0 == u) - printf("0 [no granularity requirement\n"); - else - printf("%u\n", u); - } - if (len > 56) { - u = sg_get_unaligned_be32(buff + 56); - printf(" Maximum atomic transfer length with atomic " - "boundary: "); - if (0 == u) - printf("0 blocks [not reported]\n"); - else - printf("%u blocks\n", u); - u = sg_get_unaligned_be32(buff + 60); - printf(" Maximum atomic boundary size: "); - if (0 == u) - printf("0 blocks [can only write atomic 1 block]\n"); - else - printf("%u blocks\n", u); - } + /* now done by decode_block_limits_vpd() in sg_vpd_common.c */ break; case PDT_TAPE: case PDT_MCHANGER: - printf(" WORM=%d\n", !!(buff[4] & 0x1)); + sgj_haj_vi_nex(jsp, jop, 2, "TSMC", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[4] & 0x2), false, "Tape Stream Mirror " + "Capable"); + sgj_haj_vi_nex(jsp, jop, 2, "WORM", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[4] & 0x1), false, "Write Once Read Multple " + "supported"); break; case PDT_OSD: default: @@ -1040,72 +924,6 @@ decode_b1_vpd(uint8_t * buff, int len, int do_hex, int pdt) } } -#if 0 -/* VPD_BLOCK_DEV_C_EXTENS 0xb5 (added sbc4r02) */ -static void -decode_block_dev_char_ext_vpd(uint8_t * b, int len) -{ - if (len < 16) { - pr2serr("Block device characteristics extension VPD page " - "length too short=%d\n", len); - return; - } - printf(" Utilization type: "); - switch (b[5]) { - case 1: - printf("Combined writes and reads"); - break; - case 2: - printf("Writes only"); - break; - case 3: - printf("Separate writes and reads"); - break; - default: - printf("Reserved"); - break; - } - printf(" [0x%x]\n", b[5]); - printf(" Utilization units: "); - switch (b[6]) { - case 2: - printf("megabytes"); - break; - case 3: - printf("gigabytes"); - break; - case 4: - printf("terabytes"); - break; - case 5: - printf("petabytes"); - break; - case 6: - printf("exabytes"); - break; - default: - printf("Reserved"); - break; - } - printf(" [0x%x]\n", b[6]); - printf(" Utilization interval: "); - switch (b[7]) { - case 0xa: - printf("per day"); - break; - case 0xe: - printf("per year"); - break; - default: - printf("Reserved"); - break; - } - printf(" [0x%x]\n", b[7]); - printf(" Utilization B: %u\n", sg_get_unaligned_be32(b + 8)); - printf(" Utilization A: %u\n", sg_get_unaligned_be32(b + 12)); -} -#endif - /* VPD_LB_PROTECTION 0xb5 (SSC) [added in ssc5r02a] */ static void decode_lb_protection_vpd(uint8_t * buff, int len, int do_hex) @@ -1265,77 +1083,6 @@ decode_b5_vpd(uint8_t * b, int len, int do_hex, int pdt) } } -#if 0 -/* VPD_FORMAT_PRESETS 0xb8 (added sbc4r18) */ -static void -decode_format_presets_vpd(uint8_t * buff, int len, int do_hex) -{ - int k; - unsigned int sch_type; - uint8_t * bp; - - if (do_hex) { - hex2stdout(buff, len, (1 == do_hex) ? 0 : -1); - return; - } - if (len < 4) { - pr2serr("Format presets VPD page length too short=%d\n", len); - return; - } - len -= 4; - bp = buff + 4; - for (k = 0; k < len; k += 64, bp += 64) { - printf(" Preset identifier: 0x%x\n", sg_get_unaligned_be32(bp)); - sch_type = bp[4]; - printf(" schema type: %u\n", sch_type); - printf(" logical blocks per physical block exponent type: %u\n", - 0xf & bp[7]); - printf(" logical block length: %u\n", - sg_get_unaligned_be32(bp + 8)); - printf(" designed last LBA: 0x%" PRIx64 "\n", - sg_get_unaligned_be64(bp + 16)); - printf(" FMPT_INFO: %u\n", (bp[38] >> 6) & 0x3); - printf(" protection field usage: %u\n", bp[38] & 0x7); - printf(" protection interval exponent: %u\n", bp[39] & 0xf); - if (2 == sch_type) - printf(" Defines zones for host aware device:\n"); - else if (3 == sch_type) - printf(" Defines zones for host managed device:\n"); - else if (4 == sch_type) - printf(" Defines zones for zone domains and realms device:\n"); - if ((2 == sch_type) || (3 == sch_type)) { - unsigned int u = bp[40 + 0]; - - printf(" low LBA conventional zones percentage: " - "%u.%u %%\n", u / 10, u % 10); - u = bp[40 + 1]; - printf(" high LBA conventional zones percentage: " - "%u.%u %%\n", u / 10, u % 10); - printf(" logical blocks per zone: %u\n", - sg_get_unaligned_be32(bp + 40 + 12)); - } else if (4 == sch_type) { - uint8_t u; - char b[128]; - - u = bp[40 + 0]; - printf(" zone type for zone domain 0: %s\n", - sg_get_zone_type_str((u >> 4) & 0xf, sizeof(b), b)); - printf(" zone type for zone domain 1: %s\n", - sg_get_zone_type_str(u & 0xf, sizeof(b), b)); - u = bp[40 + 1]; - printf(" zone type for zone domain 2: %s\n", - sg_get_zone_type_str((u >> 4) & 0xf, sizeof(b), b)); - printf(" zone type for zone domain 3: %s\n", - sg_get_zone_type_str(u & 0xf, sizeof(b), b)); - printf(" logical blocks per zone: %u\n", - sg_get_unaligned_be32(bp + 40 + 12)); - printf(" designed zone maximum address: 0x%" PRIx64 "\n", - sg_get_unaligned_be64(bp + 40 + 16)); - } - } -} -#endif - /* Returns 0 if successful */ static int svpd_unable_to_decode(int sg_fd, struct opts_t * op, int subvalue, int off) @@ -1404,7 +1151,6 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, bool inhex_active = (-1 == sg_fd); int len, pdt, pqual, num, k, resid, alloc_len, pn, vb; int res = 0; - const struct svpd_values_name_t * vnp; sgj_state * jsp = &op->json_st; uint8_t * rp; sgj_opaque_p jap = NULL; @@ -1416,9 +1162,7 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, bool as_json = jsp->pr_as_json; bool not_json = ! as_json; char obuff[DEF_ALLOC_LEN]; - char b[120]; char d[48]; - static const int blen = sizeof(b); vb = op->verbose; qt = op->do_quiet; @@ -1520,44 +1264,7 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, jap = sgj_named_subarray_r(jsp, jo2p, "supported_vpd_page_list"); } - for (k = 0; k < num; ++k) { - pn = rp[4 + k]; - snprintf(b, blen, "0x%02x", pn); - vnp = sdp_get_vpd_detail(pn, -1, pdt); - if (vnp) { - if (op->do_long) - sgj_pr_hr(jsp, " %s %s [%s]\n", b, - vnp->name, vnp->acron); - else - sgj_pr_hr(jsp, " %s [%s]\n", vnp->name, - vnp->acron); - } else if (op->vend_prod_num >= 0) { - vnp = svpd_find_vendor_by_num(pn, op->vend_prod_num); - if (vnp) { - if (op->do_long) - sgj_pr_hr(jsp, " %s %s [%s]\n", b, - vnp->name, vnp->acron); - else - sgj_pr_hr(jsp, " %s [%s]\n", vnp->name, - vnp->acron); - } else - sgj_pr_hr(jsp, " %s\n", b); - } else - sgj_pr_hr(jsp, " %s\n", b); - if (as_json) { - jo2p = sgj_new_unattached_object_r(jsp); - sgj_js_nv_i(jsp, jo2p, "i", pn); - sgj_js_nv_s(jsp, jo2p, "hex", b + 2); - if (vnp) { - sgj_js_nv_s(jsp, jo2p, "name", vnp->name); - sgj_js_nv_s(jsp, jo2p, "acronym", vnp->acron); - } else { - sgj_js_nv_s(jsp, jo2p, "name", "unknown"); - sgj_js_nv_s(jsp, jo2p, "acronym", "unknown"); - } - sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); - } - } + decode_supported_vpd_4vpd(rp, len, op, jap); } return 0; } @@ -1584,7 +1291,7 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, len = sizeof(obuff) - 1; memcpy(obuff, rp + 4, len); jo2p = sg_vpd_js_hdr(jsp, jop, np, rp); - sgj_hr_js_vs(jsp, jo2p, 2, np, SGJ_SEP_COLON_1_SPACE, obuff); + sgj_haj_vs(jsp, jo2p, 2, np, SGJ_SEP_COLON_1_SPACE, obuff); } return 0; } @@ -1736,7 +1443,7 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, jap = sgj_named_subarray_r(jsp, jo2p, "scsi_ports_descriptor_list"); } - decode_scsi_ports_vpd(rp, len, op, jap); + decode_scsi_ports_vpd_4vpd(rp, len, op, jap); } return 0; } @@ -1978,9 +1685,9 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop, if (bl) decode_block_limits_vpd(rp, len, op, jo2p); else if (sad) { - decode_b0_vpd(rp, len, op->do_hex, pdt); + decode_b0_vpd(rp, len, op, jop); } else if (oi) { - decode_b0_vpd(rp, len, op->do_hex, pdt); + decode_b0_vpd(rp, len, op, jop); } else { } @@ -2549,7 +2256,7 @@ main(int argc, char * argv[]) sgj_state * jsp; sgj_opaque_p jop = NULL; const struct svpd_values_name_t * vnp; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; struct opts_t * op = &opts; op->invoker = SG_VPD_INV_SG_VPD; @@ -2822,6 +2529,9 @@ main(int argc, char * argv[]) subvalue = op->vend_prod_num; } } + if (op->verbose > 3) + pr2serr("'--page=' matched pn=%d [0x%x], subvalue=%d\n", + op->vpd_pn, op->vpd_pn, subvalue); } else if (op->vend_prod) { if (isdigit((uint8_t)op->vend_prod[0])) op->vend_prod_num = sg_get_num_nomult(op->vend_prod); diff --git a/src/sg_vpd_common.c b/src/sg_vpd_common.c index 5cc33f68..98e798fb 100644 --- a/src/sg_vpd_common.c +++ b/src/sg_vpd_common.c @@ -54,6 +54,206 @@ static const char * const vs_s = "Vendor specific"; static const char * const null_s = ""; static const char * const mn_s = "meaning"; +/* Supported vendor specific VPD pages */ +/* Arrange in alphabetical order by acronym */ +struct svpd_vp_name_t vp_arr[] = { + {VPD_VP_DDS, "dds", "DDS tape family from IBM"}, + {VPD_VP_EMC, "emc", "EMC (company)"}, + {VPD_VP_WDC_HITACHI, "hit", "WDC/Hitachi disk"}, + {VPD_VP_HP3PAR, "hp3par", "3PAR array (HP was Left Hand)"}, + {VPD_VP_HP_LTO, "hp_lto", "HP LTO tape/systems"}, + {VPD_VP_IBM_LTO, "ibm_lto", "IBM LTO tape/systems"}, + {VPD_VP_NVME, "nvme", "NVMe related"}, + {VPD_VP_RDAC, "rdac", "RDAC array (NetApp E-Series)"}, + {VPD_VP_SEAGATE, "sea", "Seagate disk"}, + {VPD_VP_SG, "sg", "sg3_utils extensions"}, + {VPD_VP_WDC_HITACHI, "wdc", "WDC/Hitachi disk"}, + {0, NULL, NULL}, +}; + +/* Supported vendor specific VPD pages */ +/* 'subvalue' holds vendor/product number to disambiguate */ +/* Arrange in alphabetical order by acronym */ +struct svpd_values_name_t vendor_vpd_pg[] = { + {VPD_V_ACI_LTO, VPD_VP_HP_LTO, 1, "aci", "ACI revision level (HP LTO)"}, + {VPD_V_DATC_SEA, VPD_VP_SEAGATE, 0, "datc", "Date code (Seagate)"}, + {VPD_V_DCRL_LTO, VPD_VP_IBM_LTO, 1, "dcrl", "Drive component revision " + "levels (IBM LTO)"}, + {VPD_V_FVER_DDS, VPD_VP_DDS, 1, "ddsver", "Firmware revision (DDS)"}, + {VPD_V_DEV_BEH_SEA, VPD_VP_SEAGATE, 0, "devb", "Device behavior " + "(Seagate)"}, + {VPD_V_DSN_LTO, VPD_VP_IBM_LTO, 1, "dsn", "Drive serial numbers (IBM " + "LTO)"}, + {VPD_V_DUCD_LTO, VPD_VP_IBM_LTO, 1, "ducd", "Device unique " + "configuration data (IBM LTO)"}, + {VPD_V_EDID_RDAC, VPD_VP_RDAC, 0, "edid", "Extended device " + "identification (RDAC)"}, + {VPD_V_FIRM_SEA, VPD_VP_SEAGATE, 0, "firm", "Firmware numbers " + "(Seagate)"}, + {VPD_V_FVER_LTO, VPD_VP_HP_LTO, 0, "frl", "Firmware revision level " + "(HP LTO)"}, + {VPD_V_FVER_RDAC, VPD_VP_RDAC, 0, "fwr4", "Firmware version (RDAC)"}, + {VPD_V_HEAD_LTO, VPD_VP_HP_LTO, 1, "head", "Head Assy revision level " + "(HP LTO)"}, + {VPD_V_HP3PAR, VPD_VP_HP3PAR, 0, "hp3par", "Volume information " + "(HP/3PAR)"}, + {VPD_V_HVER_LTO, VPD_VP_HP_LTO, 1, "hrl", "Hardware revision level " + "(HP LTO)"}, + {VPD_V_HVER_RDAC, VPD_VP_RDAC, 0, "hwr4", "Hardware version (RDAC)"}, + {VPD_V_JUMP_SEA, VPD_VP_SEAGATE, 0, "jump", "Jump setting (Seagate)"}, + {VPD_V_MECH_LTO, VPD_VP_HP_LTO, 1, "mech", "Mechanism revision level " + "(HP LTO)"}, + {VPD_V_MPDS_LTO, VPD_VP_IBM_LTO, 1, "mpds", "Mode parameter default " + "settings (IBM LTO)"}, + {SG_NVME_VPD_NICR, VPD_VP_SG, 0, "nicr", + "NVMe Identify Controller Response (sg3_utils)"}, + {VPD_V_PCA_LTO, VPD_VP_HP_LTO, 1, "pca", "PCA revision level (HP LTO)"}, + {VPD_V_FEAT_RDAC, VPD_VP_RDAC, 0, "prm4", "Feature Parameters (RDAC)"}, + {VPD_V_RVSI_RDAC, VPD_VP_RDAC, 0, "rvsi", "Replicated volume source " + "identifier (RDAC)"}, + {VPD_V_SAID_RDAC, VPD_VP_RDAC, 0, "said", "Storage array world wide " + "name (RDAC)"}, + {VPD_V_SUBS_RDAC, VPD_VP_RDAC, 0, "subs", "Subsystem identifier (RDAC)"}, + {VPD_V_SVER_RDAC, VPD_VP_RDAC, 0, "swr4", "Software version (RDAC)"}, + {VPD_V_UPR_EMC, VPD_VP_EMC, 0, "upr", "Unit path report (EMC)"}, + {VPD_V_VAC_RDAC, VPD_VP_RDAC, 0, "vac1", "Volume access control (RDAC)"}, + {VPD_V_HIT_PG3, VPD_VP_WDC_HITACHI, 0, "wp3", "Page 0x3 (WDC/Hitachi)"}, + {VPD_V_HIT_PG_D1, VPD_VP_WDC_HITACHI, 0, "wpd1", + "Page 0xd1 (WDC/Hitachi)"}, + {VPD_V_HIT_PG_D2, VPD_VP_WDC_HITACHI, 0, "wpd2", + "Page 0xd2 (WDC/Hitachi)"}, + {0, 0, 0, NULL, NULL}, +}; + + +int +svpd_find_vp_num_by_acron(const char * vp_ap) +{ + size_t len; + const struct svpd_vp_name_t * vpp; + + for (vpp = vp_arr; vpp->acron; ++vpp) { + len = strlen(vpp->acron); + if (0 == strncmp(vpp->acron, vp_ap, len)) + return vpp->vend_prod_num; + } + return -1; +} + +/* if vend_prod_num < -1 then list vendor_product ids + vendor pages, =-1 + * list only vendor_product ids, else list pages for that vend_prod_num */ +void +svpd_enumerate_vendor(int vend_prod_num) +{ + bool seen; + const struct svpd_vp_name_t * vpp; + const struct svpd_values_name_t * vnp; + + if (vend_prod_num < 0) { + for (seen = false, vpp = vp_arr; vpp->acron; ++vpp) { + if (vpp->name) { + if (! seen) { + printf("\nVendor/product identifiers:\n"); + seen = true; + } + printf(" %-10s %d %s\n", vpp->acron, + vpp->vend_prod_num, vpp->name); + } + } + } + if (-1 == vend_prod_num) + return; + for (seen = false, vnp = vendor_vpd_pg; vnp->acron; ++vnp) { + if ((vend_prod_num >= 0) && (vend_prod_num != vnp->subvalue)) + continue; + if (vnp->name) { + if (! seen) { + printf("\nVendor specific VPD pages:\n"); + seen = true; + } + printf(" %-10s 0x%02x,%d %s\n", vnp->acron, + vnp->value, vnp->subvalue, vnp->name); + } + } +} + +/* mxlen is command line --maxlen=LEN option (def: 0) or -1 for a VPD page + * with a short length (1 byte). Returns 0 for success. */ +int /* global: use by sg_vpd_vendor.c */ +vpd_fetch_page(int sg_fd, uint8_t * rp, int page, int mxlen, bool qt, + int vb, int * rlenp) +{ + int res, resid, rlen, len, n; + + if (sg_fd < 0) { + len = sg_get_unaligned_be16(rp + 2) + 4; + if (vb && (len > mxlen)) + pr2serr("warning: VPD page's length (%d) > bytes in --inhex=FN " + "file (%d)\n", len , mxlen); + if (rlenp) + *rlenp = (len < mxlen) ? len : mxlen; + return 0; + } + if (mxlen > MX_ALLOC_LEN) { + pr2serr("--maxlen=LEN too long: %d > %d\n", mxlen, MX_ALLOC_LEN); + return SG_LIB_SYNTAX_ERROR; + } + n = (mxlen > 0) ? mxlen : DEF_ALLOC_LEN; + res = sg_ll_inquiry_v2(sg_fd, true, page, rp, n, DEF_PT_TIMEOUT, &resid, + ! qt, vb); + if (res) + return res; + rlen = n - resid; + if (rlen < 4) { + pr2serr("VPD response too short (len=%d)\n", rlen); + return SG_LIB_CAT_MALFORMED; + } + if (page != rp[1]) { + pr2serr("invalid VPD response; probably a STANDARD INQUIRY " + "response\n"); + n = (rlen < 32) ? rlen : 32; + if (vb) { + pr2serr("First %d bytes of bad response\n", n); + hex2stderr(rp, n, 0); + } + return SG_LIB_CAT_MALFORMED; + } else if ((0x80 == page) && (0x2 == rp[2]) && (0x2 == rp[3])) { + /* could be a Unit Serial number VPD page with a very long + * length of 4+514 bytes; more likely standard response for + * SCSI-2, RMB=1 and a response_data_format of 0x2. */ + pr2serr("invalid Unit Serial Number VPD response; probably a " + "STANDARD INQUIRY response\n"); + return SG_LIB_CAT_MALFORMED; + } + if (mxlen < 0) + len = rp[3] + 4; + else + len = sg_get_unaligned_be16(rp + 2) + 4; + if (len <= rlen) { + if (rlenp) + *rlenp = len; + return 0; + } else if (mxlen) { + if (rlenp) + *rlenp = rlen; + return 0; + } + if (len > MX_ALLOC_LEN) { + pr2serr("response length too long: %d > %d\n", len, MX_ALLOC_LEN); + return SG_LIB_CAT_MALFORMED; + } else { + res = sg_ll_inquiry_v2(sg_fd, true, page, rp, len, DEF_PT_TIMEOUT, + &resid, ! qt, vb); + if (res) + return res; + rlen = len - resid; + /* assume it is well behaved: hence page and len still same */ + if (rlenp) + *rlenp = rlen; + return 0; + } +} + sgj_opaque_p sg_vpd_js_hdr(sgj_state * jsp, sgj_opaque_p jop, const char * name, const uint8_t * vpd_hdrp) @@ -240,48 +440,46 @@ decode_x_inq_vpd(uint8_t * b, int len, bool protect, struct opts_t * op, sgj_pr_hr(jsp, " SPT=%d%s\n", n, d); sgj_js_nv_ihexstr_nex(jsp, jop, "spt", n, false, NULL, cp, "Supported Protection Type"); - sgj_hr_js_vi_nex(jsp, jop, 2, "GRD_CHK", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[4] & 0x4), false, "guard check"); - sgj_hr_js_vi_nex(jsp, jop, 2, "APP_CHK", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[4] & 0x2), false, "application tag check"); - sgj_hr_js_vi_nex(jsp, jop, 2, "REF_CHK", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[4] & 0x1), false, "reference tag check"); - sgj_hr_js_vi_nex(jsp, jop, 2, "UASK_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x20), false, "Unit Attention " - "condition Sense Key specific data Supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "GROUP_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x10), false, "grouping function " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "PRIOR_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x8), false, "priority supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "HEADSUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x4), false, "head of queue supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "ORDSUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x2), false, "ordered (task attribute) " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "SIMPSUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[5] & 0x1), false, "simple (task attribute) " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "WU_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[6] & 0x8), false, "Write uncorrectable " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "CRD_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[6] & 0x4), false, "Correction disable " - "supported (obsolete SPC-5)"); - sgj_hr_js_vi_nex(jsp, jop, 2, "NV_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[6] & 0x2), false, "Nonvolatile cache " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "V_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[6] & 0x1), false, "Volatile cache supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "NO_PI_CHK", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[7] & 0x20), false, "No protection " - "information checking"); /* spc5r02 */ - sgj_hr_js_vi_nex(jsp, jop, 2, "P_I_I_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[7] & 0x10), false, "Protection information " - "interval supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "LUICLR", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[7] & 0x1), false, "Logical unit I_T nexus " - "clear"); + sgj_haj_vi_nex(jsp, jop, 2, "GRD_CHK", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[4] & 0x4), false, "guard check"); + sgj_haj_vi_nex(jsp, jop, 2, "APP_CHK", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[4] & 0x2), false, "application tag check"); + sgj_haj_vi_nex(jsp, jop, 2, "REF_CHK", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[4] & 0x1), false, "reference tag check"); + sgj_haj_vi_nex(jsp, jop, 2, "UASK_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x20), false, "Unit Attention " + "condition Sense Key specific data Supported"); + sgj_haj_vi_nex(jsp, jop, 2, "GROUP_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x10), false, "grouping function supported"); + sgj_haj_vi_nex(jsp, jop, 2, "PRIOR_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x8), false, "priority supported"); + sgj_haj_vi_nex(jsp, jop, 2, "HEADSUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x4), false, "head of queue supported"); + sgj_haj_vi_nex(jsp, jop, 2, "ORDSUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x2), false, "ordered (task attribute) " + "supported"); + sgj_haj_vi_nex(jsp, jop, 2, "SIMPSUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[5] & 0x1), false, "simple (task attribute) " + "supported"); + sgj_haj_vi_nex(jsp, jop, 2, "WU_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[6] & 0x8), false, "Write uncorrectable " + "supported"); + sgj_haj_vi_nex(jsp, jop, 2, "CRD_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[6] & 0x4), false, "Correction disable " + "supported (obsolete SPC-5)"); + sgj_haj_vi_nex(jsp, jop, 2, "NV_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[6] & 0x2), false, "Nonvolatile cache " + "supported"); + sgj_haj_vi_nex(jsp, jop, 2, "V_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[6] & 0x1), false, "Volatile cache supported"); + sgj_haj_vi_nex(jsp, jop, 2, "NO_PI_CHK", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[7] & 0x20), false, "No protection " + "information checking"); /* spc5r02 */ + sgj_haj_vi_nex(jsp, jop, 2, "P_I_I_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[7] & 0x10), false, "Protection information " + "interval supported"); + sgj_haj_vi_nex(jsp, jop, 2, "LUICLR", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[7] & 0x1), false, "Logical unit I_T nexus clear"); np = "LU_COLL_TYPE"; n = (b[8] >> 5) & 0x7; nex_p = "Logical unit collection type"; @@ -300,87 +498,86 @@ decode_x_inq_vpd(uint8_t * b, int len, bool protect, struct opts_t * op, cp = rsv_s; break; } - jo2p = sgj_hr_js_subo_r(jsp, jop, 2, np, SGJ_SEP_EQUAL_NO_SPACE, - n, false); + jo2p = sgj_haj_subo_r(jsp, jop, 2, np, SGJ_SEP_EQUAL_NO_SPACE, + n, false); sgj_js_nv_s(jsp, jo2p, mn_s, cp); if (jsp->pr_name_ex) sgj_js_nv_s(jsp, jo2p, "abbreviated_name_expansion", nex_p); } else - sgj_hr_js_vi_nex(jsp, jop, 2, np, SGJ_SEP_EQUAL_NO_SPACE, n, - true, nex_p); - - sgj_hr_js_vi_nex(jsp, jop, 2, "R_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[8] & 0x10), false, "Referrals supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "RTD_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[8] & 0x8), false, - "Revert to defaults supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "HSSRELEF", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[8] & 0x2), false, - "History snapshots release effects"); - sgj_hr_js_vi_nex(jsp, jop, 2, "CBCS", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[8] & 0x1), false, "Capability-based command " - "security (obsolete SPC-5)"); - sgj_hr_js_vi(jsp, jop, 2, "Multi I_T nexus microcode download", - SGJ_SEP_EQUAL_NO_SPACE, b[9] & 0xf, true); - sgj_hr_js_vi(jsp, jop, 2, "Extended self-test completion minutes", - SGJ_SEP_EQUAL_NO_SPACE, - sg_get_unaligned_be16(b + 10), true); - sgj_hr_js_vi_nex(jsp, jop, 2, "POA_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[12] & 0x80), false, - "Power on activation supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "HRA_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[12] & 0x40), false, - "Hard reset activation supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "VSA_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[12] & 0x20), false, - "Vendor specific activation supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DMS_VALID", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[12] & 0x10), false, - "Download microcode support byte valid"); - sgj_hr_js_vi(jsp, jop, 2, "Maximum supported sense data length", - SGJ_SEP_EQUAL_NO_SPACE, b[13], true); - sgj_hr_js_vi_nex(jsp, jop, 2, "IBS", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[14] & 0x80), false, - "Implicit bind supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "IAS", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[14] & 0x40), false, - "Implicit affiliation supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "SAC", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[14] & 0x4), false, - "Set affiliation command supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "NRD1", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[14] & 0x2), false, - "No redirect one supported (BIND)"); - sgj_hr_js_vi_nex(jsp, jop, 2, "NRD0", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[14] & 0x1), false, - "No redirect zero supported (BIND)"); - sgj_hr_js_vi(jsp, jop, 2, "Maximum inquiry change logs", - SGJ_SEP_EQUAL_NO_SPACE, - sg_get_unaligned_be16(b + 15), true); - sgj_hr_js_vi(jsp, jop, 2, "Maximum mode page change logs", - SGJ_SEP_EQUAL_NO_SPACE, - sg_get_unaligned_be16(b + 17), true); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_4", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x80), false, - "Download microcode mode 4 supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_5", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x40), false, - "Download microcode mode 5 supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_6", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x20), false, - "Download microcode mode 6 supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_7", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x10), false, - "Download microcode mode 7 supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_D", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x8), false, - "Download microcode mode 0xd supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_E", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x4), false, - "Download microcode mode 0xe supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "DM_MD_F", SGJ_SEP_EQUAL_NO_SPACE, - !!(b[19] & 0x2), false, - "Download microcode mode 0xf supported"); + sgj_haj_vi_nex(jsp, jop, 2, np, SGJ_SEP_EQUAL_NO_SPACE, n, + true, nex_p); + + sgj_haj_vi_nex(jsp, jop, 2, "R_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[8] & 0x10), false, "Referrals supported"); + sgj_haj_vi_nex(jsp, jop, 2, "RTD_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[8] & 0x8), false, + "Revert to defaults supported"); + sgj_haj_vi_nex(jsp, jop, 2, "HSSRELEF", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[8] & 0x2), false, + "History snapshots release effects"); + sgj_haj_vi_nex(jsp, jop, 2, "CBCS", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[8] & 0x1), false, "Capability-based command " + "security (obsolete SPC-5)"); + sgj_haj_vi(jsp, jop, 2, "Multi I_T nexus microcode download", + SGJ_SEP_EQUAL_NO_SPACE, b[9] & 0xf, true); + sgj_haj_vi(jsp, jop, 2, "Extended self-test completion minutes", + SGJ_SEP_EQUAL_NO_SPACE, + sg_get_unaligned_be16(b + 10), true); + sgj_haj_vi_nex(jsp, jop, 2, "POA_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[12] & 0x80), false, + "Power on activation supported"); + sgj_haj_vi_nex(jsp, jop, 2, "HRA_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[12] & 0x40), false, + "Hard reset activation supported"); + sgj_haj_vi_nex(jsp, jop, 2, "VSA_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[12] & 0x20), false, + "Vendor specific activation supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DMS_VALID", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[12] & 0x10), false, + "Download microcode support byte valid"); + sgj_haj_vi(jsp, jop, 2, "Maximum supported sense data length", + SGJ_SEP_EQUAL_NO_SPACE, b[13], true); + sgj_haj_vi_nex(jsp, jop, 2, "IBS", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[14] & 0x80), false, "Implicit bind supported"); + sgj_haj_vi_nex(jsp, jop, 2, "IAS", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[14] & 0x40), false, + "Implicit affiliation supported"); + sgj_haj_vi_nex(jsp, jop, 2, "SAC", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[14] & 0x4), false, + "Set affiliation command supported"); + sgj_haj_vi_nex(jsp, jop, 2, "NRD1", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[14] & 0x2), false, + "No redirect one supported (BIND)"); + sgj_haj_vi_nex(jsp, jop, 2, "NRD0", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[14] & 0x1), false, + "No redirect zero supported (BIND)"); + sgj_haj_vi(jsp, jop, 2, "Maximum inquiry change logs", + SGJ_SEP_EQUAL_NO_SPACE, + sg_get_unaligned_be16(b + 15), true); + sgj_haj_vi(jsp, jop, 2, "Maximum mode page change logs", + SGJ_SEP_EQUAL_NO_SPACE, + sg_get_unaligned_be16(b + 17), true); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_4", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x80), false, + "Download microcode mode 4 supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_5", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x40), false, + "Download microcode mode 5 supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_6", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x20), false, + "Download microcode mode 6 supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_7", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x10), false, + "Download microcode mode 7 supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_D", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x8), false, + "Download microcode mode 0xd supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_E", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x4), false, + "Download microcode mode 0xe supported"); + sgj_haj_vi_nex(jsp, jop, 2, "DM_MD_F", SGJ_SEP_EQUAL_NO_SPACE, + !!(b[19] & 0x2), false, + "Download microcode mode 0xf supported"); if (do_long_nq || (! jsp->pr_out_hr)) return; } @@ -538,24 +735,24 @@ decode_power_condition(uint8_t * buff, int len, struct opts_t * op, sgj_js_nv_ihex(jsp, jop, "idle_b", !!(buff[5] & 0x2)); sgj_js_nv_ihex(jsp, jop, "idle_a", !!(buff[5] & 0x1)); } - sgj_hr_js_vi_nex(jsp, jop, 2, "Stopped condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 6), - true, "unit: millisecond"); - sgj_hr_js_vi_nex(jsp, jop, 2, "Standby_z condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 8), - true, "unit: millisecond"); - sgj_hr_js_vi_nex(jsp, jop, 2, "Standby_y condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 10), - true, "unit: millisecond"); - sgj_hr_js_vi_nex(jsp, jop, 2, "Idle_a condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 12), - true, "unit: millisecond"); - sgj_hr_js_vi_nex(jsp, jop, 2, "Idle_b condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 14), - true, "unit: millisecond"); - sgj_hr_js_vi_nex(jsp, jop, 2, "Idle_c condition recovery time", - SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 16), - true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Stopped condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 6), + true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Standby_z condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 8), + true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Standby_y condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 10), + true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Idle_a condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 12), + true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Idle_b condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 14), + true, "unit: millisecond"); + sgj_haj_vi_nex(jsp, jop, 2, "Idle_c condition recovery time", + SGJ_SEP_SPACE_1, sg_get_unaligned_be16(buff + 16), + true, "unit: millisecond"); } int @@ -1114,8 +1311,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(mcawl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, cni); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mcawl, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mcawl, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); u = sg_get_unaligned_be16(buff + 6); if (0 == u) { @@ -1123,8 +1320,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(otlg, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, otlg, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, otlg, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); u = sg_get_unaligned_be32(buff + 8); if (0 == u) { @@ -1132,8 +1329,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(mtl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mtl, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mtl, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); u = sg_get_unaligned_be32(buff + 12); if (0 == u) { @@ -1141,8 +1338,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(otl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, otl, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, otl, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); if (len > 19) { /* added in sbc3r09 */ u = sg_get_unaligned_be32(buff + 16); if (0 == u) { @@ -1150,8 +1347,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(mpl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mpl, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mpl, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); } if (len > 27) { /* added in sbc3r18 */ u = sg_get_unaligned_be32(buff + 20); @@ -1163,8 +1360,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_pr_hr(jsp, " %s: %s blocks\n", ul, mulc); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, ul); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mulc, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mulc, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); u = sg_get_unaligned_be32(buff + 24); sgj_convert_to_snake_name(mulc, b, blen); @@ -1175,8 +1372,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_pr_hr(jsp, " %s: %s block descriptors\n", ul, mubdc); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, ul); } else - sgj_hr_js_vi(jsp, jop, 2, mubdc, SGJ_SEP_COLON_1_SPACE, - u, true); + sgj_haj_vi(jsp, jop, 2, mubdc, SGJ_SEP_COLON_1_SPACE, + u, true); } if (len > 35) { /* added in sbc3r19 */ u = sg_get_unaligned_be32(buff + 28); @@ -1185,16 +1382,16 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(oug, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, oug, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, oug, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); ugavalid = !!(buff[32] & 0x80); sgj_pr_hr(jsp, " %s: %s\n", ugav, ugavalid ? "true" : "false"); sgj_js_nv_i(jsp, jop, ugav, ugavalid); if (ugavalid) { u = 0x7fffffff & sg_get_unaligned_be32(buff + 32); - sgj_hr_js_vi_nex(jsp, jop, 2, uga, SGJ_SEP_COLON_1_SPACE, u, - true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, uga, SGJ_SEP_COLON_1_SPACE, u, + true, "unit: LB"); } } if (len > 43) { /* added in sbc3r26 */ @@ -1204,8 +1401,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(mwsl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, ull, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mwsl, SGJ_SEP_COLON_1_SPACE, - ull, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mwsl, SGJ_SEP_COLON_1_SPACE, + ull, true, "unit: LB"); } if (len > 47) { /* added in sbc4r02 */ u = sg_get_unaligned_be32(buff + 44); @@ -1214,8 +1411,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(matl, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, matl, SGJ_SEP_COLON_1_SPACE, - u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, matl, SGJ_SEP_COLON_1_SPACE, + u, true, "unit: LB"); u = sg_get_unaligned_be32(buff + 48); if (0 == u) { @@ -1225,8 +1422,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(aa, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, uawp); } else - sgj_hr_js_vi_nex(jsp, jop, 2, aa, SGJ_SEP_COLON_1_SPACE, - u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, aa, SGJ_SEP_COLON_1_SPACE, + u, true, "unit: LB"); u = sg_get_unaligned_be32(buff + 52); if (0 == u) { @@ -1236,8 +1433,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(atlg, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, ngr); } else - sgj_hr_js_vi_nex(jsp, jop, 2, aa, SGJ_SEP_COLON_1_SPACE, - u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, aa, SGJ_SEP_COLON_1_SPACE, + u, true, "unit: LB"); } if (len > 56) { u = sg_get_unaligned_be32(buff + 56); @@ -1246,8 +1443,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(matlwab, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, nr_s); } else - sgj_hr_js_vi_nex(jsp, jop, 2, matlwab, SGJ_SEP_COLON_1_SPACE, - u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, matlwab, SGJ_SEP_COLON_1_SPACE, + u, true, "unit: LB"); u = sg_get_unaligned_be32(buff + 60); if (0 == u) { @@ -1257,8 +1454,8 @@ decode_block_limits_vpd(const uint8_t * buff, int len, struct opts_t * op, sgj_convert_to_snake_name(mabs, b, blen); sgj_js_nv_ihexstr(jsp, jop, b, u, NULL, cowa1b); } else - sgj_hr_js_vi_nex(jsp, jop, 2, mabs, SGJ_SEP_COLON_1_SPACE, - u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, mabs, SGJ_SEP_COLON_1_SPACE, + u, true, "unit: LB"); } } @@ -1327,12 +1524,12 @@ decode_block_dev_ch_vpd(const uint8_t * buff, int len, struct opts_t * op, (u < 0xf0) ? rsv_s : vs_s, u); sgj_js_nv_ihexstr(jsp, jop, pt_j, u, NULL, (u < 0xf0) ? rsv_s : vs_s); } - sgj_hr_js_vi_nex(jsp, jop, 2, "WABEREQ", SGJ_SEP_EQUAL_NO_SPACE, - (buff[7] >> 6) & 0x3, false, - "Write After Block Erase REQuired"); - sgj_hr_js_vi_nex(jsp, jop, 2, "WACEREQ", SGJ_SEP_EQUAL_NO_SPACE, - (buff[7] >> 4) & 0x3, false, - "Write After Cryptographic Erase REQuired"); + sgj_haj_vi_nex(jsp, jop, 2, "WABEREQ", SGJ_SEP_EQUAL_NO_SPACE, + (buff[7] >> 6) & 0x3, false, + "Write After Block Erase REQuired"); + sgj_haj_vi_nex(jsp, jop, 2, "WACEREQ", SGJ_SEP_EQUAL_NO_SPACE, + (buff[7] >> 4) & 0x3, false, + "Write After Cryptographic Erase REQuired"); u = buff[7] & 0xf; switch (u) { case 0: @@ -1359,25 +1556,25 @@ decode_block_dev_ch_vpd(const uint8_t * buff, int len, struct opts_t * op, } sgj_pr_hr(jsp, " Nominal form factor: %s\n", b); sgj_js_nv_ihexstr(jsp, jop, "nominal_forn_factor", u, NULL, b); - sgj_hr_js_vi_nex(jsp, jop, 2, "MACT", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[8] & 0x40), false, "Multiple ACTuator"); + sgj_haj_vi_nex(jsp, jop, 2, "MACT", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[8] & 0x40), false, "Multiple ACTuator"); zoned = (buff[8] >> 4) & 0x3; /* added sbc4r04, obsolete sbc5r01 */ cp = bdc_zoned_strs[zoned]; sgj_pr_hr(jsp, " ZONED=%d [%s]\n", zoned, cp); sgj_js_nv_ihexstr_nex(jsp, jop, "zoned", zoned, false, NULL, cp, "Added in SBC-4, obsolete in SBC-5"); - sgj_hr_js_vi_nex(jsp, jop, 2, "RBWZ", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[8] & 0x4), false, - "Background Operation Control Supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "FUAB", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[8] & 0x2), false, - "Force Unit Access Behaviour"); - sgj_hr_js_vi_nex(jsp, jop, 2, "VBULS", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[8] & 0x1), false, - "Verify Byte check Unmapped Lba Supported"); + sgj_haj_vi_nex(jsp, jop, 2, "RBWZ", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[8] & 0x4), false, + "Background Operation Control Supported"); + sgj_haj_vi_nex(jsp, jop, 2, "FUAB", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[8] & 0x2), false, + "Force Unit Access Behaviour"); + sgj_haj_vi_nex(jsp, jop, 2, "VBULS", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[8] & 0x1), false, + "Verify Byte check Unmapped Lba Supported"); u = sg_get_unaligned_be32(buff + 12); - sgj_hr_js_vi_nex(jsp, jop, 2, "DEPOPULATION TIME", SGJ_SEP_COLON_1_SPACE, - u, true, "unit: second"); + sgj_haj_vi_nex(jsp, jop, 2, "DEPOPULATION TIME", SGJ_SEP_COLON_1_SPACE, + u, true, "unit: second"); } static const char * prov_type_arr[8] = { @@ -1412,25 +1609,24 @@ decode_block_lb_prov_vpd(uint8_t * buff, int len, struct opts_t * op, t_exp = buff[4]; sgj_js_nv_ihexstr(jsp, jop, "threshold_exponent", t_exp, NULL, (0 == t_exp) ? ns_s : NULL); - sgj_hr_js_vi_nex(jsp, jop, 2, "LBPU", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[5] & 0x80), false, - "Logical Block Provisioning Unmap command supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "LBPWS", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[5] & 0x40), false, "Logical Block Provisioning " - "Write Same (16) command supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "LBPWS10", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[5] & 0x20), false, - "Logical Block Provisioning Write Same (10) command " - "supported"); - sgj_hr_js_vi_nex(jsp, jop, 2, "LBPRZ", SGJ_SEP_EQUAL_NO_SPACE, - (0x7 & (buff[5] >> 2)), true, - "Logical Block Provisioning Read Zero"); - sgj_hr_js_vi_nex(jsp, jop, 2, "ANC_SUP", SGJ_SEP_EQUAL_NO_SPACE, - !!(buff[5] & 0x2), false, - "ANChor SUPported"); + sgj_haj_vi_nex(jsp, jop, 2, "LBPU", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[5] & 0x80), false, + "Logical Block Provisioning Unmap command supported"); + sgj_haj_vi_nex(jsp, jop, 2, "LBPWS", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[5] & 0x40), false, "Logical Block Provisioning " + "Write Same (16) command supported"); + sgj_haj_vi_nex(jsp, jop, 2, "LBPWS10", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[5] & 0x20), false, "Logical Block Provisioning " + "Write Same (10) command supported"); + sgj_haj_vi_nex(jsp, jop, 2, "LBPRZ", SGJ_SEP_EQUAL_NO_SPACE, + (0x7 & (buff[5] >> 2)), true, + "Logical Block Provisioning Read Zero"); + sgj_haj_vi_nex(jsp, jop, 2, "ANC_SUP", SGJ_SEP_EQUAL_NO_SPACE, + !!(buff[5] & 0x2), false, + "ANChor SUPported"); dp = !!(buff[5] & 0x1); - sgj_hr_js_vi_nex(jsp, jop, 2, "DP", SGJ_SEP_EQUAL_NO_SPACE, - dp, false, "Descriptor Present"); + sgj_haj_vi_nex(jsp, jop, 2, "DP", SGJ_SEP_EQUAL_NO_SPACE, + dp, false, "Descriptor Present"); u = 0x1f & (buff[6] >> 3); /* minimum percentage */ if (0 == u) sgj_pr_hr(jsp, " %s: 0 [%s]\n", mp, nr_s); @@ -1501,8 +1697,8 @@ decode_referrals_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_pr_hr(jsp, "%s%u\n", b, u); sgj_js_nv_ihex(jsp, jop, "user_data_segment_size", u); u = sg_get_unaligned_be32(buff + 12); - sgj_hr_js_vi(jsp, jop, 2, "User data segment multiplier", - SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi(jsp, jop, 2, "User data segment multiplier", + SGJ_SEP_COLON_1_SPACE, u, true); } /* VPD_SUP_BLOCK_LENS 0xb4 ["sbl"] (added sbc4r01) */ @@ -1526,35 +1722,28 @@ decode_sup_block_lens_vpd(uint8_t * buff, int len, struct opts_t * op, if (jsp->pr_as_json) jo2p = sgj_new_unattached_object_r(jsp); u = sg_get_unaligned_be32(bp); - sgj_hr_js_vi(jsp, jo2p, 2, "Logical block length", - SGJ_SEP_COLON_1_SPACE, u, true); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "P_I_I_SUP", - SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x40), false, - "Protection Information Interval SUPported"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "NO_PI_CHK", - SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x8), false, - "NO Protection Information CHecKing"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "GRD_CHK", - SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x4), false, - "GuaRD CHecK"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "APP_CHK", - SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x2), false, - "APPlication tag CHecK"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "REF_CHK", - SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x1), false, - "REFerence tag CHecK"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "T3PS", - SGJ_SEP_COLON_1_SPACE, !!(bp[5] & 0x8), false, - "Type 3 Protection Supported"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "T2PS", - SGJ_SEP_COLON_1_SPACE, !!(bp[5] & 0x4), false, - "Type 2 Protection Supported"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "T1PS", - SGJ_SEP_COLON_1_SPACE, !!(bp[5] & 0x2), false, - "Type 1 Protection Supported"); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "T0PS", - SGJ_SEP_COLON_1_SPACE, !!(bp[5] & 0x1), false, - "Type 0 Protection Supported"); + sgj_haj_vi(jsp, jo2p, 2, "Logical block length", + SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi_nex(jsp, jo2p, 4, "P_I_I_SUP", + SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x40), false, + "Protection Information Interval SUPported"); + sgj_haj_vi_nex(jsp, jo2p, 4, "NO_PI_CHK", + SGJ_SEP_COLON_1_SPACE, !!(bp[4] & 0x8), false, + "NO Protection Information CHecKing"); + sgj_haj_vi_nex(jsp, jo2p, 4, "GRD_CHK", SGJ_SEP_COLON_1_SPACE, + !!(bp[4] & 0x4), false, "GuaRD CHecK"); + sgj_haj_vi_nex(jsp, jo2p, 4, "APP_CHK", SGJ_SEP_COLON_1_SPACE, + !!(bp[4] & 0x2), false, "APPlication tag CHecK"); + sgj_haj_vi_nex(jsp, jo2p, 4, "REF_CHK", SGJ_SEP_COLON_1_SPACE, + !!(bp[4] & 0x1), false, "REFerence tag CHecK"); + sgj_haj_vi_nex(jsp, jo2p, 4, "T3PS", SGJ_SEP_COLON_1_SPACE, + !!(bp[5] & 0x8), false, "Type 3 Protection Supported"); + sgj_haj_vi_nex(jsp, jo2p, 4, "T2PS", SGJ_SEP_COLON_1_SPACE, + !!(bp[5] & 0x4), false, "Type 2 Protection Supported"); + sgj_haj_vi_nex(jsp, jo2p, 4, "T1PS", SGJ_SEP_COLON_1_SPACE, + !!(bp[5] & 0x2), false, "Type 1 Protection Supported"); + sgj_haj_vi_nex(jsp, jo2p, 4, "T0PS", SGJ_SEP_COLON_1_SPACE, + !!(bp[5] & 0x1), false, "Type 0 Protection Supported"); sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); } } @@ -1595,8 +1784,8 @@ decode_block_dev_char_ext_vpd(uint8_t * buff, int len, struct opts_t * op, utp = rsv_s; break; } - sgj_hr_js_vistr(jsp, jop, 2, "Utilization type", SGJ_SEP_COLON_1_SPACE, - buff[5], true, utp); + sgj_haj_vistr(jsp, jop, 2, "Utilization type", SGJ_SEP_COLON_1_SPACE, + buff[5], true, utp); switch (buff[6]) { case 2: uup = "megabytes"; @@ -1617,8 +1806,8 @@ decode_block_dev_char_ext_vpd(uint8_t * buff, int len, struct opts_t * op, uup = rsv_s; break; } - sgj_hr_js_vistr(jsp, jop, 2, "Utilization units", SGJ_SEP_COLON_1_SPACE, - buff[6], true, uup); + sgj_haj_vistr(jsp, jop, 2, "Utilization units", SGJ_SEP_COLON_1_SPACE, + buff[6], true, uup); switch (buff[7]) { case 0xa: uip = "per day"; @@ -1630,16 +1819,16 @@ decode_block_dev_char_ext_vpd(uint8_t * buff, int len, struct opts_t * op, uip = rsv_s; break; } - sgj_hr_js_vistr(jsp, jop, 2, "Utilization interval", - SGJ_SEP_COLON_1_SPACE, buff[7], true, uip); + sgj_haj_vistr(jsp, jop, 2, "Utilization interval", SGJ_SEP_COLON_1_SPACE, + buff[7], true, uip); u = sg_get_unaligned_be32(buff + 8); - sgj_hr_js_vistr(jsp, jop, 2, "Utilization B", SGJ_SEP_COLON_1_SPACE, - u, true, (b_active ? NULL : rsv_s)); + sgj_haj_vistr(jsp, jop, 2, "Utilization B", SGJ_SEP_COLON_1_SPACE, + u, true, (b_active ? NULL : rsv_s)); n = sg_scnpr(b, blen, "%s: ", "Designed utilization"); if (b_active) n += sg_scnpr(b + n, blen - n, "%u %s for reads and ", u, uup); u = sg_get_unaligned_be32(buff + 12); - sgj_hr_js_vi(jsp, jop, 2, "Utilization A", SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi(jsp, jop, 2, "Utilization A", SGJ_SEP_COLON_1_SPACE, u, true); n += sg_scnpr(b + n, blen - n, "%u %s for %swrites, %s", u, uup, combined ? "reads and " : null_s, uip); sgj_pr_hr(jsp, " %s\n", b); @@ -1689,27 +1878,27 @@ decode_zbdch_vpd(uint8_t * buff, int len, struct opts_t * op, strcpy(b, rsv_s); break; } - sgj_hr_js_vistr(jsp, jop, 2, "Zoned block device extension", - SGJ_SEP_COLON_1_SPACE, u, true, b); - sgj_hr_js_vi_nex(jsp, jop, 2, "AAORB", SGJ_SEP_COLON_1_SPACE, - !!(buff[4] & 0x2), false, - "Activation Aligned On Realm Boundaries"); - sgj_hr_js_vi_nex(jsp, jop, 2, "URSWRZ", SGJ_SEP_COLON_1_SPACE, - !!(buff[4] & 0x1), false, - "Unrestricted Read in Sequential Write Required Zone"); + sgj_haj_vistr(jsp, jop, 2, "Zoned block device extension", + SGJ_SEP_COLON_1_SPACE, u, true, b); + sgj_haj_vi_nex(jsp, jop, 2, "AAORB", SGJ_SEP_COLON_1_SPACE, + !!(buff[4] & 0x2), false, + "Activation Aligned On Realm Boundaries"); + sgj_haj_vi_nex(jsp, jop, 2, "URSWRZ", SGJ_SEP_COLON_1_SPACE, + !!(buff[4] & 0x1), false, + "Unrestricted Read in Sequential Write Required Zone"); u = sg_get_unaligned_be32(buff + 8); - sgj_hr_js_vistr(jsp, jop, 2, "Optimal number of open sequential write " - "preferred zones", SGJ_SEP_COLON_1_SPACE, u, true, - (SG_LIB_UNBOUNDED_32BIT == u) ? nr_s : NULL); + sgj_haj_vistr(jsp, jop, 2, "Optimal number of open sequential write " + "preferred zones", SGJ_SEP_COLON_1_SPACE, u, true, + (SG_LIB_UNBOUNDED_32BIT == u) ? nr_s : NULL); u = sg_get_unaligned_be32(buff + 12); - sgj_hr_js_vistr(jsp, jop, 2, "Optimal number of non-sequentially " - "written sequential write preferred zones", - SGJ_SEP_COLON_1_SPACE, u, true, - (SG_LIB_UNBOUNDED_32BIT == u) ? nr_s : NULL); + sgj_haj_vistr(jsp, jop, 2, "Optimal number of non-sequentially " + "written sequential write preferred zones", + SGJ_SEP_COLON_1_SPACE, u, true, + (SG_LIB_UNBOUNDED_32BIT == u) ? nr_s : NULL); u = sg_get_unaligned_be32(buff + 16); - sgj_hr_js_vistr(jsp, jop, 2, "Maximum number of open sequential write " - "required zones", SGJ_SEP_COLON_1_SPACE, u, true, - (SG_LIB_UNBOUNDED_32BIT == u) ? nl_s : NULL); + sgj_haj_vistr(jsp, jop, 2, "Maximum number of open sequential write " + "required zones", SGJ_SEP_COLON_1_SPACE, u, true, + (SG_LIB_UNBOUNDED_32BIT == u) ? nl_s : NULL); u = buff[23] & 0xf; switch (u) { case 0: @@ -1726,11 +1915,10 @@ decode_zbdch_vpd(uint8_t * buff, int len, struct opts_t * op, strcpy(b, rsv_s); break; } - sgj_hr_js_vistr(jsp, jop, 2, "Zoned alignment method", - SGJ_SEP_COLON_1_SPACE, u, true, b); - sgj_hr_js_vi(jsp, jop, 2, "Zone starting LBA granularity", - SGJ_SEP_COLON_1_SPACE, sg_get_unaligned_be64(buff + 24), - true); + sgj_haj_vistr(jsp, jop, 2, "Zoned alignment method", + SGJ_SEP_COLON_1_SPACE, u, true, b); + sgj_haj_vi(jsp, jop, 2, "Zone starting LBA granularity", + SGJ_SEP_COLON_1_SPACE, sg_get_unaligned_be64(buff + 24), true); } /* VPD_BLOCK_LIMITS_EXT 0xb7 ["ble"] SBC */ @@ -1750,32 +1938,32 @@ decode_block_limits_ext_vpd(uint8_t * buff, int len, struct opts_t * op, return; } u = sg_get_unaligned_be16(buff + 6); - sgj_hr_js_vistr(jsp, jop, 2, "Maximum number of streams", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u) ? "Stream control not supported" : NULL); + sgj_haj_vistr(jsp, jop, 2, "Maximum number of streams", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u) ? "Stream control not supported" : NULL); u = sg_get_unaligned_be16(buff + 8); - sgj_hr_js_vi_nex(jsp, jop, 2, "Optimal stream write size", - SGJ_SEP_COLON_1_SPACE, u, true, "unit: LB"); + sgj_haj_vi_nex(jsp, jop, 2, "Optimal stream write size", + SGJ_SEP_COLON_1_SPACE, u, true, "unit: LB"); u = sg_get_unaligned_be32(buff + 10); - sgj_hr_js_vi_nex(jsp, jop, 2, "Stream granularity size", - SGJ_SEP_COLON_1_SPACE, u, true, - "unit: number of optimal stream write size blocks"); + sgj_haj_vi_nex(jsp, jop, 2, "Stream granularity size", + SGJ_SEP_COLON_1_SPACE, u, true, + "unit: number of optimal stream write size blocks"); if (len < 28) return; u = sg_get_unaligned_be32(buff + 16); - sgj_hr_js_vistr_nex(jsp, jop, 2, "Maximum scattered LBA range transfer " - "length", SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? nlr_s : NULL), - "unit: LB (in a single LBA range descriptor)"); + sgj_haj_vistr_nex(jsp, jop, 2, "Maximum scattered LBA range transfer " + "length", SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? nlr_s : NULL), + "unit: LB (in a single LBA range descriptor)"); u = sg_get_unaligned_be16(buff + 22); - sgj_hr_js_vistr(jsp, jop, 2, "Maximum scattered LBA range descriptor " - "count", SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? nlr_s : NULL)); + sgj_haj_vistr(jsp, jop, 2, "Maximum scattered LBA range descriptor " + "count", SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? nlr_s : NULL)); u = sg_get_unaligned_be32(buff + 24); - sgj_hr_js_vistr_nex(jsp, jop, 2, "Maximum scattered transfer length", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? nlr_s : NULL), - "unit: LB (per single Write Scattered command)"); + sgj_haj_vistr_nex(jsp, jop, 2, "Maximum scattered transfer length", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? nlr_s : NULL), + "unit: LB (per single Write Scattered command)"); } static const char * sch_type_arr[8] = { @@ -1843,8 +2031,8 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op, bp = buff + 4; for (k = 0; k < len; k += 64, bp += 64) { jo2p = sgj_new_unattached_object_r(jsp); - sgj_hr_js_vi(jsp, jo2p, 2, "Preset identifier", SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be64(bp + 0), true); + sgj_haj_vi(jsp, jo2p, 2, "Preset identifier", SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be64(bp + 0), true); sch_type = bp[4]; if (sch_type < 8) { cp = sch_type_arr[sch_type]; @@ -1854,24 +2042,24 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op, snprintf(b, blen, "%s", cp); } else strcpy(b, rsv_s); - sgj_hr_js_vistr(jsp, jo2p, 4, "Schema type", SGJ_SEP_COLON_1_SPACE, - sch_type, true, b); - sgj_hr_js_vi(jsp, jo2p, 4, "Logical blocks per physical block " - "exponent", SGJ_SEP_COLON_1_SPACE, - 0xf & bp[7], true); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "Logical block length", - SGJ_SEP_COLON_1_SPACE, sg_get_unaligned_be32(bp + 8), - true, "unit: byte"); - sgj_hr_js_vi(jsp, jo2p, 4, "Designed last Logical Block Address", - SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be64(bp + 16), true); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "FMTPINFO", SGJ_SEP_COLON_1_SPACE, - (bp[38] >> 6) & 0x3, false, - "ForMaT Protection INFOrmation (see Format Unit)"); - sgj_hr_js_vi(jsp, jo2p, 4, "Protection field usage", - SGJ_SEP_COLON_1_SPACE, bp[38] & 0x7, false); - sgj_hr_js_vi(jsp, jo2p, 4, "Protection interval exponent", - SGJ_SEP_COLON_1_SPACE, bp[39] & 0xf, true); + sgj_haj_vistr(jsp, jo2p, 4, "Schema type", SGJ_SEP_COLON_1_SPACE, + sch_type, true, b); + sgj_haj_vi(jsp, jo2p, 4, "Logical blocks per physical block " + "exponent", SGJ_SEP_COLON_1_SPACE, + 0xf & bp[7], true); + sgj_haj_vi_nex(jsp, jo2p, 4, "Logical block length", + SGJ_SEP_COLON_1_SPACE, sg_get_unaligned_be32(bp + 8), + true, "unit: byte"); + sgj_haj_vi(jsp, jo2p, 4, "Designed last Logical Block Address", + SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be64(bp + 16), true); + sgj_haj_vi_nex(jsp, jo2p, 4, "FMTPINFO", SGJ_SEP_COLON_1_SPACE, + (bp[38] >> 6) & 0x3, false, + "ForMaT Protection INFOrmation (see Format Unit)"); + sgj_haj_vi(jsp, jo2p, 4, "Protection field usage", + SGJ_SEP_COLON_1_SPACE, bp[38] & 0x7, false); + sgj_haj_vi(jsp, jo2p, 4, "Protection interval exponent", + SGJ_SEP_COLON_1_SPACE, bp[39] & 0xf, true); jo3p = sgj_named_subobject_r(jsp, jo2p, "schema_type_specific_information"); switch (sch_type) { @@ -1888,9 +2076,9 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_js_nv_ihex_nex(jsp, jo3p, b, u, true, "unit: 1/10 of a " "percent"); u = sg_get_unaligned_be32(bp + 40 + 12); - sgj_hr_js_vistr(jsp, jo3p, 6, "Logical blocks per zone", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? rsv_s : NULL)); + sgj_haj_vistr(jsp, jo3p, 6, "Logical blocks per zone", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? rsv_s : NULL)); break; case 3: sgj_pr_hr(jsp, " Defines zones for host managed device:\n"); @@ -1905,17 +2093,17 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_js_nv_ihex_nex(jsp, jo3p, b, u, true, "unit: 1/10 of a " "percent"); u = bp[40 + 3] & 0x7; - sgj_hr_js_vistr(jsp, jo3p, 6, "Designed zone alignment method", - SGJ_SEP_COLON_1_SPACE, u, true, - get_zone_align_method(u, d, dlen)); + sgj_haj_vistr(jsp, jo3p, 6, "Designed zone alignment method", + SGJ_SEP_COLON_1_SPACE, u, true, + get_zone_align_method(u, d, dlen)); ul = sg_get_unaligned_be64(bp + 40 + 4); - sgj_hr_js_vi_nex(jsp, jo3p, 6, "Designed zone starting LBA " - "granularity", SGJ_SEP_COLON_1_SPACE, ul, true, - "unit: LB"); + sgj_haj_vi_nex(jsp, jo3p, 6, "Designed zone starting LBA " + "granularity", SGJ_SEP_COLON_1_SPACE, ul, true, + "unit: LB"); u = sg_get_unaligned_be32(bp + 40 + 12); - sgj_hr_js_vistr(jsp, jo3p, 6, "Logical blocks per zone", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? rsv_s : NULL)); + sgj_haj_vistr(jsp, jo3p, 6, "Logical blocks per zone", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? rsv_s : NULL)); break; case 4: sgj_pr_hr(jsp, " Defines zones for zone domains and realms " @@ -1923,37 +2111,33 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op, snprintf(b, blen, "%s 0", ztzd); u = bp[40 + 0]; sg_get_zone_type_str((u >> 4) & 0xf, dlen, d); - sgj_hr_js_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, - d); + sgj_haj_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, d); snprintf(b, blen, "%s 1", ztzd); sg_get_zone_type_str(u & 0xf, dlen, d); - sgj_hr_js_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, - d); + sgj_haj_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, d); snprintf(b, blen, "%s 2", ztzd); u = bp[40 + 1]; sg_get_zone_type_str((u >> 4) & 0xf, dlen, d); - sgj_hr_js_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, - d); + sgj_haj_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, d); snprintf(b, blen, "%s 3", ztzd); sg_get_zone_type_str(u & 0xf, dlen, d); - sgj_hr_js_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, - d); + sgj_haj_vistr(jsp, jo3p, 6, b, SGJ_SEP_COLON_1_SPACE, u, true, d); u = bp[40 + 3] & 0x7; - sgj_hr_js_vistr(jsp, jo3p, 6, "Designed zone alignment method", - SGJ_SEP_COLON_1_SPACE, u, true, - get_zone_align_method(u, d, dlen)); + sgj_haj_vistr(jsp, jo3p, 6, "Designed zone alignment method", + SGJ_SEP_COLON_1_SPACE, u, true, + get_zone_align_method(u, d, dlen)); ul = sg_get_unaligned_be64(bp + 40 + 4); - sgj_hr_js_vi_nex(jsp, jo3p, 6, "Designed zone starting LBA " - "granularity", SGJ_SEP_COLON_1_SPACE, ul, true, - "unit: LB"); + sgj_haj_vi_nex(jsp, jo3p, 6, "Designed zone starting LBA " + "granularity", SGJ_SEP_COLON_1_SPACE, ul, true, + "unit: LB"); u = sg_get_unaligned_be32(bp + 40 + 12); - sgj_hr_js_vistr(jsp, jo3p, 6, "Logical blocks per zone", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? rsv_s : NULL)); + sgj_haj_vistr(jsp, jo3p, 6, "Logical blocks per zone", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u ? rsv_s : NULL)); ul = sg_get_unaligned_be64(bp + 40 + 16); - sgj_hr_js_vi_nex(jsp, jo3p, 6, "Designed zone maximum address", - SGJ_SEP_COLON_1_SPACE, ul, true, "unit: LBA"); + sgj_haj_vi_nex(jsp, jo3p, 6, "Designed zone maximum address", + SGJ_SEP_COLON_1_SPACE, ul, true, "unit: LBA"); break; default: sgj_pr_hr(jsp, " No schema type specific information\n"); @@ -1986,16 +2170,15 @@ decode_con_pos_range_vpd(uint8_t * buff, int len, struct opts_t * op, bp = buff + 64; for (k = 0; k < len; k += 32, bp += 32) { jo2p = sgj_new_unattached_object_r(jsp); - sgj_hr_js_vi(jsp, jo2p, 2, "LBA range number", - SGJ_SEP_COLON_1_SPACE, bp[0], true); + sgj_haj_vi(jsp, jo2p, 2, "LBA range number", + SGJ_SEP_COLON_1_SPACE, bp[0], true); u = bp[1]; - sgj_hr_js_vistr(jsp, jo2p, 4, "Number of storage elements", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u ? nr_s : NULL)); - sgj_hr_js_vi(jsp, jo2p, 4, "Starting LBA", SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be64(bp + 8), true); - sgj_hr_js_vi(jsp, jo2p, 4, "Number of LBAs", SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be64(bp + 16), true); + sgj_haj_vistr(jsp, jo2p, 4, "Number of storage elements", + SGJ_SEP_COLON_1_SPACE, u, true, (0 == u ? nr_s : NULL)); + sgj_haj_vi(jsp, jo2p, 4, "Starting LBA", SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be64(bp + 8), true); + sgj_haj_vi(jsp, jo2p, 4, "Number of LBAs", SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be64(bp + 16), true); sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); } } @@ -2033,24 +2216,24 @@ decode_rod_descriptor(const uint8_t * buff, int len, struct opts_t * op, sgj_js_nv_ihexstr_nex(jsp, jo2p, "peripheral_device_type", pdt, false, NULL, "Block ROD device " "type specific descriptor", ab_pdt); - sgj_hr_js_vi_nex(jsp, jo2p, 4, "Optimal block ROD length " - "granularity", SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be16(bp + 6), true, "unit: LB"); + sgj_haj_vi_nex(jsp, jo2p, 4, "Optimal block ROD length " + "granularity", SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be16(bp + 6), true, "unit: LB"); ull = sg_get_unaligned_be64(bp + 8); - sgj_hr_js_vi(jsp, jo2p, 4, "Maximum bytes in block ROD", - SGJ_SEP_COLON_1_SPACE, ull, true); + sgj_haj_vi(jsp, jo2p, 4, "Maximum bytes in block ROD", + SGJ_SEP_COLON_1_SPACE, ull, true); ull = sg_get_unaligned_be64(bp + 16); - sgj_hr_js_vistr(jsp, jo2p, 4, "Optimal Bytes in block ROD " - "transfer", SGJ_SEP_COLON_1_SPACE, ull, true, - (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); + sgj_haj_vistr(jsp, jo2p, 4, "Optimal Bytes in block ROD " + "transfer", SGJ_SEP_COLON_1_SPACE, ull, true, + (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); ull = sg_get_unaligned_be64(bp + 24); - sgj_hr_js_vistr(jsp, jo2p, 4, "Optimal Bytes to token per " - "segment", SGJ_SEP_COLON_1_SPACE, ull, true, - (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); + sgj_haj_vistr(jsp, jo2p, 4, "Optimal Bytes to token per " + "segment", SGJ_SEP_COLON_1_SPACE, ull, true, + (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); ull = sg_get_unaligned_be64(bp + 32); - sgj_hr_js_vistr(jsp, jo2p, 4, "Optimal Bytes from token per " - "segment", SGJ_SEP_COLON_1_SPACE, ull, true, - (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); + sgj_haj_vistr(jsp, jo2p, 4, "Optimal Bytes from token per " + "segment", SGJ_SEP_COLON_1_SPACE, ull, true, + (SG_LIB_UNBOUNDED_64BIT == ull) ? nl_s : NULL); break; case 1: /* Stream ROD device type specific descriptor */ @@ -2058,8 +2241,8 @@ decode_rod_descriptor(const uint8_t * buff, int len, struct opts_t * op, pdt, false, NULL, "Stream ROD device " "type specific descriptor", ab_pdt); ull = sg_get_unaligned_be64(bp + 8); - sgj_hr_js_vi(jsp, jo2p, 4, "Maximum bytes in stream ROD", - SGJ_SEP_COLON_1_SPACE, ull, true); + sgj_haj_vi(jsp, jo2p, 4, "Maximum bytes in stream ROD", + SGJ_SEP_COLON_1_SPACE, ull, true); ull = sg_get_unaligned_be64(bp + 16); printf(" Optimal Bytes in stream ROD transfer: "); if (SG_LIB_UNBOUNDED_64BIT == ull) @@ -2084,7 +2267,7 @@ decode_rod_descriptor(const uint8_t * buff, int len, struct opts_t * op, break; default: sgj_js_nv_ihexstr(jsp, jo2p, "peripheral_device_type", - pdt, false, "unknown"); + pdt, NULL, "unknown"); break; } sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p); @@ -2302,9 +2485,9 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, case 0x0000: /* Required if POPULATE TOKEN (or friend) used */ sgj_pr_hr(jsp, " %s:\n", dtp); u = sg_get_unaligned_be16(bp + 10); - sgj_hr_js_vistr(jsp, jo2p, 2, "Maximum range descriptors", - SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u) ? nr_s : NULL); + sgj_haj_vistr(jsp, jo2p, 2, "Maximum range descriptors", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u) ? nr_s : NULL); u = sg_get_unaligned_be32(bp + 12); if (0 == u) cp = nr_s; @@ -2312,21 +2495,21 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, cp = "No maximum given"; else cp = NULL; - sgj_hr_js_vistr_nex(jsp, jo2p, 2, "Maximum inactivity " - "timeout", SGJ_SEP_COLON_1_SPACE, u, true, - cp, "unit: second"); + sgj_haj_vistr_nex(jsp, jo2p, 2, "Maximum inactivity timeout", + SGJ_SEP_COLON_1_SPACE, u, true, cp, + "unit: second"); u = sg_get_unaligned_be32(bp + 16); - sgj_hr_js_vistr_nex(jsp, jo2p, 2, "Default inactivity " - "timeout", SGJ_SEP_COLON_1_SPACE, u, true, - (0 == u) ? nr_s : NULL, "unit: second"); + sgj_haj_vistr_nex(jsp, jo2p, 2, "Default inactivity timeout", + SGJ_SEP_COLON_1_SPACE, u, true, + (0 == u) ? nr_s : NULL, "unit: second"); ull = sg_get_unaligned_be64(bp + 20); - sgj_hr_js_vistr_nex(jsp, jo2p, 2, "Maximum token transfer " - "size", SGJ_SEP_COLON_1_SPACE, ull, true, - (0 == ull) ? nr_s : NULL, "unit: LB"); + sgj_haj_vistr_nex(jsp, jo2p, 2, "Maximum token transfer size", + SGJ_SEP_COLON_1_SPACE, ull, true, + (0 == ull) ? nr_s : NULL, "unit: LB"); ull = sg_get_unaligned_be64(bp + 28); - sgj_hr_js_vistr_nex(jsp, jo2p, 2, "Optimal transfer count", - SGJ_SEP_COLON_1_SPACE, ull, true, - (0 == ull) ? nr_s : NULL, "unit: LB"); + sgj_haj_vistr_nex(jsp, jo2p, 2, "Optimal transfer count", + SGJ_SEP_COLON_1_SPACE, ull, true, + (0 == ull) ? nr_s : NULL, "unit: LB"); break; case 0x0001: /* Mandatory (SPC-4) */ sgj_pr_hr(jsp, " %s:\n", "Commands supported list"); @@ -2373,18 +2556,18 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, break; case 0x0004: sgj_pr_hr(jsp, " %s:\n", dtp); - sgj_hr_js_vi(jsp, jo2p, 2, "Maximum CSCD descriptor count", - SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be16(bp + 8), true); - sgj_hr_js_vi(jsp, jo2p, 2, "Maximum segment descriptor count", - SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be16(bp + 10), true); - sgj_hr_js_vi(jsp, jo2p, 2, "Maximum descriptor list length", - SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be32(bp + 12), true); - sgj_hr_js_vi(jsp, jo2p, 2, "Maximum inline data length", - SGJ_SEP_COLON_1_SPACE, - sg_get_unaligned_be32(bp + 17), true); + sgj_haj_vi(jsp, jo2p, 2, "Maximum CSCD descriptor count", + SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be16(bp + 8), true); + sgj_haj_vi(jsp, jo2p, 2, "Maximum segment descriptor count", + SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be16(bp + 10), true); + sgj_haj_vi(jsp, jo2p, 2, "Maximum descriptor list length", + SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be32(bp + 12), true); + sgj_haj_vi(jsp, jo2p, 2, "Maximum inline data length", + SGJ_SEP_COLON_1_SPACE, + sg_get_unaligned_be32(bp + 17), true); break; case 0x0008: sgj_pr_hr(jsp, " Supported descriptors:\n"); @@ -2437,8 +2620,8 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, break; case 0x0106: sgj_pr_hr(jsp, " ROD token features:\n"); - sgj_hr_js_vi(jsp, jo2p, 2, "Remote tokens", - SGJ_SEP_COLON_1_SPACE, bp[4] & 0x0f, true); + sgj_haj_vi(jsp, jo2p, 2, "Remote tokens", + SGJ_SEP_COLON_1_SPACE, bp[4] & 0x0f, true); u = sg_get_unaligned_be32(bp + 16); sgj_pr_hr(jsp, " Minimum token lifetime: %u seconds\n", u); sgj_js_nv_ihex_nex(jsp, jo2p, "minimum_token_lifetime", u, @@ -2448,9 +2631,9 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, sgj_js_nv_ihex_nex(jsp, jo2p, "maximum_token_lifetime", u, true, "unit: second"); u = sg_get_unaligned_be32(bp + 24); - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Maximum token inactivity " - "timeout", SGJ_SEP_COLON_1_SPACE, u, - true, "unit: second"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Maximum token inactivity " + "timeout", SGJ_SEP_COLON_1_SPACE, u, + true, "unit: second"); u = sg_get_unaligned_be16(bp + 46); ja2p = sgj_named_subarray_r(jsp, jo2p, "rod_device_type_specific_features_descriptor_list"); @@ -2485,48 +2668,47 @@ decode_3party_copy_vpd(uint8_t * buff, int len, struct opts_t * op, (u & 0x1) ? y_s : n_s); sgj_js_nv_i(jsp, jo3p, "token_out", !!(0x2 & u)); u = sg_get_unaligned_be16(bp + 8 + j + 6); - sgj_hr_js_vi(jsp, jo3p, 4, "Preference indicator", - SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi(jsp, jo3p, 4, "Preference indicator", + SGJ_SEP_COLON_1_SPACE, u, true); sgj_js_nv_o(jsp, ja2p, NULL /* name */, jo3p); } break; case 0x8001: /* Mandatory (SPC-4) */ sgj_pr_hr(jsp, " General copy operations:\n"); u = sg_get_unaligned_be32(bp + 4); - sgj_hr_js_vi(jsp, jo2p, 2, "Total concurrent copies", - SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi(jsp, jo2p, 2, "Total concurrent copies", + SGJ_SEP_COLON_1_SPACE, u, true); u = sg_get_unaligned_be32(bp + 8); - sgj_hr_js_vi(jsp, jo2p, 2, "Maximum identified concurrent " - "copies", SGJ_SEP_COLON_1_SPACE, u, true); + sgj_haj_vi(jsp, jo2p, 2, "Maximum identified concurrent " + "copies", SGJ_SEP_COLON_1_SPACE, u, true); u = sg_get_unaligned_be32(bp + 12); - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Maximum segment length", - SGJ_SEP_COLON_1_SPACE, u, true, - "unit: byte"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Maximum segment length", + SGJ_SEP_COLON_1_SPACE, u, true, "unit: byte"); u = bp[16]; /* field is power of 2 */ - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Data segment granularity", - SGJ_SEP_COLON_1_SPACE, u, true, - "unit: 2^val LB"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Data segment granularity", + SGJ_SEP_COLON_1_SPACE, u, true, + "unit: 2^val LB"); u = bp[17]; /* field is power of 2 */ - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Inline data granularity", - SGJ_SEP_COLON_1_SPACE, u, true, - "unit: 2^val LB"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Inline data granularity", + SGJ_SEP_COLON_1_SPACE, u, true, + "unit: 2^val LB"); break; case 0x9101: sgj_pr_hr(jsp, " Stream copy operations:\n"); u = sg_get_unaligned_be32(bp + 4); - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Maximum stream device " - "transfer size", SGJ_SEP_COLON_1_SPACE, u, - true, "unit: byte"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Maximum stream device transfer " + "size", SGJ_SEP_COLON_1_SPACE, u, true, + "unit: byte"); break; case 0xC001: sgj_pr_hr(jsp, " Held data:\n"); u = sg_get_unaligned_be32(bp + 4); - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Held data limit", - SGJ_SEP_COLON_1_SPACE, u, true, - "unit: byte; (lower limit: minimum)"); - sgj_hr_js_vi_nex(jsp, jo2p, 2, "Held data granularity", - SGJ_SEP_COLON_1_SPACE, bp[8], true, - "unit: 2^val byte"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Held data limit", + SGJ_SEP_COLON_1_SPACE, u, true, + "unit: byte; (lower limit: minimum)"); + sgj_haj_vi_nex(jsp, jo2p, 2, "Held data granularity", + SGJ_SEP_COLON_1_SPACE, bp[8], true, + "unit: 2^val byte"); break; default: pr2serr("Unexpected type=%d\n", desc_type); @@ -2567,12 +2749,12 @@ decode_proto_lu_vpd(uint8_t * buff, int len, struct opts_t * op, for (k = 0; k < len; k += bump, bp += bump) { jo2p = sgj_new_unattached_object_r(jsp); rel_port = sg_get_unaligned_be16(bp); - sgj_hr_js_vi(jsp, jo2p, 2, "Relative port", - SGJ_SEP_COLON_1_SPACE, rel_port, true); + sgj_haj_vi(jsp, jo2p, 2, "Relative port", + SGJ_SEP_COLON_1_SPACE, rel_port, true); proto = bp[2] & 0xf; sg_get_trans_proto_str(proto, blen, b); - sgj_hr_js_vistr(jsp, jo2p, 4, "Protocol identifier", - SGJ_SEP_COLON_1_SPACE, proto, false, b); + sgj_haj_vistr(jsp, jo2p, 4, "Protocol identifier", + SGJ_SEP_COLON_1_SPACE, proto, false, b); desc_len = sg_get_unaligned_be16(bp + 6); bump = 8 + desc_len; if ((k + bump) > len) { @@ -2589,8 +2771,8 @@ decode_proto_lu_vpd(uint8_t * buff, int len, struct opts_t * op, } switch (proto) { case TPROTO_SAS: - sgj_hr_js_vi(jsp, jo2p, 2, "TLR control supported", - SGJ_SEP_COLON_1_SPACE, !!(bp[8] & 0x1), false); + sgj_haj_vi(jsp, jo2p, 2, "TLR control supported", + SGJ_SEP_COLON_1_SPACE, !!(bp[8] & 0x1), false); break; default: pr2serr("Unexpected proto=%d\n", proto); @@ -2631,12 +2813,12 @@ decode_proto_port_vpd(uint8_t * buff, int len, struct opts_t * op, for (k = 0; k < len; k += bump, bp += bump) { jo2p = sgj_new_unattached_object_r(jsp); rel_port = sg_get_unaligned_be16(bp); - sgj_hr_js_vi(jsp, jo2p, 2, "Relative port", - SGJ_SEP_COLON_1_SPACE, rel_port, true); + sgj_haj_vi(jsp, jo2p, 2, "Relative port", + SGJ_SEP_COLON_1_SPACE, rel_port, true); proto = bp[2] & 0xf; sg_get_trans_proto_str(proto, blen, b); - sgj_hr_js_vistr(jsp, jo2p, 4, "Protocol identifier", - SGJ_SEP_COLON_1_SPACE, proto, false, b); + sgj_haj_vistr(jsp, jo2p, 4, "Protocol identifier", + SGJ_SEP_COLON_1_SPACE, proto, false, b); desc_len = sg_get_unaligned_be16(bp + 6); bump = 8 + desc_len; if ((k + bump) > len) { diff --git a/src/sg_vpd_common.h b/src/sg_vpd_common.h index bc2bbfac..722da1fd 100644 --- a/src/sg_vpd_common.h +++ b/src/sg_vpd_common.h @@ -66,6 +66,58 @@ extern "C" { #define VPD_CON_POS_RANGE 0xb9 /* sbc5r01 */ #define VPD_NOPE_WANT_STD_INQ -2 /* request for standard inquiry */ +/* vendor/product identifiers */ +#define VPD_VP_SEAGATE 0 +#define VPD_VP_RDAC 1 +#define VPD_VP_EMC 2 +#define VPD_VP_DDS 3 +#define VPD_VP_HP3PAR 4 +#define VPD_VP_IBM_LTO 5 +#define VPD_VP_HP_LTO 6 +#define VPD_VP_WDC_HITACHI 7 +#define VPD_VP_NVME 8 +#define VPD_VP_SG 9 /* this package/library as a vendor */ + + +/* vendor VPD pages */ +#define VPD_V_HIT_PG3 0x3 +#define VPD_V_HP3PAR 0xc0 +#define VPD_V_FIRM_SEA 0xc0 +#define VPD_V_UPR_EMC 0xc0 +#define VPD_V_HVER_RDAC 0xc0 +#define VPD_V_FVER_DDS 0xc0 +#define VPD_V_FVER_LTO 0xc0 +#define VPD_V_DCRL_LTO 0xc0 +#define VPD_V_DATC_SEA 0xc1 +#define VPD_V_FVER_RDAC 0xc1 +#define VPD_V_HVER_LTO 0xc1 +#define VPD_V_DSN_LTO 0xc1 +#define VPD_V_JUMP_SEA 0xc2 +#define VPD_V_SVER_RDAC 0xc2 +#define VPD_V_PCA_LTO 0xc2 +#define VPD_V_DEV_BEH_SEA 0xc3 +#define VPD_V_FEAT_RDAC 0xc3 +#define VPD_V_MECH_LTO 0xc3 +#define VPD_V_SUBS_RDAC 0xc4 +#define VPD_V_HEAD_LTO 0xc4 +#define VPD_V_ACI_LTO 0xc5 +#define VPD_V_DUCD_LTO 0xc7 +#define VPD_V_EDID_RDAC 0xc8 +#define VPD_V_MPDS_LTO 0xc8 +#define VPD_V_VAC_RDAC 0xc9 +#define VPD_V_RVSI_RDAC 0xca +#define VPD_V_SAID_RDAC 0xd0 +#define VPD_V_HIT_PG_D1 0xd1 +#define VPD_V_HIT_PG_D2 0xd2 + +#ifndef SG_NVME_VPD_NICR +#define SG_NVME_VPD_NICR 0xde /* NVME Identify Controller Response */ +#endif + +#define DEF_ALLOC_LEN 252 +#define MX_ALLOC_LEN (0xc000 + 0x80) +#define DEF_PT_TIMEOUT 60 /* 60 seconds */ + enum sg_vpd_invoker_e { SG_VPD_INV_NONE = 0, SG_VPD_INV_SG_INQ, @@ -126,6 +178,12 @@ struct svpd_values_name_t { const char * name; }; +struct svpd_vp_name_t { + int vend_prod_num; /* vendor/product identifier */ + const char * acron; + const char * name; +}; + typedef int (*recurse_vpd_decodep)(struct opts_t *, sgj_opaque_p jop, int off); @@ -202,6 +260,8 @@ extern const char * product_id_hr; extern const char * product_id_js; extern const char * product_rev_lev_hr; extern const char * product_rev_lev_js; +extern struct svpd_vp_name_t vp_arr[]; +extern struct svpd_values_name_t vendor_vpd_pg[]; #ifdef __cplusplus diff --git a/src/sg_vpd_vendor.c b/src/sg_vpd_vendor.c index 2f9dc10f..23df1442 100644 --- a/src/sg_vpd_vendor.c +++ b/src/sg_vpd_vendor.c @@ -100,86 +100,6 @@ #define DEF_ALLOC_LEN 252 #define MX_ALLOC_LEN (0xc000 + 0x80) - -struct svpd_vp_name_t { - int vend_prod_num; /* vendor/product identifier */ - const char * acron; - const char * name; -}; - - -/* Supported vendor specific VPD pages */ -/* Arrange in alphabetical order by acronym */ -static struct svpd_vp_name_t vp_arr[] = { - {VPD_VP_DDS, "dds", "DDS tape family from IBM"}, - {VPD_VP_EMC, "emc", "EMC (company)"}, - {VPD_VP_WDC_HITACHI, "hit", "WDC/Hitachi disk"}, - {VPD_VP_HP3PAR, "hp3par", "3PAR array (HP was Left Hand)"}, - {VPD_VP_HP_LTO, "hp_lto", "HP LTO tape/systems"}, - {VPD_VP_IBM_LTO, "ibm_lto", "IBM LTO tape/systems"}, - {VPD_VP_NVME, "nvme", "NVMe related"}, - {VPD_VP_RDAC, "rdac", "RDAC array (NetApp E-Series)"}, - {VPD_VP_SEAGATE, "sea", "Seagate disk"}, - {VPD_VP_SG, "sg", "sg3_utils extensions"}, - {VPD_VP_WDC_HITACHI, "wdc", "WDC/Hitachi disk"}, - {0, NULL, NULL}, -}; - -/* Supported vendor specific VPD pages */ -/* 'subvalue' holds vendor/product number to disambiguate */ -/* Arrange in alphabetical order by acronym */ -static struct svpd_values_name_t vendor_vpd_pg[] = { - {VPD_V_ACI_LTO, VPD_VP_HP_LTO, 1, "aci", "ACI revision level (HP LTO)"}, - {VPD_V_DATC_SEA, VPD_VP_SEAGATE, 0, "datc", "Date code (Seagate)"}, - {VPD_V_DCRL_LTO, VPD_VP_IBM_LTO, 1, "dcrl", "Drive component revision " - "levels (IBM LTO)"}, - {VPD_V_FVER_DDS, VPD_VP_DDS, 1, "ddsver", "Firmware revision (DDS)"}, - {VPD_V_DEV_BEH_SEA, VPD_VP_SEAGATE, 0, "devb", "Device behavior " - "(Seagate)"}, - {VPD_V_DSN_LTO, VPD_VP_IBM_LTO, 1, "dsn", "Drive serial numbers (IBM " - "LTO)"}, - {VPD_V_DUCD_LTO, VPD_VP_IBM_LTO, 1, "ducd", "Device unique " - "configuration data (IBM LTO)"}, - {VPD_V_EDID_RDAC, VPD_VP_RDAC, 0, "edid", "Extended device " - "identification (RDAC)"}, - {VPD_V_FIRM_SEA, VPD_VP_SEAGATE, 0, "firm", "Firmware numbers " - "(Seagate)"}, - {VPD_V_FVER_LTO, VPD_VP_HP_LTO, 0, "frl", "Firmware revision level " - "(HP LTO)"}, - {VPD_V_FVER_RDAC, VPD_VP_RDAC, 0, "fwr4", "Firmware version (RDAC)"}, - {VPD_V_HEAD_LTO, VPD_VP_HP_LTO, 1, "head", "Head Assy revision level " - "(HP LTO)"}, - {VPD_V_HP3PAR, VPD_VP_HP3PAR, 0, "hp3par", "Volume information " - "(HP/3PAR)"}, - {VPD_V_HVER_LTO, VPD_VP_HP_LTO, 1, "hrl", "Hardware revision level " - "(HP LTO)"}, - {VPD_V_HVER_RDAC, VPD_VP_RDAC, 0, "hwr4", "Hardware version (RDAC)"}, - {VPD_V_JUMP_SEA, VPD_VP_SEAGATE, 0, "jump", "Jump setting (Seagate)"}, - {VPD_V_MECH_LTO, VPD_VP_HP_LTO, 1, "mech", "Mechanism revision level " - "(HP LTO)"}, - {VPD_V_MPDS_LTO, VPD_VP_IBM_LTO, 1, "mpds", "Mode parameter default " - "settings (IBM LTO)"}, - {SG_NVME_VPD_NICR, VPD_VP_SG, 0, "nicr", - "NVMe Identify Controller Response (sg3_utils)"}, - {VPD_V_PCA_LTO, VPD_VP_HP_LTO, 1, "pca", "PCA revision level (HP LTO)"}, - {VPD_V_FEAT_RDAC, VPD_VP_RDAC, 0, "prm4", "Feature Parameters (RDAC)"}, - {VPD_V_RVSI_RDAC, VPD_VP_RDAC, 0, "rvsi", "Replicated volume source " - "identifier (RDAC)"}, - {VPD_V_SAID_RDAC, VPD_VP_RDAC, 0, "said", "Storage array world wide " - "name (RDAC)"}, - {VPD_V_SUBS_RDAC, VPD_VP_RDAC, 0, "subs", "Subsystem identifier (RDAC)"}, - {VPD_V_SVER_RDAC, VPD_VP_RDAC, 0, "swr4", "Software version (RDAC)"}, - {VPD_V_UPR_EMC, VPD_VP_EMC, 0, "upr", "Unit path report (EMC)"}, - {VPD_V_VAC_RDAC, VPD_VP_RDAC, 0, "vac1", "Volume access control (RDAC)"}, - {VPD_V_HIT_PG3, VPD_VP_WDC_HITACHI, 0, "wp3", "Page 0x3 (WDC/Hitachi)"}, - {VPD_V_HIT_PG_D1, VPD_VP_WDC_HITACHI, 0, "wpd1", - "Page 0xd1 (WDC/Hitachi)"}, - {VPD_V_HIT_PG_D2, VPD_VP_WDC_HITACHI, 0, "wpd2", - "Page 0xd2 (WDC/Hitachi)"}, - {0, 0, 0, NULL, NULL}, -}; - - void dup_sanity_chk(int sz_opts_t, int sz_values_name_t) { @@ -260,22 +180,6 @@ svpd_find_vendor_by_num(int page_num, int vend_prod_num) return NULL; } - -int -svpd_find_vp_num_by_acron(const char * vp_ap) -{ - size_t len; - const struct svpd_vp_name_t * vpp; - - for (vpp = vp_arr; vpp->acron; ++vpp) { - len = strlen(vpp->acron); - if (0 == strncmp(vpp->acron, vp_ap, len)) - return vpp->vend_prod_num; - } - return -1; -} - - const struct svpd_values_name_t * svpd_find_vendor_by_acron(const char * ap) { @@ -288,43 +192,6 @@ svpd_find_vendor_by_acron(const char * ap) return NULL; } -/* if vend_prod_num < -1 then list vendor_product ids + vendor pages, =-1 - * list only vendor_product ids, else list pages for that vend_prod_num */ -void -svpd_enumerate_vendor(int vend_prod_num) -{ - bool seen; - const struct svpd_vp_name_t * vpp; - const struct svpd_values_name_t * vnp; - - if (vend_prod_num < 0) { - for (seen = false, vpp = vp_arr; vpp->acron; ++vpp) { - if (vpp->name) { - if (! seen) { - printf("\nVendor/product identifiers:\n"); - seen = true; - } - printf(" %-10s %d %s\n", vpp->acron, - vpp->vend_prod_num, vpp->name); - } - } - } - if (-1 == vend_prod_num) - return; - for (seen = false, vnp = vendor_vpd_pg; vnp->acron; ++vnp) { - if ((vend_prod_num >= 0) && (vend_prod_num != vnp->subvalue)) - continue; - if (vnp->name) { - if (! seen) { - printf("\nVendor specific VPD pages:\n"); - seen = true; - } - printf(" %-10s 0x%02x,%d %s\n", vnp->acron, - vnp->value, vnp->subvalue, vnp->name); - } - } -} - int svpd_count_vendor_vpds(int vpd_pn, int vend_prod_num) { diff --git a/src/sg_write_same.c b/src/sg_write_same.c index 011deb99..bfdf8159 100644 --- a/src/sg_write_same.c +++ b/src/sg_write_same.c @@ -169,8 +169,8 @@ do_write_same(int sg_fd, const struct opts_t * op, const void * dataoutp, { int ret, res, sense_cat, cdb_len; uint64_t llba; - uint8_t ws_cdb[WRITE_SAME32_LEN] = {0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t ws_cdb[WRITE_SAME32_LEN] SG_C_CPP_ZERO_INIT; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; cdb_len = op->pref_cdb_size; diff --git a/src/sg_write_verify.c b/src/sg_write_verify.c index e2af4019..ee6b12bf 100644 --- a/src/sg_write_verify.c +++ b/src/sg_write_verify.c @@ -129,7 +129,7 @@ run_scsi_transaction(int sg_fd, const uint8_t *cdbp, int cdb_len, { int res, sense_cat, ret; struct sg_pt_base * ptvp; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; char b[32]; snprintf(b, sizeof(b), "Write and verify(%d)", cdb_len); diff --git a/src/sg_write_x.c b/src/sg_write_x.c index b7c34f75..89c91258 100644 --- a/src/sg_write_x.c +++ b/src/sg_write_x.c @@ -1053,7 +1053,7 @@ do_write_x(int sg_fd, const void * dataoutp, int dout_len, { int k, ret, res, sense_cat, cdb_len, vb, err; uint8_t x_cdb[WRITE_X_32_LEN]; /* use for both lengths */ - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_pt_base * ptvp; memset(x_cdb, 0, sizeof(x_cdb)); @@ -2197,7 +2197,7 @@ main(int argc, char * argv[]) uint64_t addr_arr[MAX_NUM_ADDR]; uint32_t num_arr[MAX_NUM_ADDR]; struct stat if_stat, sf_stat; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; op = &opts; memset(&if_stat, 0, sizeof(if_stat)); diff --git a/src/sg_z_act_query.c b/src/sg_z_act_query.c index f0e0688f..372c27c9 100644 --- a/src/sg_z_act_query.c +++ b/src/sg_z_act_query.c @@ -142,7 +142,7 @@ sg_ll_zone_act_query(int sg_fd, const struct opts_t * op, void * resp, struct sg_pt_base * ptvp; uint8_t zi_cdb[SG_ZBC_IN_CMDLEN] = {SG_ZBC_IN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; char b[64]; zi_cdb[1] = 0x1f & sa; @@ -365,7 +365,7 @@ main(int argc, char * argv[]) uint8_t * free_zibp = NULL; const char * sa_name; char b[80]; - struct opts_t opts = {0}; + struct opts_t opts SG_C_CPP_ZERO_INIT; struct opts_t * op = &opts; while (1) { diff --git a/src/sg_zone.c b/src/sg_zone.c index e4540143..6da6d0ac 100644 --- a/src/sg_zone.c +++ b/src/sg_zone.c @@ -137,7 +137,7 @@ sg_ll_zone_out(int sg_fd, int sa, uint64_t zid, uint16_t zc, bool all, struct sg_pt_base * ptvp; uint8_t zo_cdb[SG_ZONING_OUT_CMDLEN] = {SG_ZONING_OUT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; char b[64]; zo_cdb[1] = 0x1f & sa; diff --git a/src/sginfo.c b/src/sginfo.c index 0fb85904..0937e689 100644 --- a/src/sginfo.c +++ b/src/sginfo.c @@ -393,7 +393,7 @@ struct scsi_cmnd_io static int do_scsi_io(struct scsi_cmnd_io * sio) { - uint8_t sense_b[SENSE_BUFF_LEN] = {0}; + uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; struct sg_scsi_sense_hdr ssh; int res; diff --git a/src/sgm_dd.c b/src/sgm_dd.c index aa656b39..d85a6fa2 100644 --- a/src/sgm_dd.c +++ b/src/sgm_dd.c @@ -473,7 +473,7 @@ sg_read(int sg_fd, uint8_t * buff, int blocks, int64_t from_block, bool print_cdb_after = false; int res; uint8_t rdCmd[MAX_SCSI_CDBSZ]; - uint8_t senseBuff[SENSE_BUFF_LEN] = {0}; + uint8_t senseBuff[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; struct sg_io_hdr io_hdr; if (sg_build_scsi_cdb(rdCmd, cdbsz, blocks, from_block, false, fua, @@ -570,8 +570,8 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block, bool print_cdb_after = false; int res; uint8_t wrCmd[MAX_SCSI_CDBSZ]; - uint8_t senseBuff[SENSE_BUFF_LEN] = {0}; - struct sg_io_hdr io_hdr; + uint8_t senseBuff[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT; + struct sg_io_hdr io_hdr SG_C_CPP_ZERO_INIT; if (sg_build_scsi_cdb(wrCmd, cdbsz, blocks, to_block, true, fua, dpo)) { pr2serr(ME "bad wr cdb build, to_block=%" PRId64 ", blocks=%d\n", @@ -579,7 +579,6 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block, return SG_LIB_SYNTAX_ERROR; } - memset(&io_hdr, 0, sizeof(struct sg_io_hdr)); io_hdr.interface_id = 'S'; io_hdr.cmd_len = cdbsz; io_hdr.cmdp = wrCmd; |