aboutsummaryrefslogtreecommitdiff
path: root/lib/sg_cmds_extra.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2017-10-22 17:32:39 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2017-10-22 17:32:39 +0000
commit9a9577a3b7f0b0c82ad0e77b9f16b3afa238322c (patch)
tree9d756acc6206a1dbc5c0777efc8ce6f6a3b9366b /lib/sg_cmds_extra.c
parent23712b6e6d5ee067cf7a740ef10e4dbea90dd179 (diff)
downloadsg3_utils-9a9577a3b7f0b0c82ad0e77b9f16b3afa238322c.tar.gz
sg_lib: add sg_ll_log_sense_v2(), sg_ll_mode_sense10_v2() and sg_ll_receive_diag_v2(); documentation cleanup; sg_ses: filter join output on dpage element presence (AES dpage)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@722 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib/sg_cmds_extra.c')
-rw-r--r--lib/sg_cmds_extra.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index fdeb1829..fb1b02be 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -525,12 +525,24 @@ int
sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "receive diagnostic results";
+ return sg_ll_receive_diag_v2(sg_fd, pcv, pg_code, resp, mx_resp_len, 0,
+ NULL, noisy, verbose);
+}
+
+/* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success,
+ * various SG_LIB_CAT_* positive values or -1 -> other errors */
+int
+sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
+ int mx_resp_len, int timeout_secs, int * residp,
+ bool noisy, int verbose)
+{
+ int resid = 0;
int k, res, ret, sense_cat;
+ static const char * const cdb_name_s = "receive diagnostic results";
+ struct sg_pt_base * ptvp;
unsigned char rcvdiag_cdb[RECEIVE_DIAGNOSTICS_CMDLEN] =
{RECEIVE_DIAGNOSTICS_CMD, 0, 0, 0, 0, 0};
unsigned char sense_b[SENSE_BUFF_LEN];
- struct sg_pt_base * ptvp;
if (pcv)
rcvdiag_cdb[1] = 0x1;
@@ -543,15 +555,23 @@ sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
pr2ws("%02x ", rcvdiag_cdb[k]);
pr2ws("\n");
}
+ if (timeout_secs <= 0)
+ timeout_secs = DEF_PT_TIMEOUT;
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_name_s)))) {
+ if (residp)
+ *residp = 0;
return -1;
+ }
set_scsi_pt_cdb(ptvp, rcvdiag_cdb, sizeof(rcvdiag_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ res = do_scsi_pt(ptvp, sg_fd, timeout_secs, verbose);
ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
noisy, verbose, &sense_cat);
+ resid = get_scsi_pt_resid(ptvp);
+ if (residp)
+ *residp = resid;
if (-1 == ret)
;
else if (-2 == ret) {