aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-05-12 18:37:08 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-05-12 18:37:08 +0000
commit404cd7cc68c42c49076623e3ec13bb1f42f74ec7 (patch)
treef164f678be7a236aeb87874e1fa6890b37c2c6b3 /src
parent3e056f675f51f14a5209efe1b491ba897e7873ce (diff)
downloadsg3_utils-404cd7cc68c42c49076623e3ec13bb1f42f74ec7.tar.gz
sg_lib: document internal json interface in include/sg_pr2serr.h; codespell fixes
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@952 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/sg_inq.c2
-rw-r--r--src/sg_logs.c4
-rw-r--r--src/sg_opcodes.c82
-rw-r--r--src/sg_read.c2
-rw-r--r--src/sg_read_buffer.c2
-rw-r--r--src/sg_rep_zones.c35
-rw-r--r--src/sg_sanitize.c2
-rw-r--r--src/sg_scan_win32.c2
-rw-r--r--src/sg_stpg.c2
-rw-r--r--src/sginfo.c2
10 files changed, 69 insertions, 66 deletions
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 8e3b8c6f..3a098774 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -1631,7 +1631,7 @@ decode_dev_ids(const char * leadin, uint8_t * buff, int len, int do_hex,
printf(" [or device number: 0x%x, function number: "
"0x%x]\n", (0x1f & (ip[1] >> 3)), 0x7 & ip[1]);
} else
- printf(" >>>> unexpected protocol indentifier: %s\n"
+ printf(" >>>> unexpected protocol identifier: %s\n"
" with Protocol specific port "
"identifier\n",
sg_get_trans_proto_str(p_id, sizeof(b), b));
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 051ea7fc..358b7222 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -426,7 +426,7 @@ static struct log_elem log_arr[] = {
{STATS_LPAGE, CACHE_STATS_SUBPG, 0, -1, MVP_STD, /* 0x19, 0x20 */
"Cache memory statistics", "cms", show_cache_stats_page},
{STATS_LPAGE, CMD_DUR_LIMITS_SUBPG, 0, -1, MVP_STD, /* 0x19, 0x21 */
- "Commmand duration limits statistics", "cdl",
+ "Command duration limits statistics", "cdl",
show_cmd_dur_limits_page /* spc6r01 */ },
{PCT_LPAGE, 0, 0, -1, MVP_STD, "Power condition transitions", "pct",
show_power_condition_transitions_page}, /* 0x1a, 0 */
@@ -3506,7 +3506,7 @@ show_sas_phy_event_info(int pes, unsigned int val, unsigned int thresh_val)
printf(" Received retry-class OPEN_REJECT count: %u\n", val);
break;
case 0x25:
- printf(" Received AIP (WATING ON PARTIAL) count: %u\n", val);
+ printf(" Received AIP (WAITING ON PARTIAL) count: %u\n", val);
break;
case 0x26:
printf(" Received AIP (WAITING ON CONNECTION) count: %u\n", val);
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index cf343a18..aba72afe 100644
--- a/src/sg_opcodes.c
+++ b/src/sg_opcodes.c
@@ -33,7 +33,7 @@
#include "sg_pt.h"
-static const char * version_str = "0.80 20220505"; /* spc6r06 */
+static const char * version_str = "0.81 20220506"; /* spc6r06 */
#define MY_NAME "sg_opcodes"
@@ -852,22 +852,22 @@ list_all_codes(uint8_t * rsoc_buff, int rsoc_len, struct opts_t * op,
}
if (jsp->pr_as_json) {
snprintf(b, blen, "0x%x", opcode);
- sgj_add_name_vs(jsp, jop, "operation_code", b);
+ sgj_add_val_s(jsp, jop, "operation_code", b);
if (sa_v) {
snprintf(b, blen, "0x%x", serv_act);
- sgj_add_name_vs(jsp, jop, "service_action", b);
+ sgj_add_val_s(jsp, jop, "service_action", b);
}
if (name_buff[0])
- sgj_add_name_vs(jsp, jop, "name", name_buff);
- sgj_add_name_vi(jsp, jop, "rwcdlp", (byt5 >> 6) & 0x1);
- sgj_add_name_vi(jsp, jop, "mlu", (byt5 >> 4) & 0x3);
- sgj_add_name_vi(jsp, jop, "cdlp", (byt5 >> 2) & 0x3);
- sgj_add_name_vi(jsp, jop, "ctdp", (byt5 >> 1) & 0x1);
- sgj_add_name_vi(jsp, jop, "servactv", byt5 & 0x1);
- sgj_add_name_vi(jsp, jop, "cdb_length",
- sg_get_unaligned_be16(bp + 6));
-
- sgj_add_array_element(jsp, jap, jop);
+ sgj_add_val_s(jsp, jop, "name", name_buff);
+ sgj_add_val_i(jsp, jop, "rwcdlp", (byt5 >> 6) & 0x1);
+ sgj_add_val_i(jsp, jop, "mlu", (byt5 >> 4) & 0x3);
+ sgj_add_val_i(jsp, jop, "cdlp", (byt5 >> 2) & 0x3);
+ sgj_add_val_i(jsp, jop, "ctdp", (byt5 >> 1) & 0x1);
+ sgj_add_val_i(jsp, jop, "servactv", byt5 & 0x1);
+ sgj_add_val_i(jsp, jop, "cdb_length",
+ sg_get_unaligned_be16(bp + 6));
+
+ sgj_add_val_o(jsp, jap, NULL /* implies an array add */, jop);
}
if (op->do_mask && ptvp) {
@@ -903,8 +903,8 @@ list_all_codes(uint8_t * rsoc_buff, int rsoc_len, struct opts_t * op,
l = strlen(b2p);
if ((l > 0) && (' ' == b2p[l - 1]))
b2p[l - 1] = '\0';
- sgj_add_name_vi(jsp, jo2p, "cdb_size", cdb_sz);
- sgj_add_name_vs(jsp, jo2p, "cdb_usage_data", b2p);
+ sgj_add_val_i(jsp, jo2p, "cdb_size", cdb_sz);
+ sgj_add_val_s(jsp, jo2p, "cdb_usage_data", b2p);
}
}
} else
@@ -942,9 +942,9 @@ decode_cmd_timeout_desc(uint8_t * dp, int max_b_len, char * b,
else
snprintf(b, max_b_len, "nominal timeout: %u secs, ", timeout);
if (jsp->pr_as_json) {
- sgj_add_name_vi(jsp, jsp->userp, "command_specific", dp[3]);
- sgj_add_name_vi(jsp, jsp->userp,
- "nominal_command_processing_timeout", timeout);
+ sgj_add_val_i(jsp, jsp->userp, "command_specific", dp[3]);
+ sgj_add_val_i(jsp, jsp->userp,
+ "nominal_command_processing_timeout", timeout);
}
len = strlen(b);
max_b_len -= len;
@@ -955,8 +955,8 @@ decode_cmd_timeout_desc(uint8_t * dp, int max_b_len, char * b,
else
snprintf(b, max_b_len, "recommended timeout: %u secs", timeout);
if (jsp->pr_as_json)
- sgj_add_name_vi(jsp, jsp->userp,
- "recommended_command_timeout", timeout);
+ sgj_add_val_i(jsp, jsp->userp,
+ "recommended_command_timeout", timeout);
return;
}
@@ -1072,25 +1072,25 @@ list_one(uint8_t * rsoc_buff, int cd_len, int rep_opts,
int l;
snprintf(b, blen, "0x%x", op->opcode);
- sgj_add_name_vs(jsp, jop, "operation_code", b);
+ sgj_add_val_s(jsp, jop, "operation_code", b);
if (rep_opts > 1) {
snprintf(b, blen, "0x%x", op->servact);
- sgj_add_name_vs(jsp, jop, "service_action", b);
+ sgj_add_val_s(jsp, jop, "service_action", b);
}
- sgj_add_name_vi(jsp, jop, "rwcdlp", rwcdlp);
- sgj_add_name_vi(jsp, jop, "ctdp", ctdp);
- sgj_add_name_vi(jsp, jop, "mlu", mlu);
- sgj_add_name_vi(jsp, jop, "cdlp", cdlp);
- sgj_add_name_vi(jsp, jop, "support", support);
- sgj_add_name_vs(jsp, jop, "support_str", cp);
- sgj_add_name_vi(jsp, jop, "cdb_size", cd_len);
+ sgj_add_val_i(jsp, jop, "rwcdlp", rwcdlp);
+ sgj_add_val_i(jsp, jop, "ctdp", ctdp);
+ sgj_add_val_i(jsp, jop, "mlu", mlu);
+ sgj_add_val_i(jsp, jop, "cdlp", cdlp);
+ sgj_add_val_i(jsp, jop, "support", support);
+ sgj_add_val_s(jsp, jop, "support_str", cp);
+ sgj_add_val_i(jsp, jop, "cdb_size", cd_len);
n = 0;
for (k = 0; k < cd_len; ++k)
n += sg_scnpr(b + n, blen - n, "%.2x ", rsoc_buff[k + 4]);
l = strlen(b);
if ((l > 0) && (' ' == b[l - 1]))
b[l - 1] = '\0';
- sgj_add_name_vs(jsp, jop, "cdb_usage_data", b);
+ sgj_add_val_s(jsp, jop, "cdb_usage_data", b);
}
if (ctdp) {
jsp->userp = sgj_new_named_object(jsp, jsp->basep,
@@ -1364,17 +1364,17 @@ start_response:
goto fini;
}
if (jsp->pr_as_json) {
- sgj_add_name_vb(jsp, jop, "ats", rsoc_buff[0] & 0x80);
- sgj_add_name_vb(jsp, jop, "atss", rsoc_buff[0] & 0x40);
- sgj_add_name_vb(jsp, jop, "cacas", rsoc_buff[0] & 0x20);
- sgj_add_name_vb(jsp, jop, "ctss", rsoc_buff[0] & 0x10);
- sgj_add_name_vb(jsp, jop, "lurs", rsoc_buff[0] & 0x8);
- sgj_add_name_vb(jsp, jop, "qts", rsoc_buff[0] & 0x4);
- sgj_add_name_vb(jsp, jop, "trs", rsoc_buff[0] & 0x2);
- sgj_add_name_vb(jsp, jop, "ws", rsoc_buff[0] & 0x1);
- sgj_add_name_vb(jsp, jop, "qaes", rsoc_buff[1] & 0x4);
- sgj_add_name_vb(jsp, jop, "qtss", rsoc_buff[1] & 0x2);
- sgj_add_name_vb(jsp, jop, "itnrs", rsoc_buff[1] & 0x1);
+ sgj_add_val_b(jsp, jop, "ats", rsoc_buff[0] & 0x80);
+ sgj_add_val_b(jsp, jop, "atss", rsoc_buff[0] & 0x40);
+ sgj_add_val_b(jsp, jop, "cacas", rsoc_buff[0] & 0x20);
+ sgj_add_val_b(jsp, jop, "ctss", rsoc_buff[0] & 0x10);
+ sgj_add_val_b(jsp, jop, "lurs", rsoc_buff[0] & 0x8);
+ sgj_add_val_b(jsp, jop, "qts", rsoc_buff[0] & 0x4);
+ sgj_add_val_b(jsp, jop, "trs", rsoc_buff[0] & 0x2);
+ sgj_add_val_b(jsp, jop, "ws", rsoc_buff[0] & 0x1);
+ sgj_add_val_b(jsp, jop, "qaes", rsoc_buff[1] & 0x4);
+ sgj_add_val_b(jsp, jop, "qtss", rsoc_buff[1] & 0x2);
+ sgj_add_val_b(jsp, jop, "itnrs", rsoc_buff[1] & 0x1);
if (! jsp->pr_output)
goto fini;
}
diff --git a/src/sg_read.c b/src/sg_read.c
index a4f7ceec..52304970 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -202,7 +202,7 @@ usage()
" fua 1-> set force unit access (FUA) in SCSI READs\n"
" if an sg, block or raw device, or a seekable file (not "
"stdin)\n"
- " mmap 1->perform mmaped IO on sg device, 0->indirect IO "
+ " mmap 1->perform mmap-ed IO on sg device, 0->indirect IO "
"(def)\n"
" no_dxfer 1->DMA to kernel buffers only, not user space, "
"0->normal(def)\n"
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index cbc5023b..232b94cd 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -63,7 +63,7 @@ static const char * version_str = "1.35 20220217"; /* spc6r06 */
#define MAX_DEF_INHEX_LEN 8192
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
#define DEF_PT_TIMEOUT 60 /* 60 seconds */
-#define DEF_RESPONSE_LEN 4 /* increased to 64 fo MODE_ERR_HISTORY */
+#define DEF_RESPONSE_LEN 4 /* increased to 64 for MODE_ERR_HISTORY */
static struct option long_options[] = {
diff --git a/src/sg_rep_zones.c b/src/sg_rep_zones.c
index faa89d29..0866cd8d 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.36 20220505";
+static const char * version_str = "1.38 20220511";
#define MY_NAME "sg_rep_zones"
@@ -134,6 +134,8 @@ static struct zt_num2abbrev_t zt_num2abbrev[] = {
static const char * zn_dnum_s = "zone descriptor number: ";
+static const char * meaning_s = "meaning";
+
static void
prn_zone_type_abbrevs(void)
@@ -393,10 +395,10 @@ prt_a_zn_desc(const uint8_t *bp, const struct opts_t * op,
zc = (bp[1] >> 4) & 0xf;
sg_get_zone_type_str(zt, sizeof(b), b);
sgj_pr_hr(jsp, " Zone type: %s\n", b);
- sgj_add_name_pair_istr(jsp, jop, "zone_type", zt, b);
+ sgj_add_name_pair_istr(jsp, jop, "zone_type", zt, meaning_s, b);
zone_condition_str(zc, b, sizeof(b), op->vb);
sgj_pr_hr(jsp, " Zone condition: %s\n", b);
- sgj_add_name_pair_istr(jsp, jop, "zone_condition", zc, b);
+ sgj_add_name_pair_istr(jsp, jop, "zone_condition", zc, meaning_s, b);
sgj_pr_twin_vi(jsp, jop, 3, "PUEP", SGJ_SEP_COLON_1_SPACE,
!!(bp[1] & 0x4));
sgj_pr_twin_vi(jsp, jop, 3, "NON_SEQ", SGJ_SEP_COLON_1_SPACE,
@@ -455,7 +457,8 @@ decode_rep_zones(const uint8_t * rzBuff, int act_len, uint32_t decod_len,
"granularity";
sgj_pr_hr(jsp, " Same=%d: %s\n", same, same_desc_arr[same]);
- sgj_add_name_pair_istr(jsp, jop, "same", same, same_desc_arr[same]);
+ sgj_add_name_pair_istr(jsp, jop, "same", same, meaning_s,
+ same_desc_arr[same]);
sgj_pr_hr(jsp, " Maximum LBA: 0x%" PRIx64 "\n\n", mx_lba);
sgj_add_name_pair_ihex(jsp, jop, "maximum_lba", mx_lba);
sgj_pr_hr(jsp, " %s: 0x%" PRIx64 "\n\n", rzslbag_s, rzslbag);
@@ -480,7 +483,7 @@ decode_rep_zones(const uint8_t * rzBuff, int act_len, uint32_t decod_len,
}
sgj_pr_hr(jsp, "From last descriptor in this response:\n");
sgj_pr_hr(jsp, " %s%d\n", zn_dnum_s, num_zd - 1);
- sgj_add_name_vi(jsp, jop, "zone_descriptor_index", num_zd - 1);
+ sgj_add_val_i(jsp, jop, "zone_descriptor_index", num_zd - 1);
ul = prt_a_zn_desc(bp, op, jsp, jop);
if (ul > mx_lba)
sgj_pr_hr(jsp, " >> This zone seems to be the last one\n");
@@ -513,13 +516,13 @@ decode_rep_zones(const uint8_t * rzBuff, int act_len, uint32_t decod_len,
jo2p = sgj_new_unattached_object(jsp);
sgj_add_name_pair_ihex(jsp, jo2p, "write_pointer_lba",
(int64_t)wp);
- sgj_add_array_element(jsp, jap, jo2p);
+ sgj_add_val_o(jsp, jap, NULL /* name */, jo2p);
}
continue;
}
jo2p = sgj_new_unattached_object(jsp);
prt_a_zn_desc(bp, op, jsp, jo2p);
- sgj_add_array_element(jsp, jap, jo2p);
+ sgj_add_val_o(jsp, jap, NULL /* name */, jo2p);
}
if ((op->do_num == 0) && (! op->wp_only) && (! op->do_hex)) {
if ((64 + (REPORT_ZONES_DESC_LEN * (uint32_t)num_zd)) < decod_len)
@@ -615,7 +618,7 @@ decode_rep_realms(const uint8_t * rzBuff, int act_len,
jo3p = sgj_new_unattached_object(jsp);
sgj_pr_hr(jsp, " zone_domain=%u\n", j);
- sgj_add_name_vi(jsp, jo3p, "corresponding_zone_domain_id", j);
+ sgj_add_val_i(jsp, jo3p, "corresponding_zone_domain_id", j);
lba = sg_get_unaligned_be64(zp + 0);
sgj_pr_hr(jsp, " starting_lba=0x%" PRIx64 "\n", lba);
sgj_add_name_pair_ihex(jsp, jo3p, "realm_starting_lba",
@@ -624,9 +627,9 @@ decode_rep_realms(const uint8_t * rzBuff, int act_len,
sgj_pr_hr(jsp, " ending_lba=0x%" PRIx64 "\n", lba);
sgj_add_name_pair_ihex(jsp, jo3p, "realm_ending_lba",
(int64_t)lba);
- sgj_add_array_element(jsp, ja2p, jo3p);
+ sgj_add_val_o(jsp, ja2p, NULL /* name */, jo3p);
}
- sgj_add_array_element(jsp, jap, jo2p);
+ sgj_add_val_o(jsp, jap, NULL /* name */, jo2p);
}
return 0;
}
@@ -694,7 +697,7 @@ decode_rep_zdomains(const uint8_t * rzBuff, int act_len,
!!(0x2 & bp[42]));
sgj_pr_twin_vi(jsp, jo2p, 5, "SRB", SGJ_SEP_EQUAL_NO_SPACE,
!!(0x1 & bp[42]));
- sgj_add_array_element(jsp, jap, jo2p);
+ sgj_add_val_o(jsp, jap, NULL /* name */, jo2p);
}
return 0;
}
@@ -771,8 +774,8 @@ find_report_zones(int sg_fd, uint8_t * rzBuff, const char * cmd_name,
} else {
sgj_pr_hr(jsp, "Condition met at:\n");
sgj_pr_hr(jsp, " %s: %d\n", zn_dnum_s, zn_dnum);
- sgj_add_name_vb(jsp, jo2p, "met", true);
- sgj_add_name_vi(jsp, jo2p, "zone_descriptor_index", zn_dnum);
+ sgj_add_val_b(jsp, jo2p, "met", true);
+ sgj_add_val_i(jsp, jo2p, "zone_descriptor_index", zn_dnum);
prt_a_zn_desc(bp, op, jsp, jo2p);
}
} else {
@@ -780,8 +783,8 @@ find_report_zones(int sg_fd, uint8_t * rzBuff, const char * cmd_name,
memset(b, 0xff, 64);
hex2stdout((const uint8_t *)b, 64, -1);
} else {
- sgj_add_name_vb(jsp, jo2p, "met", false);
- sgj_add_name_vi(jsp, jo2p, "zone_descriptor_index", zn_dnum);
+ sgj_add_val_b(jsp, jo2p, "met", false);
+ sgj_add_val_i(jsp, jo2p, "zone_descriptor_index", zn_dnum);
if (num_rem < 1)
sgj_pr_hr(jsp, "Condition NOT met, checked %d zones; "
"next %s%u\n", op->do_num, zn_dnum_s, zn_dnum);
@@ -1337,7 +1340,7 @@ main(int argc, char * argv[])
else if (op->do_realms)
cmd_name = "Report realms";
if (as_json)
- sgj_add_name_vs(jsp, jop, "scsi_command_name", cmd_name);
+ sgj_add_val_s(jsp, jop, "scsi_command_name", cmd_name);
if ((op->serv_act != REPORT_ZONES_SA) && op->do_partial) {
pr2serr("Can only use --partial with REPORT ZONES\n");
return SG_LIB_SYNTAX_ERROR;
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index 147898fe..41db4bba 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -138,7 +138,7 @@ usage()
"field\n"
" (def: clear 'desc' field)\n"
" --dry-run|-D to preparation but bypass SANITIZE "
- "commnd\n"
+ "command\n"
" --early|-e exit once sanitize started (IMMED set "
"in cdb)\n"
" user can monitor progress with REQUEST "
diff --git a/src/sg_scan_win32.c b/src/sg_scan_win32.c
index 06851497..d39212c7 100644
--- a/src/sg_scan_win32.c
+++ b/src/sg_scan_win32.c
@@ -103,7 +103,7 @@ usage()
"scan after\n"
" device scan; default: show no "
"adapters;\n"
- " used twice: show only adapaters\n"
+ " used twice: show only adapters\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
"Scan for storage and related device names\n");
diff --git a/src/sg_stpg.c b/src/sg_stpg.c
index a12b5cac..ce21c9c1 100644
--- a/src/sg_stpg.c
+++ b/src/sg_stpg.c
@@ -284,7 +284,7 @@ encode_tpgs_states(uint8_t *buff, struct tgtgrp *tgtState, int numgrp)
}
/* Read numbers (up to 32 bits in size) from command line (comma separated
- * list). Assumed decimal unless prefixed by '0x', '0X' or contains traling
+ * list). Assumed decimal unless prefixed by '0x', '0X' or contains trailing
* 'h' or 'H' (which indicate hex). Returns 0 if ok, else error code. */
static int
build_port_arr(const char * inp, int * port_arr, int * port_arr_len,
diff --git a/src/sginfo.c b/src/sginfo.c
index 0225ab5f..0fb85904 100644
--- a/src/sginfo.c
+++ b/src/sginfo.c
@@ -3012,7 +3012,7 @@ spi4_report_xfer(struct mpage_info * mpi, const char * prefix)
mpi->subpage);
printf("--------------------------------------------\n");
}
- intfield(pagestart + 6, 1, "Mimimum transfer period factor");
+ intfield(pagestart + 6, 1, "Minimum transfer period factor");
intfield(pagestart + 8, 1, "Maximum REQ/ACK offset");
intfield(pagestart + 9, 1, "Maximum transfer width exponent");
bitfield(pagestart + 10, "Protocol option bits supported", 0xff, 0);