aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-11-01 23:46:24 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-11-01 23:46:24 +0000
commit6d3bd268768b83b2749c560517c18b88f222df63 (patch)
tree5a29f79f49c19788ec25b5d2ec7074d7f09e2b4f /lib
parent7b73fc26be3892abf1e91243cd107ff5bcef4a0b (diff)
downloadsg3_utils-6d3bd268768b83b2749c560517c18b88f222df63.tar.gz
sg_read_block_limits: fix granularity value, add --mloi option; sg_lib: add sg_ll_read_block_limits_v2(); sg_logs: json work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@978 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib')
-rw-r--r--lib/sg_cmds_extra.c21
-rw-r--r--lib/sg_pr2serr.c19
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 9cbb0295..f0bfd16b 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -2236,16 +2236,20 @@ sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
/* Invokes a SCSI READ BLOCK LIMITS command. Return of 0 -> success,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
-sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
- bool noisy, int vb)
+sg_ll_read_block_limits_v2(int sg_fd, bool mloi, void * resp,
+ int mx_resp_len, int * residp, bool noisy,
+ int vb)
{
static const char * const cdb_s = "read block limits";
int ret, res, s_cat;
+ int resid = 0;
uint8_t rl_cdb[READ_BLOCK_LIMITS_CMDLEN] =
{READ_BLOCK_LIMITS_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN] SG_C_CPP_ZERO_INIT;
struct sg_pt_base * ptvp;
+ if (mloi)
+ rl_cdb[1] |= 0x1; /* introduced in ssc4r02 */
if (vb) {
char b[128];
@@ -2261,6 +2265,9 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
+ resid = get_scsi_pt_resid(ptvp);
+ if (residp)
+ *residp = resid;
if (-1 == ret) {
if (get_scsi_pt_transport_err(ptvp))
ret = SG_LIB_TRANSPORT_ERROR;
@@ -2287,6 +2294,8 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
pr2ws(":\n");
hex2stderr((const uint8_t *)resp, ret, 0);
}
+ if (vb)
+ pr2ws("resid=%d\n", resid);
}
ret = 0;
}
@@ -2294,6 +2303,14 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
return ret;
}
+int
+sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
+ bool noisy, int vb)
+{
+ return sg_ll_read_block_limits_v2(sg_fd, false, resp, mx_resp_len, NULL,
+ noisy, vb);
+}
+
/* Invokes a SCSI RECEIVE COPY RESULTS command. Actually cover all current
* uses of opcode 0x84 (Third-party copy IN). Return of 0 -> success,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
diff --git a/lib/sg_pr2serr.c b/lib/sg_pr2serr.c
index 79845335..ef533967 100644
--- a/lib/sg_pr2serr.c
+++ b/lib/sg_pr2serr.c
@@ -869,6 +869,25 @@ sgj_convert_to_snake_name(const char * in_name, char * sname,
return sname;
}
+bool
+sgj_is_snake_name(const char * in_name)
+{
+ size_t k;
+ size_t ln = strlen(in_name);
+ char c;
+
+ for (k = 0; k < ln; ++k) {
+ c = in_name[k];
+ if (((c >= '0') && (c <= '9')) ||
+ ((c >= 'a') && (c <= 'z')) ||
+ (c == '_'))
+ continue;
+ else
+ return false;
+ }
+ return true;
+}
+
/* This function tries to convert the 'in' C string to "snake_case"
* convention so the output 'out' only contains lower case ASCII letters,
* numerals and "_" as a separator. Any leading or trailing underscores