aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-07-29 15:09:18 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-07-29 15:09:18 +0000
commit640f7a7eff809159d9ac4c3ffc3681a6a5c3bede (patch)
treeb889f3d3a995b9ed8eed68a3bd83c75a484df174
parentaac31a343f55c0b40b7d46ba453201fff3430acb (diff)
downloadsg3_utils-640f7a7eff809159d9ac4c3ffc3681a6a5c3bede.tar.gz
cleanup warning and C++20 building issues
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@963 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog2
-rw-r--r--doc/sg_inq.813
-rw-r--r--doc/sg_vpd.88
-rw-r--r--src/sg_dd.c8
-rw-r--r--src/sg_decode_sense.c5
-rw-r--r--src/sg_get_elem_status.c6
-rw-r--r--src/sg_get_lba_status.c20
-rw-r--r--src/sg_inq.c50
-rw-r--r--src/sg_logs.c22
-rw-r--r--src/sg_vpd.c60
-rw-r--r--src/sg_vpd_common.c94
-rw-r--r--src/sg_vpd_common.h2
-rw-r--r--src/sg_z_act_query.c6
-rw-r--r--src/sgp_dd.c4
14 files changed, 170 insertions, 130 deletions
diff --git a/ChangeLog b/ChangeLog
index 8186547f..9e981394 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for pre-release sg3_utils-1.48 [20220727] [svn: r962]
+Changelog for pre-release sg3_utils-1.48 [20220728] [svn: r963]
- some utilities: add experimental --json[=JO] option
- sg_z_act_query: new utility for sending either a
Zone activate or Zone query command
diff --git a/doc/sg_inq.8 b/doc/sg_inq.8
index a7b4ef9f..0f02d2a3 100644
--- a/doc/sg_inq.8
+++ b/doc/sg_inq.8
@@ -39,8 +39,11 @@ options.
An important "non\-standard" INQUIRY page is the Device Identification
Vital Product Data (VPD) page [0x83]. Since SPC\-3, support for this page
is mandatory. The \fI\-\-id\fR option decodes this page. New VPD page
-information is no longer being added to this utility. To get information
-on new VPD pages see the sg_vpd(8) or sdparm(8) utilities.
+information is no longer being added to this utility. The sg_vpd(8) utility
+is specialized for decoding VPD pages and shares code with this utility for
+that purpose. The sdparm(8) utility which is in a package of that name also
+decodes VPD pages although its major purpose is to access and modify SCSI
+mode pages.
.PP
In Linux, if the \fIDEVICE\fR exists and the SCSI INQUIRY fails (e.g. because
the SG_IO ioctl is not supported) then an ATA IDENTIFY (PACKET) DEVICE is
@@ -239,8 +242,7 @@ print out version string then exit.
set the Enable Vital Product Data (EVPD) bit (defaults to clear(0)). Used in
conjunction with the \fI\-\-page=PG\fR option where \fIPG\fR specifies the
VPD page number to query. If the \fI\-\-page=PG\fR is not given then \fIPG\fR
-defaults to zero which is the "Supported VPD pages" VPD page. A more up to
-date decoding of VPD pages can be found in the sg_vpd(8) utility.
+defaults to zero which is the "Supported VPD pages" VPD page.
.SH NOTES
Some devices with weak SCSI command set implementations lock up when they
receive commands they don't understand (and some lock up if they receive
@@ -335,8 +337,7 @@ get the controller's Identify decoded use the \fI\-\-only\fR option.
.PP
It is possible that even though the \fIDEVICE\fR presents as a NVMe device,
it has a SNTL and accepts SCSI commands. In this case to send a SCSI INQUIRY
-command (and fetch its VPD pages) use 'sg_vpd \-p sinq <dev>' (or to get VPD
-pages: 'sg_vpd \-p <vpd_page> <dev>').
+command (and fetch its VPD pages) use the sg_vpd(8) utility.
.SH EXIT STATUS
The exit status of sg_inq is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
diff --git a/doc/sg_vpd.8 b/doc/sg_vpd.8
index 842114ea..7f681604 100644
--- a/doc/sg_vpd.8
+++ b/doc/sg_vpd.8
@@ -136,7 +136,7 @@ command is sent with a larger value in the cdb's "allocation length" field.
If this option is given and \fILEN\fR is greater than 0 then only one INQUIRY
command is sent. Since many simple devices implement the INQUIRY command
badly (and do not support VPD pages) then the safest value to use for
-\fILEN\fR is 36. See the sg_inq man page for the more information.
+\fILEN\fR is 36. See the sg_inq(8) man page for the more information.
.TP
\fB\-p\fR, \fB\-\-page\fR=\fIPG\fR
where \fIPG\fR is the VPD page to be decoded or output. The \fIPG\fR argument
@@ -210,12 +210,6 @@ the decoding of some fields (e.g. the Extended INQUIRY page's SPT field)
is expanded when the '\-\-long' option is given using the standard INQUIRY
response information (e.g. the PDT and the PROTECT fields).
.PP
-In the 2.4 series of Linux kernels the \fIDEVICE\fR must be
-a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks
-and ATAPI DVDs) can also be specified. For example "sg_inq /dev/sda"
-will work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char"
-device names may be used as well (e.g. "/dev/st0m").
-.PP
The \fIDEVICE\fR is opened with a read\-only flag (e.g. in Unix with the
O_RDONLY flag).
.SH EXIT STATUS
diff --git a/src/sg_dd.c b/src/sg_dd.c
index 10ede6fd..9e0b6931 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -70,7 +70,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "6.33 20220418";
+static const char * version_str = "6.34 20220729";
#define ME "sg_dd: "
@@ -2420,21 +2420,21 @@ main(int argc, char * argv[])
else if (iflag.ff)
memset(wrkPos, 0xff, res);
else {
- int kk, j;
+ int kk, jj;
const int jbump = sizeof(uint32_t);
long rn;
uint8_t * bp;
bp = wrkPos;
for (kk = 0; kk < blocks; ++kk, bp += blk_sz) {
- for (j = 0; j < blk_sz; j += jbump) {
+ for (jj = 0; jj < blk_sz; jj += jbump) {
/* mrand48 takes uniformly from [-2^31, 2^31) */
#ifdef HAVE_SRAND48_R
mrand48_r(&drand, &rn);
#else
rn = mrand48();
#endif
- *((uint32_t *)(bp + j)) = (uint32_t)rn;
+ *((uint32_t *)(bp + jj)) = (uint32_t)rn;
}
}
}
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index 63e2ab26..e902d0a6 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -30,7 +30,7 @@
#include "sg_unaligned.h"
-static const char * version_str = "1.30 20220717";
+static const char * version_str = "1.31 20220729";
#define MY_NAME "sg_decode_sense"
@@ -478,8 +478,7 @@ main(int argc, char *argv[])
else if (op->hex_count)
dStrHexFp((const char *)op->sense, op->sense_len, 0, fp);
else {
- size_t s = fwrite(op->sense, 1, op->sense_len, fp);
-
+ s = fwrite(op->sense, 1, op->sense_len, fp);
if ((int)s != op->sense_len)
pr2serr("only able to write %d of %d bytes to %s\n",
(int)s, op->sense_len, op->wfname);
diff --git a/src/sg_get_elem_status.c b/src/sg_get_elem_status.c
index f7f06a1f..1aab2244 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.13 20220717"; /* sbc5r02 */
+static const char * version_str = "1.14 20220729"; /* sbc5r03 */
#define MY_NAME "sg_get_elem_status"
@@ -302,7 +302,7 @@ main(int argc, char * argv[])
struct gpes_desc_t a_ped;
sgj_state json_st = {0};
sgj_state * jsp = &json_st;
- char b[64];
+ char b[80];
static const int blen = sizeof(b);
while (1) {
@@ -629,8 +629,6 @@ error:
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
pr2serr("Get LBA Status command: bad field in cdb\n");
else {
- char b[80];
-
sg_get_category_sense_str(res, sizeof(b), b, verbose);
pr2serr("Get LBA Status command: %s\n", b);
}
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 4ed45c81..3acf07b0 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.29 20220717"; /* sbc5r01 */
+static const char * version_str = "1.30 20220729"; /* sbc5r01 */
#define MY_NAME "sg_get_lba_status"
@@ -629,7 +629,7 @@ start_response:
sgj_js_nv_istr(jsp, jo2p, add_stat_s, add_status, NULL,
get_pr_status_str(add_status, b, blen));
} else {
- char c[64];
+ char d[64];
n = 0;
n += sg_scnpr(b + n, blen - n, "[%d] LBA: 0x", k + 1);
@@ -637,16 +637,16 @@ start_response:
n += sg_scnpr(b + n, blen - n, "%02x", bp[j]);
if (1 == (blockhex % 2)) {
- snprintf(c, sizeof(c), "0x%x", d_blocks);
- n += sg_scnpr(b + n, blen - n, " blocks: %10s", c);
+ snprintf(d, sizeof(d), "0x%x", d_blocks);
+ n += sg_scnpr(b + n, blen - n, " blocks: %10s", d);
} else
n += sg_scnpr(b + n, blen - n, " blocks: %10u",
(unsigned int)d_blocks);
- get_prov_status_str(res, c, sizeof(c));
- n += sg_scnpr(b + n, blen - n, " %s", c);
- get_pr_status_str(add_status, c, sizeof(c));
- if (strlen(c) > 0)
- n += sg_scnpr(b + n, blen - n, " [%s]", c);
+ get_prov_status_str(res, d, sizeof(d));
+ n += sg_scnpr(b + n, blen - n, " %s", d);
+ get_pr_status_str(add_status, d, sizeof(d));
+ if (strlen(d) > 0)
+ n += sg_scnpr(b + n, blen - n, " [%s]", d);
sgj_pr_hr(jsp, "%s\n", b);
}
}
@@ -663,8 +663,6 @@ error:
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
pr2serr("Get LBA Status command: bad field in cdb\n");
else {
- char b[80];
-
sg_get_category_sense_str(res, sizeof(b), b, verbose);
pr2serr("Get LBA Status command: %s\n", b);
}
diff --git a/src/sg_inq.c b/src/sg_inq.c
index c35e9343..001970f2 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.24 20220727"; /* spc6r06 */
+static const char * version_str = "2.26 20220729"; /* spc6r06 */
#define MY_NAME "sg_inq"
@@ -2390,7 +2390,7 @@ std_inq_decode(struct opts_t * op, sgj_opaque_p jop, int off)
}
pqual = (rp[0] & 0xe0) >> 5;
if (! op->do_raw && ! op->do_export) {
- snprintf(b, blen, "standard INQUIRY:");
+ strcpy(b, "standard INQUIRY:");
if (0 == pqual)
sgj_pr_hr(jsp, "%s\n", b);
else if (1 == pqual)
@@ -2997,9 +2997,7 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off)
sgj_opaque_p jap = NULL;
const char * np;
const char * ep = "";
- // const char * pdt_str;
uint8_t * rp;
- // char d[80];
rp = rsp_buff + off;
vb = op->verbose;
@@ -3297,8 +3295,8 @@ vpd_decode(int sg_fd, struct opts_t * op, sgj_opaque_p jop, int off)
bool bl = false;
bool sad = false;
bool oi = false;
- const char * ep = "";
+ ep = "";
if (op->do_raw) {
dStrRaw((const char *)rp, len);
break;
@@ -3658,11 +3656,45 @@ xxxxx
pr2serr("VPD INQUIRY: page=0xb8\n");
break;
case 0xb9:
-// yyyyyyyy
- bad = true;
- pr2serr("Please try the sg_vpd utility which decodes more VPD "
- "pages\n\n");
+ res = vpd_fetch_page_from_dev(sg_fd, rp, pn, op->maxlen, vb, &len);
+ if (0 == res) {
+ bool cpr = false;
+
+ if (op->do_raw) {
+ dStrRaw((const char *)rp, len);
+ break;
+ }
+ pdt = rp[0] & PDT_MASK;
+ switch (pdt) {
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_ZBC:
+ np = "Concurrent positioning LBAs VPD page";
+ ep = "(SBC)";
+ cpr = true;
+ break;
+ default:
+ np = NULL;
+ break;
+ }
+ if (op->do_hex < 2) {
+ if (NULL == np)
+ sgj_pr_hr(jsp, "VPD page=0x%x, pdt=0x%x:\n", pn, pdt);
+ else
+ sgj_pr_hr(jsp, "VPD INQUIRY: %s %s\n", np, ep);
+ }
+ if (as_json) {
+ jo2p = sg_vpd_js_hdr(jsp, jop, np, rp);
+ jap = sgj_named_subarray_r(jsp, jo2p, "lba_range_"
+ "descriptor_list");
+ }
+ if (cpr)
+ decode_con_pos_range_vpd(rp, len, op, jap);
+ else
+ return vpd_mainly_hex(sg_fd, op, NULL, off);
+ return 0;
+ } else if (! op->do_raw)
+ pr2serr("VPD INQUIRY: page=0xb8\n");
break;
+// yyyyyyyy
case VPD_UPR_EMC: /* 0xc0 */
if (!op->do_raw && (op->do_hex < 2))
printf("VPD INQUIRY: Unit Path Report Page (EMC)\n");
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 358b7222..66665b4a 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -37,7 +37,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.98 20220310"; /* spc6r06 + sbc5r01 */
+static const char * version_str = "1.99 20220729"; /* spc6r06 + sbc5r01 */
#define MX_ALLOC_LEN (0xfffc)
#define MX_INLEN_ALLOC_LEN (0x800000)
@@ -2804,16 +2804,16 @@ show_last_n_inq_data_ch_page(const uint8_t * resp, int len,
int vpd = *(bp + 5);
printf("VPD page 0x%x changed\n", vpd);
if (0 == op->do_brief) {
- int k;
- const int num = sg_lib_names_mode_len;
+ int m;
+ const int nn = sg_lib_names_mode_len;
struct sg_lib_simple_value_name_t * nvp =
sg_lib_names_vpd_arr;
- for (k = 0; k < num; ++k, ++nvp) {
+ for (m = 0; m < nn; ++m, ++nvp) {
if (nvp->value == vpd)
break;
}
- if (k < num)
+ if (m < nn)
printf(" name: %s\n", nvp->name);
}
} else
@@ -2877,16 +2877,16 @@ show_last_n_mode_pg_data_ch_page(const uint8_t * resp, int len,
printf("mode page 0x%x changed\n", pg_code);
if (0 == op->do_brief) {
int k;
- const int num = sg_lib_names_mode_len;
int val = (pg_code << 8) | spg_code;
+ const int nn = sg_lib_names_mode_len;
struct sg_lib_simple_value_name_t * nmp =
sg_lib_names_mode_arr;
- for (k = 0; k < num; ++k, ++nmp) {
+ for (k = 0; k < nn; ++k, ++nmp) {
if (nmp->value == val)
break;
}
- if (k < num)
+ if (k < nn)
printf(" name: %s\n", nmp->name);
}
}
@@ -3220,10 +3220,8 @@ show_app_client_page(const uint8_t * resp, int len, const struct opts_t * op)
if (op->do_raw) {
dStrRaw(bp, extra);
break;
- } else if (0 == op->do_hex)
- hex2stdout(bp, extra, op->dstrhex_no_ascii);
- else
- hex2stdout(bp, extra, op->dstrhex_no_ascii);
+ }
+ hex2stdout(bp, extra, op->dstrhex_no_ascii);
printf("\n");
if (op->do_pcb)
printf(" <%s>\n", get_pcb_str(bp[2], str, sizeof(str)));
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 74a2bd95..a0bf5036 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -42,7 +42,7 @@
*/
-static const char * version_str = "1.78 20220727"; /* spc6r06 + sbc5r01 */
+static const char * version_str = "1.78 20220729"; /* spc6r06 + sbc5r01 */
#define MY_NAME "sg_vpd"
@@ -1838,35 +1838,6 @@ decode_format_presets_vpd(uint8_t * buff, int len, int do_hex)
}
#endif
-/* VPD_CON_POS_RANGE 0xb9 (added sbc5r01) */
-static void
-decode_con_pos_range_vpd(uint8_t * buff, int len, int do_hex)
-{
- int k;
- uint64_t u;
- uint8_t * bp;
-
- if (do_hex) {
- hex2stdout(buff, len, (1 == do_hex) ? 0 : -1);
- return;
- }
- if (len < 64) {
- pr2serr("Concurrent position ranges VPD page length too short=%d\n",
- len);
- return;
- }
- len -= 64;
- bp = buff + 64;
- for (k = 0; k < len; k += 32, bp += 32) {
- printf(" LBA range number: %u\n", bp[0]);
- printf(" number of storage elements: %u\n", bp[1]);
- printf(" starting LBA: 0x%" PRIx64 "\n",
- sg_get_unaligned_be64(bp + 8));
- u = sg_get_unaligned_be64(bp + 16);
- printf(" number of LBAs: 0x%" PRIx64 " [%" PRIu64 "]\n", u, u);
- }
-}
-
/* Returns 0 if successful */
static int
svpd_unable_to_decode(int sg_fd, struct opts_t * op, int subvalue, int off)
@@ -2836,7 +2807,7 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop,
jap = sgj_named_subarray_r(jsp, jo2p, "format_preset_"
"descriptor_list");
}
- if (fp)
+ if (fp)
decode_format_presets_vpd(rp, len, op, jap);
else
return SG_LIB_CAT_OTHER;
@@ -2849,30 +2820,43 @@ svpd_decode_t10(int sg_fd, struct opts_t * op, sgj_opaque_p jop,
case 0xb9: /* VPD_CON_POS_RANGE */
res = vpd_fetch_page(sg_fd, rp, pn, op->maxlen, qt, vb, &len);
if (0 == res) {
+ bool cpr = false; /* ["cpr"] */
+
+ pdt = rp[0] & PDT_MASK;
switch (pdt) {
case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_ZBC:
- np = "Concurrent positioning ranges VPD page (SBC):";
+ np = "Concurrent positioning ranges VPD page";
+ ep = "(SBC)";
+ cpr = true;
break;
default:
np = NULL;
break;
}
if (NULL == np)
- printf("VPD page=0x%x, pdt=0x%x:\n", pn, pdt);
+ sgj_pr_hr(jsp, "VPD page=0x%x, pdt=0x%x:\n", pn, pdt);
else if (allow_name || allow_if_found)
- printf("%s%s\n", pre, np);
+ sgj_pr_hr(jsp, "%s%s %s:\n", pre, np, ep ? ep : "");
if (op->do_raw)
dStrRaw(rp, len);
else {
if (vb || long_notquiet)
- printf(" [PQual=%d Peripheral device type: %s]\n",
- pqual, pdt_str);
- decode_con_pos_range_vpd(rp, len, op->do_hex);
+ sgj_pr_hr(jsp, " [PQual=%d Peripheral device type: "
+ "%s]\n", pqual, pdt_str);
+ if (as_json) {
+ jo2p = sg_vpd_js_hdr(jsp, jop, np, rp);
+ jap = sgj_named_subarray_r(jsp, jo2p, "lba_range_"
+ "descriptor_list");
+ }
+ if (cpr)
+ decode_con_pos_range_vpd(rp, len, op, jap);
+ else
+ return SG_LIB_CAT_OTHER;
}
return 0;
} else if ((! op->do_raw) && (! op->do_quiet) && (op->do_hex < 3) &&
(0 == op->examine))
- printf("%sVPD page=0xb7\n", pre);
+ printf("%sVPD page=0xb8\n", pre);
break;
default:
return SG_LIB_CAT_OTHER;
diff --git a/src/sg_vpd_common.c b/src/sg_vpd_common.c
index c7943f45..9497de3d 100644
--- a/src/sg_vpd_common.c
+++ b/src/sg_vpd_common.c
@@ -15,6 +15,7 @@
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
+#include <assert.h>
#include <getopt.h>
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
@@ -1291,7 +1292,6 @@ decode_block_dev_ch_vpd(const uint8_t * buff, int len, struct opts_t * op,
sgj_state * jsp = &op->json_st;
const char * cp;
char b[144];
- static const int blen = sizeof(b);
static const char * mrr_j = "medium_rotation_rate";
static const char * mrr_h = "Medium rotation rate";
static const char * nrm = "Non-rotating medium (e.g. solid state)";
@@ -1334,32 +1334,31 @@ decode_block_dev_ch_vpd(const uint8_t * buff, int len, struct opts_t * op,
u = buff[7] & 0xf;
switch (u) {
case 0:
- snprintf(b, blen, nr_s);
+ strcpy(b, nr_s);
break;
case 1:
- snprintf(b, blen, "5.25 inch");
+ strcpy(b, "5.25 inch");
break;
case 2:
- snprintf(b, blen, "3.5 inch");
+ strcpy(b, "3.5 inch");
break;
case 3:
- snprintf(b, blen, "2.5 inch");
+ strcpy(b, "2.5 inch");
break;
case 4:
- snprintf(b, blen, "1.8 inch");
+ strcpy(b, "1.8 inch");
break;
case 5:
- snprintf(b, blen, "less then 1.8 inch");
+ strcpy(b, "less then 1.8 inch");
break;
default:
- snprintf(b, blen, rsv_s);
+ strcpy(b, rsv_s);
break;
}
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");
- printf(" MACT=%d\n", !!(buff[8] & 0x40)); /* added sbc5r01 */
zoned = (buff[8] >> 4) & 0x3; /* added sbc4r04, obsolete sbc5r01 */
cp = bdc_zoned_strs[zoned];
sgj_pr_hr(jsp, " ZONED=%d [%s]\n", zoned, cp);
@@ -1440,13 +1439,13 @@ decode_block_lb_prov_vpd(uint8_t * buff, int len, struct opts_t * op,
pt = buff[6] & 0x7;
cp = prov_type_arr[pt];
if (pt > 2)
- snprintf(b, blen, " [%u]]", u);
+ snprintf(b, blen, " [%u]", u);
else
b[0] = '\0';
sgj_pr_hr(jsp, " Provisioning type: %s%s\n", cp, b);
sgj_js_nv_ihexstr(jsp, jop, "provisioning_type", pt, NULL, cp);
u = buff[7]; /* threshold percentage */
- snprintf(b, blen, "%s ", tp);
+ strcpy(b, tp);
if (0 == u)
sgj_pr_hr(jsp, " %s: 0 [percentages %s]\n", b, ns_s);
else
@@ -1493,7 +1492,7 @@ decode_referrals_vpd(uint8_t * buff, int len, struct opts_t * op,
return;
}
u = sg_get_unaligned_be32(buff + 8);
- snprintf(b, sizeof(b), " User data segment size: ");
+ strcpy(b, " User data segment size: ");
if (0 == u)
sgj_pr_hr(jsp, "%s0 [per sense descriptor]\n", b);
else
@@ -1669,23 +1668,23 @@ decode_zbdch_vpd(uint8_t * buff, int len, struct opts_t * op,
sgj_pr_hr(jsp, " Peripheral device type: %s\n",
sg_get_pdt_str(pdt, blen, b));
- printf(" Zoned block device extension: ");
+ sgj_pr_hr(jsp, " Zoned block device extension: ");
u = (buff[4] >> 4) & 0xf;
switch (u) {
case 0:
if (PDT_ZBC == (PDT_MASK & buff[0]))
- snprintf(b, blen, "host managed zoned block device");
+ strcpy(b, "host managed zoned block device");
else
- snprintf(b, blen, "%s", nr_s);
+ strcpy(b, nr_s);
break;
case 1:
- snprintf(b, blen, "host aware zoned block device model");
+ strcpy(b, "host aware zoned block device model");
break;
case 2:
- snprintf(b, blen, "Domains and realms zoned block device model");
+ strcpy(b, "Domains and realms zoned block device model");
break;
default:
- snprintf(b, blen, "%s", rsv_s);
+ strcpy(b, rsv_s);
break;
}
sgj_hr_js_vistr(jsp, jop, 2, "Zoned block device extension",
@@ -1712,18 +1711,17 @@ decode_zbdch_vpd(uint8_t * buff, int len, struct opts_t * op,
u = buff[23] & 0xf;
switch (u) {
case 0:
- snprintf(b, blen, "not reported\n");
+ strcpy(b, nr_s);
break;
case 1:
- snprintf(b, blen, "Zoned starting LBAs aligned using constant zone "
- "lengths");
+ strcpy(b, "Zoned starting LBAs aligned using constant zone lengths");
break;
case 0x8:
- snprintf(b, blen, "Zoned starting LBAs potentially non-constant (as "
+ strcpy(b, "Zoned starting LBAs potentially non-constant (as "
"reported by REPORT ZONES)");
break;
default:
- snprintf(b, blen, "%s", rsv_s);
+ strcpy(b, rsv_s);
break;
}
sgj_hr_js_vistr(jsp, jop, 2, "Zoned alignment method",
@@ -1792,18 +1790,19 @@ static const char * sch_type_arr[8] = {
static char *
get_zone_align_method(uint8_t val, char * b, int blen)
{
+ assert(blen > 32);
switch (val) {
case 0:
- snprintf(b, blen, "%s", nr_s);
+ strcpy(b, nr_s);
break;
case 1:
- snprintf(b, blen, "%s", "using constant zone lengths");
+ strcpy(b, "using constant zone lengths");
break;
case 8:
- snprintf(b, blen, "%s", "taking gap zones into account");
+ strcpy(b, "taking gap zones into account");
break;
default:
- snprintf(b, blen, "%s", rsv_s);
+ strcpy(b, rsv_s);
break;
}
return b;
@@ -1852,7 +1851,7 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op,
else
snprintf(b, blen, "%s", cp);
} else
- snprintf(b, blen, "%s", rsv_s);
+ 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 "
@@ -1906,7 +1905,7 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op,
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, b, blen));
+ 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,
@@ -1961,3 +1960,40 @@ decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op,
sgj_js_nv_o(jsp, jap, NULL /* name */, jo2p);
}
}
+
+/* VPD_CON_POS_RANGE 0xb9 (added sbc5r01) */
+void
+decode_con_pos_range_vpd(uint8_t * buff, int len, struct opts_t * op,
+ sgj_opaque_p jap)
+{
+ int k;
+ uint32_t u;
+ sgj_state * jsp = &op->json_st;
+ uint8_t * bp;
+ sgj_opaque_p jo2p;
+
+ if (op->do_hex) {
+ hex2stdout(buff, len, (1 == op->do_hex) ? 0 : -1);
+ return;
+ }
+ if (len < 64) {
+ pr2serr("VPD page length too short=%d\n", len);
+ return;
+ }
+ len -= 64;
+ 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);
+ 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_js_nv_o(jsp, jap, NULL /* name */, jo2p);
+ }
+}
diff --git a/src/sg_vpd_common.h b/src/sg_vpd_common.h
index 0571ece1..73233524 100644
--- a/src/sg_vpd_common.h
+++ b/src/sg_vpd_common.h
@@ -172,6 +172,8 @@ void decode_block_limits_ext_vpd(uint8_t * buff, int len, struct opts_t * op,
sgj_opaque_p jop);
void decode_format_presets_vpd(uint8_t * buff, int len, struct opts_t * op,
sgj_opaque_p jap);
+void decode_con_pos_range_vpd(uint8_t * buff, int len, struct opts_t * op,
+ sgj_opaque_p jap);
const char * pqual_str(int pqual);
void svpd_enumerate_vendor(int vend_prod_num);
diff --git a/src/sg_z_act_query.c b/src/sg_z_act_query.c
index cd347820..f0e0688f 100644
--- a/src/sg_z_act_query.c
+++ b/src/sg_z_act_query.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2021 Douglas Gilbert.
+ * Copyright (c) 2014-2022 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -38,7 +38,7 @@
* command to the given SCSI device. Based on zbc2r12.pdf .
*/
-static const char * version_str = "1.03 20211217";
+static const char * version_str = "1.04 20220729";
#define SG_ZBC_IN_CMDLEN 16
#define Z_ACTIVATE_SA 0x8
@@ -556,8 +556,6 @@ main(int argc, char * argv[])
if (SG_LIB_CAT_INVALID_OP == res)
pr2serr("%s command not supported\n", sa_name);
else {
- char b[80];
-
sg_get_category_sense_str(res, sizeof(b), b, verbose);
pr2serr("%s command: %s\n", sa_name, b);
}
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index a36d9d03..e88f3330 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -390,9 +390,9 @@ tsafe_strerror(int code, char * ebp)
* ISBN 0-201-63392-2 . [Highly recommended book.] Changed __FILE__
* to __func__ */
#define err_exit(code,text) do { \
- char strerr_buff[STRERR_BUFF_LEN + 1]; \
+ char _strerr_buff[STRERR_BUFF_LEN + 1]; \
pr2serr("%s at \"%s\":%d: %s\n", \
- text, __func__, __LINE__, tsafe_strerror(code, strerr_buff)); \
+ text, __func__, __LINE__, tsafe_strerror(code, _strerr_buff)); \
exit(1); \
} while (0)