aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--include/sg_cmds_basic.h6
-rw-r--r--include/sg_lib_data.h10
-rw-r--r--include/sg_pt.h21
-rw-r--r--lib/sg_cmds_basic.c125
-rw-r--r--lib/sg_cmds_basic2.c121
-rw-r--r--lib/sg_cmds_extra.c822
-rw-r--r--lib/sg_cmds_mmc.c44
-rw-r--r--lib/sg_lib.c2
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--lib/sg_pt_common.c4
-rw-r--r--lib/sg_pt_freebsd.c70
-rw-r--r--lib/sg_pt_linux.c68
-rw-r--r--lib/sg_pt_linux_nvme.c4
-rw-r--r--lib/sg_pt_osf1.c47
-rw-r--r--lib/sg_pt_solaris.c56
-rw-r--r--lib/sg_pt_win32.c45
-rw-r--r--src/sg_bg_ctl.c8
-rw-r--r--src/sg_compare_and_write.c7
-rw-r--r--src/sg_format.c8
-rw-r--r--src/sg_opcodes.c9
-rw-r--r--src/sg_read_attr.c8
-rw-r--r--src/sg_read_buffer.c10
-rw-r--r--src/sg_rep_zones.c8
-rw-r--r--src/sg_reset_wp.c9
-rw-r--r--src/sg_sanitize.c8
-rw-r--r--src/sg_stream_ctl.c12
-rw-r--r--src/sg_sync.c7
-rw-r--r--src/sg_timestamp.c12
-rw-r--r--src/sg_turs.c9
-rw-r--r--src/sg_write_same.c9
-rw-r--r--src/sg_write_verify.c7
-rw-r--r--src/sg_write_x.c8
-rw-r--r--src/sg_zone.c9
-rw-r--r--testing/bsg_queue_tst.c6
-rw-r--r--testing/sg_queue_tst.c4
-rw-r--r--testing/sg_tst_async.cpp1
-rw-r--r--testing/sg_tst_bidi.c33
-rw-r--r--testing/sg_tst_ioctl.c4
-rw-r--r--testing/sg_tst_nvme.c7
40 files changed, 955 insertions, 699 deletions
diff --git a/ChangeLog b/ChangeLog
index a3e639fd..36c9e849 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 sg3_utils-1.45 [20190110] [svn: r804]
+Changelog for sg3_utils-1.45 [20190113] [svn: r805]
- sg_ses: bug: --page= being overridden when --control
and --data= also given; fix
- sg_opcodes: expand MLU (spc5r20)
@@ -13,6 +13,8 @@ Changelog for sg3_utils-1.45 [20190110] [svn: r804]
- sg_vpd: 3pc VPD page add copy group descriptor
- sg_scan (win32): expand limits for big arrays
- sg_lib: add sg_t10_uuid_desig2str()
+ - tweak sg_pt interface to better handle bidi
+ - sg_cmds_process_resp(): two arguments removed
- sg_pt_freebsd: fixes for FreeBSD 12.0 release
- rescan-scsi-bus: widen LUN 0 only scanning
- testing/sg_tst_async: fix free_list issue
diff --git a/include/sg_cmds_basic.h b/include/sg_cmds_basic.h
index d6ded5a4..e40d1011 100644
--- a/include/sg_cmds_basic.h
+++ b/include/sg_cmds_basic.h
@@ -2,7 +2,7 @@
#define SG_CMDS_BASIC_H
/*
- * Copyright (c) 2004-2018 Douglas Gilbert.
+ * Copyright (c) 2004-2019 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.
@@ -343,8 +343,8 @@ const char * sg_cmds_version();
* output via 'o_sense_cat' pointer (if not NULL). Note that several sense
* categories also have data in bytes received; -2 is still returned. */
int sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
- int pt_res, int mx_di_len, const uint8_t * sense_b,
- bool noisy, int verbose, int * o_sense_cat);
+ int pt_res, bool noisy, int verbose,
+ int * o_sense_cat);
/* NVMe devices use a different command set. This function will return true
* if the device associated with 'pvtp' is a NVME device, else it will
diff --git a/include/sg_lib_data.h b/include/sg_lib_data.h
index 9f573b97..2f142a22 100644
--- a/include/sg_lib_data.h
+++ b/include/sg_lib_data.h
@@ -2,7 +2,7 @@
#define SG_LIB_DATA_H
/*
- * Copyright (c) 2007-2018 Douglas Gilbert.
+ * Copyright (c) 2007-2019 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.
@@ -88,6 +88,14 @@ struct sg_lib_4tuple_u8 {
uint8_t t4;
};
+struct sg_cmd_response_t {
+ int din_len;
+ int dout_len;
+ int resid;
+ int resid2;
+ const uint8_t * sbp;
+};
+
extern const char * sg_lib_version_str;
diff --git a/include/sg_pt.h b/include/sg_pt.h
index b75a8d46..00a43096 100644
--- a/include/sg_pt.h
+++ b/include/sg_pt.h
@@ -2,7 +2,7 @@
#define SG_PT_H
/*
- * Copyright (c) 2005-2018 Douglas Gilbert.
+ * Copyright (c) 2005-2019 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.
@@ -172,9 +172,12 @@ int do_scsi_pt(struct sg_pt_base * objp, int fd, int timeout_secs,
* belongs to. */
int get_scsi_pt_result_category(const struct sg_pt_base * objp);
-/* If not available return 0 which implies there is no residual
- * value. If supported the number of bytes actually sent back by
- * the device is 'dxfer_ilen - get_scsi_pt_len()' bytes. */
+/* If not available return 0 which implies there is no residual value. If
+ * supported it is the number of bytes requested to transfer less the
+ * number actually transferred. This it typically important for data-in
+ * transfers. For data-out (only) transfers, the 'dout_req_len -
+ * dout_act_len' is returned. For bidi transfer the data-in residual is
+ * returned. */
int get_scsi_pt_resid(const struct sg_pt_base * objp);
/* Returns SCSI status value (from device that received the command). If an
@@ -190,6 +193,7 @@ uint32_t get_pt_result(const struct sg_pt_base * objp);
/* Actual sense length returned. If sense data is present but
actual sense length is not known, return 'max_sense_len' */
int get_scsi_pt_sense_len(const struct sg_pt_base * objp);
+uint8_t * get_scsi_pt_sense_buf(const struct sg_pt_base * objp);
/* If not available return 0 (for success). */
int get_scsi_pt_os_err(const struct sg_pt_base * objp);
@@ -207,6 +211,15 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * objp,
* command. */
int get_scsi_pt_duration_ms(const struct sg_pt_base * objp);
+/* The two functions yield requested and actual data transfer lengths in
+ * bytes. The second argument is a pointer to the data-in length; the third
+ * argument is a pointer to the data-out length. The pointers may be NULL.
+ * The _actual_ values are related to resid (residual count from DMA) */
+void get_pt_req_lengths(const struct sg_pt_base * objp, int * req_dinp,
+ int * req_doutp);
+void get_pt_actual_lengths(const struct sg_pt_base * objp, int * act_dinp,
+ int * act_doutp);
+
/* Return true if device associated with 'objp' uses NVMe command set. To
* be useful (in modifying the type of command sent (SCSI or NVMe) then
* construct_scsi_pt_obj_with_fd() should be used followed by an invocation
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 5e16b44c..3e26af24 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2018 Douglas Gilbert.
+ * Copyright (c) 1999-2019 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.
@@ -40,7 +40,7 @@
#endif
-static const char * const version_str = "1.90 20180712";
+static const char * const version_str = "1.91 20190113";
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
@@ -93,12 +93,22 @@ sg_cmds_close_device(int device_fd)
static const char * const pass_through_s = "pass-through";
+static void
+sg_cmds_resid_print(const char * leadin, bool is_din, int num_req,
+ int num_got)
+{
+ pr2ws(" %s: %s requested %d bytes (data-%s got %d "
+ "bytes%s\n", leadin, pass_through_s,num_req,
+ (is_din ? "in), got" : "out) but reported"), num_got,
+ (is_din ? "" : " sent"));
+}
+
static int
-sg_cmds_process_helper(const char * leadin, int mx_di_len, int resid,
- const uint8_t * sbp, int slen, bool noisy,
- int verbose, int * o_sense_cat)
+sg_cmds_process_helper(const char * leadin, int req_din_x, int act_din_x,
+ int req_dout_x, int act_dout_x, const uint8_t * sbp,
+ int slen, bool noisy, int verbose, int * o_sense_cat)
{
- int scat, got;
+ int scat;
bool n = false;
bool check_data_in = false;
char b[512];
@@ -138,11 +148,27 @@ sg_cmds_process_helper(const char * leadin, int mx_di_len, int resid,
sg_get_sense_str(NULL, sbp, slen, (verbose > 1),
sizeof(b), b);
pr2ws("%s", b);
- if ((mx_di_len > 0) && (resid > 0)) {
- got = mx_di_len - resid;
- if ((verbose > 2) || check_data_in || (got > 0))
- pr2ws(" %s requested %d bytes (data-in) but got %d "
- "bytes\n", pass_through_s, mx_di_len, got);
+ if (req_din_x > 0) {
+ if (act_din_x != req_din_x) {
+ if ((verbose > 2) || check_data_in || (act_din_x > 0))
+ sg_cmds_resid_print(leadin, true, req_din_x, act_din_x);
+ if (act_din_x < 0) {
+ if (verbose)
+ pr2ws(" %s: %s can't get negative bytes, say it "
+ "got none\n", leadin, pass_through_s);
+ }
+ }
+ }
+ if (req_dout_x > 0) {
+ if (act_dout_x != req_dout_x) {
+ if ((verbose > 1) && (act_dout_x > 0))
+ sg_cmds_resid_print(leadin, false, req_dout_x, act_dout_x);
+ if (act_dout_x < 0) {
+ if (verbose)
+ pr2ws(" %s: %s can't send negative bytes, say it "
+ "sent none\n", leadin, pass_through_s);
+ }
+ }
}
}
if (o_sense_cat)
@@ -155,19 +181,18 @@ sg_cmds_process_helper(const char * leadin, int mx_di_len, int resid,
* sense data is found it is decoded and output to sg_warnings_strm (def:
* stderr); depending on the 'noisy' and 'verbose' settings. Returns -2 for
* "sense" category (may not be fatal), -1 for failed, 0, or a positive
- * number. If 'mx_di_len > 0' then asks pass-through for resid and returns
- * (mx_di_len - resid); otherwise returns 0. So for data-in it should return
- * the actual number of bytes received. For data-out (to device) or no data
- * call with 'mx_di_len' set to 0 or less. If -2 returned then sense category
+ * number. If din type command (or bidi) returns actual number of bytes read
+ * (din_len - resid); otherwise returns 0. If -2 returned then sense category
* output via 'o_sense_cat' pointer (if not NULL). Note that several sense
* categories also have data in bytes received; -2 is still returned. */
int
sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
- int pt_res, int mx_di_len, const uint8_t * sbp,
- bool noisy, int verbose, int * o_sense_cat)
+ int pt_res, bool noisy, int verbose, int * o_sense_cat)
{
- int got, cat, duration, slen, resid, resp_code, sstat;
bool transport_sense;
+ int cat, duration, slen, resp_code, sstat, req_din_x, req_dout_x;
+ int act_din_x, act_dout_x;
+ const uint8_t * sbp;
char b[1024];
if (NULL == leadin)
@@ -200,8 +225,10 @@ sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
}
if ((verbose > 2) && ((duration = get_scsi_pt_duration_ms(ptvp)) >= 0))
pr2ws(" duration=%d ms\n", duration);
- resid = (mx_di_len > 0) ? get_scsi_pt_resid(ptvp) : 0;
+ get_pt_req_lengths(ptvp, &req_din_x, &req_dout_x);
+ get_pt_actual_lengths(ptvp, &act_din_x, &act_dout_x);
slen = get_scsi_pt_sense_len(ptvp);
+ sbp = get_scsi_pt_sense_buf(ptvp);
switch ((cat = get_scsi_pt_result_category(ptvp))) {
case SCSI_PT_RESULT_GOOD:
if (sbp && (slen > 7)) {
@@ -217,21 +244,31 @@ sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
}
}
}
- if (mx_di_len > 0) {
- got = mx_di_len - resid;
- if ((verbose > 1) && (resid != 0))
- pr2ws(" %s: %s requested %d bytes (data-in) but got %d "
- "bytes\n", leadin, pass_through_s, mx_di_len, got);
- if (got >= 0)
- return got;
- else {
- if (verbose)
- pr2ws(" %s: %s can't get negative bytes, say it got "
- "none\n", leadin, pass_through_s);
- return 0;
+ if (req_din_x > 0) {
+ if (act_din_x != req_din_x) {
+ if ((verbose > 1) && (act_din_x >= 0))
+ sg_cmds_resid_print(leadin, true, req_din_x, act_din_x);
+ if (act_din_x < 0) {
+ if (verbose)
+ pr2ws(" %s: %s can't get negative bytes, say it "
+ "got none\n", leadin, pass_through_s);
+ act_din_x = 0;
+ }
}
- } else
- return 0;
+ }
+ if (req_dout_x > 0) {
+ if (act_dout_x != req_dout_x) {
+ if ((verbose > 1) && (act_dout_x >= 0))
+ sg_cmds_resid_print(leadin, false, req_dout_x, act_dout_x);
+ if (act_dout_x < 0) {
+ if (verbose)
+ pr2ws(" %s: %s can't send negative bytes, say it "
+ "sent none\n", leadin, pass_through_s);
+ act_dout_x = 0;
+ }
+ }
+ }
+ return act_din_x;
case SCSI_PT_RESULT_STATUS: /* other than GOOD and CHECK CONDITION */
sstat = get_scsi_pt_status_response(ptvp);
if (o_sense_cat) {
@@ -264,7 +301,8 @@ sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
}
return -1;
case SCSI_PT_RESULT_SENSE:
- return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp, slen,
+ return sg_cmds_process_helper(leadin, req_din_x, act_din_x,
+ req_dout_x, act_dout_x, sbp, slen,
noisy, verbose, o_sense_cat);
case SCSI_PT_RESULT_TRANSPORT_ERR:
if (verbose || noisy) {
@@ -278,8 +316,9 @@ sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin,
get_scsi_pt_status_response(ptvp)) && (slen > 0));
#endif
if (transport_sense)
- return sg_cmds_process_helper(leadin, mx_di_len, resid, sbp,
- slen, noisy, verbose, o_sense_cat);
+ return sg_cmds_process_helper(leadin, req_din_x, act_din_x,
+ req_dout_x, act_dout_x, sbp, slen,
+ noisy, verbose, o_sense_cat);
else
return -1;
case SCSI_PT_RESULT_OS_ERR:
@@ -351,8 +390,8 @@ sg_ll_inquiry_com(struct sg_pt_base * ptvp, bool cmddt, bool evpd, int pg_op,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, -1, timeout_secs, verbose);
- ret = sg_cmds_process_resp(ptvp, inquiry_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, inquiry_s, res, noisy, verbose,
+ &sense_cat);
resid = get_scsi_pt_resid(ptvp);
if (residp)
*residp = resid;
@@ -559,8 +598,7 @@ sg_ll_test_unit_ready_progress_pt(struct sg_pt_base * ptvp, int pack_id,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_packet_id(ptvp, pack_id);
res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, tur_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, tur_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -665,8 +703,7 @@ sg_ll_request_sense_com(struct sg_pt_base * ptvp, int sg_fd, bool desc,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, rq_s, res, mx_resp_len, sense_b, noisy,
- verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, rq_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -740,8 +777,8 @@ sg_ll_report_luns_com(struct sg_pt_base * ptvp, int sg_fd, int select_report,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, report_luns_s, res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, report_luns_s, res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/lib/sg_cmds_basic2.c b/lib/sg_cmds_basic2.c
index f4605d44..e8536385 100644
--- a/lib/sg_cmds_basic2.c
+++ b/lib/sg_cmds_basic2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2018 Douglas Gilbert.
+ * Copyright (c) 1999-2019 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.
@@ -89,7 +89,7 @@ sg_ll_sync_cache_10(int sg_fd, bool sync_nv, bool immed, int group,
unsigned int lba, unsigned int count, bool noisy,
int verbose)
{
- static const char * const cdb_name_s = "synchronize cache(10)";
+ static const char * const cdb_s = "synchronize cache(10)";
int res, ret, k, sense_cat;
uint8_t sc_cdb[SYNCHRONIZE_CACHE_CMDLEN] =
{SYNCHRONIZE_CACHE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -109,18 +109,17 @@ sg_ll_sync_cache_10(int sg_fd, bool sync_nv, bool immed, int group,
sg_put_unaligned_be16((int16_t)count, sc_cdb + 7);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SYNCHRONIZE_CACHE_CMDLEN; ++k)
pr2ws("%02x ", sc_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, sc_cdb, sizeof(sc_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -146,7 +145,7 @@ int
sg_ll_readcap_16(int sg_fd, bool pmi, uint64_t llba, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "read capacity(16)";
+ static const char * const cdb_s = "read capacity(16)";
int k, ret, res, sense_cat;
uint8_t rc_cdb[SERVICE_ACTION_IN_16_CMDLEN] =
{SERVICE_ACTION_IN_16_CMD, READ_CAPACITY_16_SA,
@@ -161,19 +160,18 @@ sg_ll_readcap_16(int sg_fd, bool pmi, uint64_t llba, void * resp,
/* Allocation length, no guidance in SBC-2 rev 15b */
sg_put_unaligned_be32((uint32_t)mx_resp_len, rc_cdb + 10);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k)
pr2ws("%02x ", rc_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, rc_cdb, sizeof(rc_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -199,7 +197,7 @@ int
sg_ll_readcap_10(int sg_fd, bool pmi, unsigned int lba, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "read capacity(10)";
+ static const char * const cdb_s = "read capacity(10)";
int k, ret, res, sense_cat;
uint8_t rc_cdb[READ_CAPACITY_10_CMDLEN] =
{READ_CAPACITY_10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -211,19 +209,18 @@ sg_ll_readcap_10(int sg_fd, bool pmi, unsigned int lba, void * resp,
sg_put_unaligned_be32((uint32_t)lba, rc_cdb + 2);
}
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < READ_CAPACITY_10_CMDLEN; ++k)
pr2ws("%02x ", rc_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, rc_cdb, sizeof(rc_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -249,7 +246,7 @@ int
sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
void * resp, int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "mode sense(6)";
+ static const char * const cdb_s = "mode sense(6)";
int res, ret, k, sense_cat, resid;
uint8_t modes_cdb[MODE_SENSE6_CMDLEN] =
{MODE_SENSE6_CMD, 0, 0, 0, 0, 0};
@@ -265,19 +262,18 @@ sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
return -1;
}
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MODE_SENSE6_CMDLEN; ++k)
pr2ws("%02x ", modes_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, modes_cdb, sizeof(modes_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
@@ -293,7 +289,7 @@ sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
}
} else {
if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
+ pr2ws(" %s: response", cdb_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
@@ -310,7 +306,7 @@ sg_ll_mode_sense6(int sg_fd, bool dbd, int pc, int pg_code, int sub_pg_code,
if (resid > 0) {
if (resid > mx_resp_len) {
pr2ws("%s: resid (%d) should never exceed requested len=%d\n",
- cdb_name_s, resid, mx_resp_len);
+ cdb_s, resid, mx_resp_len);
return ret ? ret : SG_LIB_CAT_MALFORMED;
}
/* zero unfilled section of response buffer */
@@ -345,7 +341,7 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
int timeout_secs, int * residp, bool noisy, int verbose)
{
int res, ret, k, sense_cat, resid;
- static const char * const cdb_name_s = "mode sense(10)";
+ static const char * const cdb_s = "mode sense(10)";
struct sg_pt_base * ptvp;
uint8_t modes_cdb[MODE_SENSE10_CMDLEN] =
{MODE_SENSE10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -360,7 +356,7 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
goto gen_err;
}
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MODE_SENSE10_CMDLEN; ++k)
pr2ws("%02x ", modes_cdb[k]);
pr2ws("\n");
@@ -368,14 +364,13 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
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_s))))
goto gen_err;
set_scsi_pt_cdb(ptvp, modes_cdb, sizeof(modes_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
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);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
if (residp)
*residp = resid;
@@ -393,7 +388,7 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
}
} else {
if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
+ pr2ws(" %s: response", cdb_s);
if (3 == verbose) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
@@ -410,7 +405,7 @@ sg_ll_mode_sense10_v2(int sg_fd, bool llbaa, bool dbd, int pc, int pg_code,
if (resid > 0) {
if (resid > mx_resp_len) {
pr2ws("%s: resid (%d) should never exceed requested len=%d\n",
- cdb_name_s, resid, mx_resp_len);
+ cdb_s, resid, mx_resp_len);
return ret ? ret : SG_LIB_CAT_MALFORMED;
}
/* zero unfilled section of response buffer */
@@ -429,7 +424,7 @@ int
sg_ll_mode_select6_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
int param_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "mode select(6)";
+ static const char * const cdb_s = "mode select(6)";
int res, ret, k, sense_cat;
uint8_t modes_cdb[MODE_SELECT6_CMDLEN] =
{MODE_SELECT6_CMD, 0, 0, 0, 0, 0};
@@ -441,28 +436,27 @@ sg_ll_mode_select6_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
modes_cdb[1] |= 0x2;
modes_cdb[4] = (uint8_t)(param_len & 0xff);
if (param_len > 0xff) {
- pr2ws("%s: param_len too big\n", cdb_name_s);
+ pr2ws("%s: param_len too big\n", cdb_s);
return -1;
}
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MODE_SELECT6_CMDLEN; ++k)
pr2ws("%02x ", modes_cdb[k]);
pr2ws("\n");
}
if (verbose > 1) {
- pr2ws(" %s parameter list\n", cdb_name_s);
+ pr2ws(" %s parameter list\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, modes_cdb, sizeof(modes_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -497,7 +491,7 @@ int
sg_ll_mode_select10_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
int param_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "mode select(10)";
+ static const char * const cdb_s = "mode select(10)";
int res, ret, k, sense_cat;
uint8_t modes_cdb[MODE_SELECT10_CMDLEN] =
{MODE_SELECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -509,28 +503,27 @@ sg_ll_mode_select10_v2(int sg_fd, bool pf, bool rtd, bool sp, void * paramp,
modes_cdb[1] |= 0x2;
sg_put_unaligned_be16((int16_t)param_len, modes_cdb + 7);
if (param_len > 0xffff) {
- pr2ws("%s: param_len too big\n", cdb_name_s);
+ pr2ws("%s: param_len too big\n", cdb_s);
return -1;
}
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MODE_SELECT10_CMDLEN; ++k)
pr2ws("%02x ", modes_cdb[k]);
pr2ws("\n");
}
if (verbose > 1) {
- pr2ws(" %s parameter list\n", cdb_name_s);
+ pr2ws(" %s parameter list\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, modes_cdb, sizeof(modes_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -793,7 +786,7 @@ sg_ll_log_sense_v2(int sg_fd, bool ppc, bool sp, int pc, int pg_code,
int mx_resp_len, int timeout_secs, int * residp,
bool noisy, int verbose)
{
- static const char * const cdb_name_s = "log sense";
+ static const char * const cdb_s = "log sense";
int res, ret, k, sense_cat, resid;
uint8_t logs_cdb[LOG_SENSE_CMDLEN] =
{LOG_SENSE_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -810,7 +803,7 @@ sg_ll_log_sense_v2(int sg_fd, bool ppc, bool sp, int pc, int pg_code,
sg_put_unaligned_be16((int16_t)paramp, logs_cdb + 5);
sg_put_unaligned_be16((int16_t)mx_resp_len, logs_cdb + 7);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < LOG_SENSE_CMDLEN; ++k)
pr2ws("%02x ", logs_cdb[k]);
pr2ws("\n");
@@ -818,14 +811,13 @@ sg_ll_log_sense_v2(int sg_fd, bool ppc, bool sp, int pc, int pg_code,
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_s))))
goto gen_err;
set_scsi_pt_cdb(ptvp, logs_cdb, sizeof(logs_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, resp, mx_resp_len);
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);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
if (residp)
*residp = resid;
@@ -854,7 +846,7 @@ sg_ll_log_sense_v2(int sg_fd, bool ppc, bool sp, int pc, int pg_code,
if (resid > 0) {
if (resid > mx_resp_len) {
pr2ws("%s: resid (%d) should never exceed requested len=%d\n",
- cdb_name_s, resid, mx_resp_len);
+ cdb_s, resid, mx_resp_len);
return ret ? ret : SG_LIB_CAT_MALFORMED;
}
/* zero unfilled section of response buffer */
@@ -874,7 +866,7 @@ sg_ll_log_select(int sg_fd, bool pcr, bool sp, int pc, int pg_code,
int subpg_code, uint8_t * paramp, int param_len,
bool noisy, int verbose)
{
- static const char * const cdb_name_s = "log select";
+ static const char * const cdb_s = "log select";
int res, ret, k, sense_cat;
uint8_t logs_cdb[LOG_SELECT_CMDLEN] =
{LOG_SELECT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -882,7 +874,7 @@ sg_ll_log_select(int sg_fd, bool pcr, bool sp, int pc, int pg_code,
struct sg_pt_base * ptvp;
if (param_len > 0xffff) {
- pr2ws("%s: param_len too big\n", cdb_name_s);
+ pr2ws("%s: param_len too big\n", cdb_s);
return -1;
}
logs_cdb[1] = (uint8_t)((pcr ? 2 : 0) | (sp ? 1 : 0));
@@ -890,24 +882,23 @@ sg_ll_log_select(int sg_fd, bool pcr, bool sp, int pc, int pg_code,
logs_cdb[3] = (uint8_t)(subpg_code & 0xff);
sg_put_unaligned_be16((int16_t)param_len, logs_cdb + 7);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < LOG_SELECT_CMDLEN; ++k)
pr2ws("%02x ", logs_cdb[k]);
pr2ws("\n");
}
if ((verbose > 1) && (param_len > 0)) {
- pr2ws(" %s parameter list\n", cdb_name_s);
+ pr2ws(" %s parameter list\n", cdb_s);
hex2stderr(paramp, param_len, -1);
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, logs_cdb, sizeof(logs_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -957,7 +948,7 @@ sg_ll_start_stop_unit_pt(struct sg_pt_base * ptvp, bool immed,
int pc_mod__fl_num, int power_cond, bool noflush__fl,
bool loej, bool start, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "start stop unit";
+ static const char * const cdb_s = "start stop unit";
int k, res, ret, sense_cat;
uint8_t ssuBlk[START_STOP_CMDLEN] = {START_STOP_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -973,7 +964,7 @@ sg_ll_start_stop_unit_pt(struct sg_pt_base * ptvp, bool immed,
if (start)
ssuBlk[4] |= 0x1;
if (verbose) {
- pr2ws(" %s command:", cdb_name_s);
+ pr2ws(" %s command:", cdb_s);
for (k = 0; k < (int)sizeof(ssuBlk); ++k)
pr2ws(" %02x", ssuBlk[k]);
pr2ws("\n");
@@ -983,8 +974,7 @@ sg_ll_start_stop_unit_pt(struct sg_pt_base * ptvp, bool immed,
set_scsi_pt_cdb(ptvp, ssuBlk, sizeof(ssuBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, -1, START_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -1010,7 +1000,7 @@ sg_ll_start_stop_unit_pt(struct sg_pt_base * ptvp, bool immed,
int
sg_ll_prevent_allow(int sg_fd, int prevent, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "prevent allow medium removal";
+ static const char * const cdb_s = "prevent allow medium removal";
int k, res, ret, sense_cat;
uint8_t p_cdb[PREVENT_ALLOW_CMDLEN] =
{PREVENT_ALLOW_CMD, 0, 0, 0, 0, 0};
@@ -1023,19 +1013,18 @@ sg_ll_prevent_allow(int sg_fd, int prevent, bool noisy, int verbose)
}
p_cdb[4] |= (prevent & 0x3);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < PREVENT_ALLOW_CMDLEN; ++k)
pr2ws("%02x ", p_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, p_cdb, sizeof(p_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 1b86d23d..96558883 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2018 Douglas Gilbert.
+ * Copyright (c) 1999-2019 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.
@@ -120,10 +120,10 @@ create_pt_obj(const char * cname)
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
- void * resp, int alloc_len, bool noisy, int verbose)
+ void * resp, int alloc_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Get LBA status(16)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "Get LBA status(16)";
+ int k, res, s_cat, ret;
uint8_t getLbaStatCmd[SERVICE_ACTION_IN_16_CMDLEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -135,37 +135,36 @@ sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
sg_put_unaligned_be64(start_llba, getLbaStatCmd + 2);
sg_put_unaligned_be32((uint32_t)alloc_len, getLbaStatCmd + 10);
getLbaStatCmd[14] = rt;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k)
pr2ws("%02x ", getLbaStatCmd[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, getLbaStatCmd, sizeof(getLbaStatCmd));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, alloc_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, alloc_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response\n", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response\n", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -182,10 +181,10 @@ sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
int
sg_ll_get_lba_status(int sg_fd, uint64_t start_llba, void * resp,
- int alloc_len, bool noisy, int verbose)
+ int alloc_len, bool noisy, int vb)
{
return sg_ll_get_lba_status16(sg_fd, start_llba, /* rt = */ 0x0, resp,
- alloc_len, noisy, verbose);
+ alloc_len, noisy, vb);
}
#define GLS32_CMD_LEN 32
@@ -194,10 +193,10 @@ int
sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
uint32_t element_id, uint8_t rt,
void * resp, int alloc_len, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "Get LBA status(32)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "Get LBA status(32)";
+ int k, res, s_cat, ret;
uint8_t gls32_cmd[GLS32_CMD_LEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -211,37 +210,36 @@ sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
sg_put_unaligned_be32(scan_len, gls32_cmd + 20);
sg_put_unaligned_be32(element_id, gls32_cmd + 24);
sg_put_unaligned_be32((uint32_t)alloc_len, gls32_cmd + 28);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < GLS32_CMD_LEN; ++k)
pr2ws("%02x ", gls32_cmd[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, gls32_cmd, sizeof(gls32_cmd));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, alloc_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, alloc_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response\n", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response\n", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -258,20 +256,20 @@ sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
int
sg_ll_report_tgt_prt_grp(int sg_fd, void * resp, int mx_resp_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
return sg_ll_report_tgt_prt_grp2(sg_fd, resp, mx_resp_len, false, noisy,
- verbose);
+ vb);
}
/* Invokes a SCSI REPORT TARGET PORT GROUPS command. Return of 0 -> success,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
- bool extended, bool noisy, int verbose)
+ bool extended, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Report target port groups";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Report target port groups";
+ int k, res, ret, s_cat;
uint8_t rtpg_cdb[MAINTENANCE_IN_CMDLEN] =
{MAINTENANCE_IN_CMD, REPORT_TGT_PRT_GRP_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -281,37 +279,36 @@ sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
if (extended)
rtpg_cdb[1] |= 0x20;
sg_put_unaligned_be32((uint32_t)mx_resp_len, rtpg_cdb + 6);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k)
pr2ws("%02x ", rtpg_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, rtpg_cdb, sizeof(rtpg_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -330,10 +327,10 @@ sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "Set target port groups";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Set target port groups";
+ int k, res, ret, s_cat;
uint8_t stpg_cdb[MAINTENANCE_OUT_CMDLEN] =
{MAINTENANCE_OUT_CMD, SET_TGT_PRT_GRP_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -341,35 +338,34 @@ sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)param_len, stpg_cdb + 6);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k)
pr2ws("%02x ", stpg_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ if ((vb > 1) && paramp && param_len) {
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, stpg_cdb, sizeof(stpg_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -383,10 +379,10 @@ sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
int
sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
void * resp, int mx_resp_len, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "Report referrals";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Report referrals";
+ int k, res, ret, s_cat;
uint8_t repRef_cdb[SERVICE_ACTION_IN_16_CMDLEN] =
{SERVICE_ACTION_IN_16_CMD, REPORT_REFERRALS_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -397,37 +393,36 @@ sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
sg_put_unaligned_be32((uint32_t)mx_resp_len, repRef_cdb + 10);
if (one_seg)
repRef_cdb[14] = 0x1;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k)
pr2ws("%02x ", repRef_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, repRef_cdb, sizeof(repRef_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -451,10 +446,10 @@ int
sg_ll_send_diag_pt(struct sg_pt_base * ptvp, int st_code, bool pf_bit,
bool st_bit, bool devofl_bit, bool unitofl_bit,
int long_duration, void * paramp, int param_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "Send diagnostic";
- int k, res, ret, sense_cat, tmout;
+ static const char * const cdb_s = "Send diagnostic";
+ int k, res, ret, s_cat, tmout;
uint8_t senddiag_cdb[SEND_DIAGNOSTIC_CMDLEN] =
{SEND_DIAGNOSTIC_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -474,36 +469,35 @@ sg_ll_send_diag_pt(struct sg_pt_base * ptvp, int st_code, bool pf_bit,
else
tmout = long_duration ? LONG_PT_TIMEOUT : DEF_PT_TIMEOUT;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SEND_DIAGNOSTIC_CMDLEN; ++k)
pr2ws("%02x ", senddiag_cdb[k]);
pr2ws("\n");
- if (verbose > 1) {
+ if (vb > 1) {
if (paramp && param_len) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
- pr2ws(" %s timeout: %d seconds\n", cdb_name_s, tmout);
+ pr2ws(" %s timeout: %d seconds\n", cdb_s, tmout);
}
}
set_scsi_pt_cdb(ptvp, senddiag_cdb, sizeof(senddiag_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, -1, tmout, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, -1, tmout, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -515,17 +509,17 @@ sg_ll_send_diag_pt(struct sg_pt_base * ptvp, int st_code, bool pf_bit,
int
sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
bool devofl_bit, bool unitofl_bit, int long_duration,
- void * paramp, int param_len, bool noisy, int verbose)
+ void * paramp, int param_len, bool noisy, int vb)
{
int ret;
struct sg_pt_base * ptvp;
- ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, vb);
if (NULL == ptvp)
return sg_convert_errno(ENOMEM);
ret = sg_ll_send_diag_pt(ptvp, st_code, pf_bit, st_bit, devofl_bit,
unitofl_bit, long_duration, paramp, param_len,
- noisy, verbose);
+ noisy, vb);
destruct_scsi_pt_obj(ptvp);
return ret;
}
@@ -535,11 +529,11 @@ sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
int
sg_ll_receive_diag_pt(struct sg_pt_base * ptvp, bool pcv, int pg_code,
void * resp, int mx_resp_len, int timeout_secs,
- int * residp, bool noisy, int verbose)
+ int * residp, bool noisy, int vb)
{
int resid = 0;
- int k, res, ret, sense_cat;
- static const char * const cdb_name_s = "Receive diagnostic results";
+ int k, res, ret, s_cat;
+ static const char * const cdb_s = "Receive diagnostic results";
uint8_t rcvdiag_cdb[RECEIVE_DIAGNOSTICS_CMDLEN] =
{RECEIVE_DIAGNOSTICS_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -549,8 +543,8 @@ sg_ll_receive_diag_pt(struct sg_pt_base * ptvp, bool pcv, int pg_code,
rcvdiag_cdb[2] = (uint8_t)(pg_code);
sg_put_unaligned_be16((uint16_t)mx_resp_len, rcvdiag_cdb + 3);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < RECEIVE_DIAGNOSTICS_CMDLEN; ++k)
pr2ws("%02x ", rcvdiag_cdb[k]);
pr2ws("\n");
@@ -561,28 +555,27 @@ sg_ll_receive_diag_pt(struct sg_pt_base * ptvp, bool pcv, int pg_code,
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, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, -1, timeout_secs, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, -1, timeout_secs, 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)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -601,16 +594,16 @@ sg_ll_receive_diag_pt(struct sg_pt_base * ptvp, bool pcv, int pg_code,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
- int mx_resp_len, bool noisy, int verbose)
+ int mx_resp_len, bool noisy, int vb)
{
int ret;
struct sg_pt_base * ptvp;
- ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, vb);
if (NULL == ptvp)
return sg_convert_errno(ENOMEM);
ret = sg_ll_receive_diag_pt(ptvp, pcv, pg_code, resp, mx_resp_len, 0,
- NULL, noisy, verbose);
+ NULL, noisy, vb);
destruct_scsi_pt_obj(ptvp);
return ret;
}
@@ -618,16 +611,16 @@ sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
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)
+ bool noisy, int vb)
{
int ret;
struct sg_pt_base * ptvp;
- ptvp = construct_scsi_pt_obj_with_fd(sg_fd, verbose);
+ ptvp = construct_scsi_pt_obj_with_fd(sg_fd, vb);
if (NULL == ptvp)
return sg_convert_errno(ENOMEM);
ret = sg_ll_receive_diag_pt(ptvp, pcv, pg_code, resp, mx_resp_len,
- timeout_secs, residp, noisy, verbose);
+ timeout_secs, residp, noisy, vb);
destruct_scsi_pt_obj(ptvp);
return ret;
}
@@ -636,10 +629,10 @@ sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist, int dl_format,
- void * resp, int mx_resp_len, bool noisy, int verbose)
+ void * resp, int mx_resp_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Read defect(10)";
- int res, k, ret, sense_cat;
+ static const char * const cdb_s = "Read defect(10)";
+ int res, k, ret, s_cat;
uint8_t rdef_cdb[READ_DEFECT10_CMDLEN] =
{READ_DEFECT10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -655,37 +648,36 @@ sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist, int dl_format,
pr2ws("mx_resp_len too big\n");
return -1;
}
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < READ_DEFECT10_CMDLEN; ++k)
pr2ws("%02x ", rdef_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, rdef_cdb, sizeof(rdef_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response\n", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response\n", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -704,10 +696,10 @@ sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist, int dl_format,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "Read media serial number";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Read media serial number";
+ int k, res, ret, s_cat;
uint8_t rmsn_cdb[SERVICE_ACTION_IN_12_CMDLEN] =
{SERVICE_ACTION_IN_12_CMD, READ_MEDIA_SERIAL_NUM_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -715,37 +707,36 @@ sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
struct sg_pt_base * ptvp;
sg_put_unaligned_be32((uint32_t)mx_resp_len, rmsn_cdb + 6);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_IN_12_CMDLEN; ++k)
pr2ws("%02x ", rmsn_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, rmsn_cdb, sizeof(rmsn_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -765,10 +756,10 @@ sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "Report identifying information";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Report identifying information";
+ int k, res, ret, s_cat;
uint8_t rii_cdb[MAINTENANCE_IN_CMDLEN] = {MAINTENANCE_IN_CMD,
REPORT_IDENTIFYING_INFORMATION_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -778,37 +769,36 @@ sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
sg_put_unaligned_be32((uint32_t)max_resp_len, rii_cdb + 6);
rii_cdb[10] |= (itype << 1) & 0xfe;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MAINTENANCE_IN_CMDLEN; ++k)
pr2ws("%02x ", rii_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, rii_cdb, sizeof(rii_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, max_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, max_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -828,10 +818,10 @@ sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "Set identifying information";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "Set identifying information";
+ int k, res, ret, s_cat;
uint8_t sii_cdb[MAINTENANCE_OUT_CMDLEN] = {MAINTENANCE_OUT_CMD,
SET_IDENTIFYING_INFORMATION_SA,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -840,35 +830,34 @@ sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
sg_put_unaligned_be32((uint32_t)param_len, sii_cdb + 6);
sii_cdb[10] |= (itype << 1) & 0xfe;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < MAINTENANCE_OUT_CMDLEN; ++k)
pr2ws("%02x ", sii_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ if ((vb > 1) && paramp && param_len) {
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, sii_cdb, sizeof(sii_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -883,11 +872,11 @@ sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
int
sg_ll_format_unit(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
bool cmplst, int dlist_format, int timeout_secs,
- void * paramp, int param_len, bool noisy, int verbose)
+ void * paramp, int param_len, bool noisy, int vb)
{
return sg_ll_format_unit_v2(sg_fd, fmtpinfo, longlist, fmtdata, cmplst,
dlist_format, 0, timeout_secs, paramp,
- param_len, noisy, verbose);
+ param_len, noisy, vb);
}
/* Invokes a FORMAT UNIT (SBC-3) command. Return of 0 -> success,
@@ -895,11 +884,11 @@ sg_ll_format_unit(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
int
sg_ll_format_unit2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
bool cmplst, int dlist_format, int ffmt, int timeout_secs,
- void * paramp, int param_len, bool noisy, int verbose)
+ void * paramp, int param_len, bool noisy, int vb)
{
return sg_ll_format_unit_v2(sg_fd, fmtpinfo, longlist, fmtdata, cmplst,
dlist_format, ffmt, timeout_secs, paramp,
- param_len, noisy, verbose);
+ param_len, noisy, vb);
}
/* Invokes a FORMAT UNIT (SBC-4) command. Return of 0 -> success,
@@ -909,10 +898,10 @@ int
sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
bool cmplst, int dlist_format, int ffmt,
int timeout_secs, void * paramp, int param_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "Format unit";
- int k, res, ret, sense_cat, tmout;
+ static const char * const cdb_s = "Format unit";
+ int k, res, ret, s_cat, tmout;
uint8_t fu_cdb[FORMAT_UNIT_CMDLEN] =
{FORMAT_UNIT_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -931,38 +920,37 @@ sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
if (ffmt)
fu_cdb[4] |= (ffmt & 0x3);
tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < 6; ++k)
pr2ws("%02x ", fu_cdb[k]);
pr2ws("\n");
- if (verbose > 1) {
+ if (vb > 1) {
if (param_len > 0) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
- pr2ws(" %s timeout: %d seconds\n", cdb_name_s, tmout);
+ pr2ws(" %s timeout: %d seconds\n", cdb_s, tmout);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, fu_cdb, sizeof(fu_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, tmout, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -976,10 +964,10 @@ sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist, void * paramp,
- int param_len, bool noisy, int verbose)
+ int param_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Reassign blocks";
- int res, k, ret, sense_cat;
+ static const char * const cdb_s = "Reassign blocks";
+ int res, k, ret, s_cat;
uint8_t reass_cdb[REASSIGN_BLKS_CMDLEN] =
{REASSIGN_BLKS_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -989,35 +977,34 @@ sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist, void * paramp,
reass_cdb[1] = 0x2;
if (longlist)
reass_cdb[1] |= 0x1;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < REASSIGN_BLKS_CMDLEN; ++k)
pr2ws("%02x ", reass_cdb[k]);
pr2ws("\n");
}
- if (verbose > 1) {
- pr2ws(" %s parameter list\n", cdb_name_s);
+ if (vb > 1) {
+ pr2ws(" %s parameter list\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, reass_cdb, sizeof(reass_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1032,10 +1019,10 @@ sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist, void * paramp,
* -1 -> other errors */
int
sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
- int mx_resp_len, bool noisy, int verbose)
+ int mx_resp_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Persistent reservation in";
- int res, k, ret, sense_cat;
+ static const char * const cdb_s = "Persistent reservation in";
+ int res, k, ret, s_cat;
uint8_t prin_cdb[PERSISTENT_RESERVE_IN_CMDLEN] =
{PERSISTENT_RESERVE_IN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1045,37 +1032,36 @@ sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
prin_cdb[1] = (uint8_t)(rq_servact & 0x1f);
sg_put_unaligned_be16((uint16_t)mx_resp_len, prin_cdb + 7);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < PERSISTENT_RESERVE_IN_CMDLEN; ++k)
pr2ws("%02x ", prin_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, prin_cdb, sizeof(prin_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -1096,10 +1082,10 @@ sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
int
sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
unsigned int rq_type, void * paramp,
- int param_len, bool noisy, int verbose)
+ int param_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "Persistent reservation out";
- int res, k, ret, sense_cat;
+ static const char * const cdb_s = "Persistent reservation out";
+ int res, k, ret, s_cat;
uint8_t prout_cdb[PERSISTENT_RESERVE_OUT_CMDLEN] =
{PERSISTENT_RESERVE_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1110,35 +1096,34 @@ sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
prout_cdb[2] = (((rq_scope & 0xf) << 4) | (rq_type & 0xf));
sg_put_unaligned_be16((uint16_t)param_len, prout_cdb + 7);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < PERSISTENT_RESERVE_OUT_CMDLEN; ++k)
pr2ws("%02x ", prout_cdb[k]);
pr2ws("\n");
- if (verbose > 1) {
- pr2ws(" %s parameters:\n", cdb_name_s);
+ if (vb > 1) {
+ pr2ws(" %s parameters:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, 0);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, prout_cdb, sizeof(prout_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1172,10 +1157,10 @@ has_blk_ili(uint8_t * sensep, int sb_len)
int
sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
void * resp, int xfer_len, int * offsetp, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "read long(10)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "read long(10)";
+ int k, res, s_cat, ret;
uint8_t readLong_cdb[READ_LONG10_CMDLEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -1189,25 +1174,24 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
sg_put_unaligned_be32((uint32_t)lba, readLong_cdb + 2);
sg_put_unaligned_be16((uint16_t)xfer_len, readLong_cdb + 7);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < READ_LONG10_CMDLEN; ++k)
pr2ws("%02x ", readLong_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, readLong_cdb, sizeof(readLong_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, xfer_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, xfer_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1226,7 +1210,7 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
*offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
- if (verbose > 1)
+ if (vb > 1)
pr2ws(" info field: 0x%" PRIx64 ", valid: %d, "
"ili: %d\n", ull, valid, ili);
ret = SG_LIB_CAT_ILLEGAL_REQ;
@@ -1234,13 +1218,13 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -1261,10 +1245,10 @@ sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
int
sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
void * resp, int xfer_len, int * offsetp, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "read long(16)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "read long(16)";
+ int k, res, s_cat, ret;
uint8_t readLong_cdb[SERVICE_ACTION_IN_16_CMDLEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -1279,25 +1263,24 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
sg_put_unaligned_be64(llba, readLong_cdb + 2);
sg_put_unaligned_be16((uint16_t)xfer_len, readLong_cdb + 12);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_IN_16_CMDLEN; ++k)
pr2ws("%02x ", readLong_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, readLong_cdb, sizeof(readLong_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, xfer_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, xfer_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1316,7 +1299,7 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
*offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
- if (verbose > 1)
+ if (vb > 1)
pr2ws(" info field: 0x%" PRIx64 ", valid: %d, "
"ili: %d\n", ull, (int)valid, (int)ili);
ret = SG_LIB_CAT_ILLEGAL_REQ;
@@ -1324,13 +1307,13 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -1351,10 +1334,10 @@ sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
int
sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
unsigned int lba, void * data_out, int xfer_len,
- int * offsetp, bool noisy, int verbose)
+ int * offsetp, bool noisy, int vb)
{
- static const char * const cdb_name_s = "write long(10)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "write long(10)";
+ int k, res, s_cat, ret;
uint8_t writeLong_cdb[WRITE_LONG10_CMDLEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -1370,25 +1353,24 @@ sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
sg_put_unaligned_be32((uint32_t)lba, writeLong_cdb + 2);
sg_put_unaligned_be16((uint16_t)xfer_len, writeLong_cdb + 7);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < (int)sizeof(writeLong_cdb); ++k)
pr2ws("%02x ", writeLong_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, writeLong_cdb, sizeof(writeLong_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)data_out, xfer_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1406,7 +1388,7 @@ sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
*offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
- if (verbose > 1)
+ if (vb > 1)
pr2ws(" info field: 0x%" PRIx64 ", valid: %d, "
"ili: %d\n", ull, (int)valid, (int)ili);
ret = SG_LIB_CAT_ILLEGAL_REQ;
@@ -1414,7 +1396,7 @@ sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1430,10 +1412,10 @@ sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
int
sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
uint64_t llba, void * data_out, int xfer_len,
- int * offsetp, bool noisy, int verbose)
+ int * offsetp, bool noisy, int vb)
{
- static const char * const cdb_name_s = "write long(16)";
- int k, res, sense_cat, ret;
+ static const char * const cdb_s = "write long(16)";
+ int k, res, s_cat, ret;
uint8_t writeLong_cdb[SERVICE_ACTION_OUT_16_CMDLEN];
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -1450,25 +1432,24 @@ sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
sg_put_unaligned_be64(llba, writeLong_cdb + 2);
sg_put_unaligned_be16((uint16_t)xfer_len, writeLong_cdb + 12);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SERVICE_ACTION_OUT_16_CMDLEN; ++k)
pr2ws("%02x ", writeLong_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, writeLong_cdb, sizeof(writeLong_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)data_out, xfer_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1487,7 +1468,7 @@ sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
*offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
- if (verbose > 1)
+ if (vb > 1)
pr2ws(" info field: 0x%" PRIx64 ", valid: %d, "
"ili: %d\n", ull, (int)valid, (int)ili);
ret = SG_LIB_CAT_ILLEGAL_REQ;
@@ -1495,7 +1476,7 @@ sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1513,10 +1494,10 @@ int
sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
unsigned int lba, int veri_len, void * data_out,
int data_out_len, unsigned int * infop, bool noisy,
- int verbose)
+ int vb)
{
- static const char * const cdb_name_s = "verify(10)";
- int k, res, ret, sense_cat, slen;
+ static const char * const cdb_s = "verify(10)";
+ int k, res, ret, s_cat, slen;
uint8_t v_cdb[VERIFY10_CMDLEN] =
{VERIFY10_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1528,31 +1509,30 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
v_cdb[1] |= 0x10;
sg_put_unaligned_be32((uint32_t)lba, v_cdb + 2);
sg_put_unaligned_be16((uint16_t)veri_len, v_cdb + 7);
- if (verbose > 1) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb > 1) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < VERIFY10_CMDLEN; ++k)
pr2ws("%02x ", v_cdb[k]);
pr2ws("\n");
- if ((verbose > 3) && bytchk && data_out && (data_out_len > 0)) {
+ if ((vb > 3) && bytchk && data_out && (data_out_len > 0)) {
k = data_out_len > 4104 ? 4104 : data_out_len;
pr2ws(" data_out buffer%s\n",
(data_out_len > 4104 ? ", first 4104 bytes" : ""));
- hex2stderr((const uint8_t *)data_out, k, verbose < 5);
+ hex2stderr((const uint8_t *)data_out, k, vb < 5);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, v_cdb, sizeof(v_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
if (data_out_len > 0)
set_scsi_pt_data_out(ptvp, (uint8_t *)data_out, data_out_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1573,7 +1553,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1590,10 +1570,10 @@ sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytchk,
int
sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba,
int veri_len, int group_num, void * data_out,
- int data_out_len, uint64_t * infop, bool noisy, int verbose)
+ int data_out_len, uint64_t * infop, bool noisy, int vb)
{
- static const char * const cdb_name_s = "verify(16)";
- int k, res, ret, sense_cat, slen;
+ static const char * const cdb_s = "verify(16)";
+ int k, res, ret, s_cat, slen;
uint8_t v_cdb[VERIFY16_CMDLEN] =
{VERIFY16_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1606,31 +1586,30 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba,
sg_put_unaligned_be64(llba, v_cdb + 2);
sg_put_unaligned_be32((uint32_t)veri_len, v_cdb + 10);
v_cdb[14] = group_num & 0x1f;
- if (verbose > 1) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb > 1) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < VERIFY16_CMDLEN; ++k)
pr2ws("%02x ", v_cdb[k]);
pr2ws("\n");
- if ((verbose > 3) && bytchk && data_out && (data_out_len > 0)) {
+ if ((vb > 3) && bytchk && data_out && (data_out_len > 0)) {
k = data_out_len > 4104 ? 4104 : data_out_len;
pr2ws(" data_out buffer%s\n",
(data_out_len > 4104 ? ", first 4104 bytes" : ""));
- hex2stderr((const uint8_t *)data_out, k, verbose < 5);
+ hex2stderr((const uint8_t *)data_out, k, vb < 5);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return sg_convert_errno(ENOMEM);
set_scsi_pt_cdb(ptvp, v_cdb, sizeof(v_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
if (data_out_len > 0)
set_scsi_pt_data_out(ptvp, (uint8_t *)data_out, data_out_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
@@ -1651,7 +1630,7 @@ sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytchk, uint64_t llba,
}
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1685,7 +1664,7 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
int timeout_secs, void * dinp, void * doutp, int dlen,
uint8_t * sensep, int max_sense_len,
uint8_t * ata_return_dp, int max_ata_return_len,
- int * residp, int verbose)
+ int * residp, int vb)
{
int k, res, slen, duration;
int ret = -1;
@@ -1725,7 +1704,7 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
return -1;
}
if (NULL == cdbp) {
- if (verbose)
+ if (vb)
pr2ws("%s NULL cdb pointer\n", cnamep);
return -1;
}
@@ -1736,7 +1715,7 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
sp = sense_b;
slen = sizeof(sense_b);
}
- if (verbose) {
+ if (vb) {
pr2ws(" %s cdb: ", cnamep);
if (cdb_len < 32) {
for (k = 0; k < cdb_len; ++k)
@@ -1759,21 +1738,21 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
}
res = do_scsi_pt(ptvp, sg_fd,
((timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT),
- verbose);
+ vb);
if (SCSI_PT_DO_BAD_PARAMS == res) {
- if (verbose)
+ if (vb)
pr2ws("%s: bad parameters\n", cnamep);
goto out;
} else if (SCSI_PT_DO_TIMEOUT == res) {
- if (verbose)
+ if (vb)
pr2ws("%s: timeout\n", cnamep);
goto out;
} else if (res > 2) {
- if (verbose)
+ if (vb)
pr2ws("%s: do_scsi_pt: errno=%d\n", cnamep, -res);
}
- if ((verbose > 2) && ((duration = get_scsi_pt_duration_ms(ptvp)) >= 0))
+ if ((vb > 2) && ((duration = get_scsi_pt_duration_ms(ptvp)) >= 0))
pr2ws(" duration=%d ms\n", duration);
switch (get_scsi_pt_result_category(ptvp)) {
@@ -1814,17 +1793,17 @@ sg_ll_ata_pt(int sg_fd, const uint8_t * cdbp, int cdb_len,
ret = get_scsi_pt_status_response(ptvp);
break;
case SCSI_PT_RESULT_TRANSPORT_ERR:
- if (verbose)
+ if (vb)
pr2ws("%s: transport error: %s\n", cnamep,
get_scsi_pt_transport_err_str(ptvp, sizeof(b), b));
break;
case SCSI_PT_RESULT_OS_ERR:
- if (verbose)
+ if (vb)
pr2ws("%s: os error: %s\n", cnamep,
get_scsi_pt_os_err_str(ptvp, sizeof(b) , b));
break;
default:
- if (verbose)
+ if (vb)
pr2ws("%s: unknown pt_result_category=%d\n", cnamep,
get_scsi_pt_result_category(ptvp));
break;
@@ -1839,10 +1818,10 @@ out:
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
- void * resp, int mx_resp_len, bool noisy, int verbose)
+ void * resp, int mx_resp_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "read buffer(10)";
- int res, k, ret, sense_cat;
+ static const char * const cdb_s = "read buffer(10)";
+ int res, k, ret, s_cat;
uint8_t rbuf_cdb[READ_BUFFER_CMDLEN] =
{READ_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1852,37 +1831,36 @@ sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
rbuf_cdb[2] = (uint8_t)(buffer_id & 0xff);
sg_put_unaligned_be24((uint32_t)buffer_offset, rbuf_cdb + 3);
sg_put_unaligned_be24((uint32_t)mx_resp_len, rbuf_cdb + 6);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < READ_BUFFER_CMDLEN; ++k)
pr2ws("%02x ", rbuf_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, rbuf_cdb, sizeof(rbuf_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -1901,10 +1879,10 @@ sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
- void * paramp, int param_len, bool noisy, int verbose)
+ void * paramp, int param_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "write buffer";
- int k, res, ret, sense_cat;
+ static const char * const cdb_s = "write buffer";
+ int k, res, ret, s_cat;
uint8_t wbuf_cdb[WRITE_BUFFER_CMDLEN] =
{WRITE_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1914,14 +1892,14 @@ sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
wbuf_cdb[2] = (uint8_t)(buffer_id & 0xff);
sg_put_unaligned_be24((uint32_t)buffer_offset, wbuf_cdb + 3);
sg_put_unaligned_be24((uint32_t)param_len, wbuf_cdb + 6);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < WRITE_BUFFER_CMDLEN; ++k)
pr2ws("%02x ", wbuf_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list", cdb_name_s);
- if (2 == verbose) {
+ if ((vb > 1) && paramp && param_len) {
+ pr2ws(" %s parameter list", cdb_s);
+ if (2 == vb) {
pr2ws("%s:\n", (param_len > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)paramp,
(param_len > 256 ? 256 : param_len), -1);
@@ -1932,24 +1910,23 @@ sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, wbuf_cdb, sizeof(wbuf_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -1970,9 +1947,9 @@ int
sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
uint32_t buffer_offset, void * paramp,
uint32_t param_len, int timeout_secs, bool noisy,
- int verbose)
+ int vb)
{
- int k, res, ret, sense_cat;
+ int k, res, ret, s_cat;
uint8_t wbuf_cdb[WRITE_BUFFER_CMDLEN] =
{WRITE_BUFFER_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -1991,12 +1968,12 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
wbuf_cdb[2] = (uint8_t)(buffer_id & 0xff);
sg_put_unaligned_be24(buffer_offset, wbuf_cdb + 3);
sg_put_unaligned_be24(param_len, wbuf_cdb + 6);
- if (verbose) {
+ if (vb) {
pr2ws(" Write buffer cdb: ");
for (k = 0; k < WRITE_BUFFER_CMDLEN; ++k)
pr2ws("%02x ", wbuf_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
+ if ((vb > 1) && paramp && param_len) {
pr2ws(" Write buffer parameter list%s:\n",
((param_len > 256) ? " (first 256 bytes)" : ""));
hex2stderr((const uint8_t *)paramp,
@@ -2014,19 +1991,18 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
set_scsi_pt_cdb(ptvp, wbuf_cdb, sizeof(wbuf_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, timeout_secs, verbose);
- ret = sg_cmds_process_resp(ptvp, "Write buffer", res, SG_NO_DATA_IN,
- sense_b, noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, timeout_secs, vb);
+ ret = sg_cmds_process_resp(ptvp, "Write buffer", res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -2040,20 +2016,20 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_unmap(int sg_fd, int group_num, int timeout_secs, void * paramp,
- int param_len, bool noisy, int verbose)
+ int param_len, bool noisy, int vb)
{
return sg_ll_unmap_v2(sg_fd, false, group_num, timeout_secs, paramp,
- param_len, noisy, verbose);
+ param_len, noisy, vb);
}
/* Invokes a SCSI UNMAP (SBC-3) command. Version 2 adds anchor field
* (sbc3r22). Otherwise same as sg_ll_unmap() . */
int
sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
- void * paramp, int param_len, bool noisy, int verbose)
+ void * paramp, int param_len, bool noisy, int vb)
{
- static const char * const cdb_name_s = "unmap";
- int k, res, ret, sense_cat, tmout;
+ static const char * const cdb_s = "unmap";
+ int k, res, ret, s_cat, tmout;
uint8_t u_cdb[UNMAP_CMDLEN] =
{UNMAP_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -2064,35 +2040,34 @@ sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT;
u_cdb[6] = group_num & 0x1f;
sg_put_unaligned_be16((uint16_t)param_len, u_cdb + 7);
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < UNMAP_CMDLEN; ++k)
pr2ws("%02x ", u_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ if ((vb > 1) && paramp && param_len) {
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, u_cdb, sizeof(u_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, tmout, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -2105,46 +2080,45 @@ sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
* 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 verbose)
+ bool noisy, int vb)
{
- static const char * const cdb_name_s = "read block limits";
- int k, ret, res, sense_cat;
+ static const char * const cdb_s = "read block limits";
+ int k, ret, res, s_cat;
uint8_t rl_cdb[READ_BLOCK_LIMITS_CMDLEN] =
{READ_BLOCK_LIMITS_CMD, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < READ_BLOCK_LIMITS_CMDLEN; ++k)
pr2ws("%02x ", rl_cdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, rl_cdb, sizeof(rl_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else {
- if ((verbose > 2) && (ret > 0)) {
- pr2ws(" %s: response", cdb_name_s);
- if (3 == verbose) {
+ if ((vb > 2) && (ret > 0)) {
+ pr2ws(" %s: response", cdb_s);
+ if (3 == vb) {
pr2ws("%s:\n", (ret > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (ret > 256 ? 256 : ret),
-1);
@@ -2164,9 +2138,9 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
- int mx_resp_len, bool noisy, int verbose)
+ int mx_resp_len, bool noisy, int vb)
{
- int k, res, ret, sense_cat;
+ int k, res, ret, s_cat;
uint8_t rcvcopyres_cdb[THIRD_PARTY_COPY_IN_CMDLEN] =
{THIRD_PARTY_COPY_IN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -2181,7 +2155,7 @@ sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
sg_put_unaligned_be32((uint32_t)list_id, rcvcopyres_cdb + 2);
sg_put_unaligned_be32((uint32_t)mx_resp_len, rcvcopyres_cdb + 10);
- if (verbose) {
+ if (vb) {
pr2ws(" %s cdb: ", b);
for (k = 0; k < THIRD_PARTY_COPY_IN_CMDLEN; ++k)
pr2ws("%02x ", rcvcopyres_cdb[k]);
@@ -2193,19 +2167,18 @@ sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
set_scsi_pt_cdb(ptvp, rcvcopyres_cdb, sizeof(rcvcopyres_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, b, res, mx_resp_len, sense_b, noisy,
- verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, b, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -2224,47 +2197,46 @@ sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
* various SG_LIB_CAT_* positive values or -1 -> other errors */
int
sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, bool noisy,
- int verbose)
+ int vb)
{
- int k, res, ret, sense_cat;
+ int k, res, ret, s_cat;
uint8_t xcopy_cdb[THIRD_PARTY_COPY_OUT_CMDLEN] =
{THIRD_PARTY_COPY_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
- const char * opcode_name = "Extended copy (LID1)";
+ const char * cdb_s = "Extended copy (LID1)";
xcopy_cdb[1] = (uint8_t)(EXTENDED_COPY_LID1_SA & 0x1f);
sg_put_unaligned_be32((uint32_t)param_len, xcopy_cdb + 10);
- if (verbose) {
- pr2ws(" %s cdb: ", opcode_name);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < THIRD_PARTY_COPY_OUT_CMDLEN; ++k)
pr2ws("%02x ", xcopy_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list:\n", opcode_name);
+ if ((vb > 1) && paramp && param_len) {
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
- if (NULL == ((ptvp = create_pt_obj(opcode_name))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, xcopy_cdb, sizeof(xcopy_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, opcode_name, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, vb);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -2281,9 +2253,9 @@ sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, bool noisy,
int
sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
int timeout_secs, void * paramp, int param_len,
- bool noisy, int verbose)
+ bool noisy, int vb)
{
- int k, res, ret, sense_cat, tmout;
+ int k, res, ret, s_cat, tmout;
uint8_t xcopy_cdb[THIRD_PARTY_COPY_OUT_CMDLEN] =
{THIRD_PARTY_COPY_OUT_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t sense_b[SENSE_BUFF_LEN];
@@ -2313,12 +2285,12 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
}
tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT;
- if (verbose) {
+ if (vb) {
pr2ws(" %s cdb: ", cname);
for (k = 0; k < THIRD_PARTY_COPY_OUT_CMDLEN; ++k)
pr2ws("%02x ", xcopy_cdb[k]);
pr2ws("\n");
- if ((verbose > 1) && paramp && param_len) {
+ if ((vb > 1) && paramp && param_len) {
pr2ws(" %s parameter list:\n", cname);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
@@ -2329,19 +2301,18 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
set_scsi_pt_cdb(ptvp, xcopy_cdb, sizeof(xcopy_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
- ret = sg_cmds_process_resp(ptvp, cname, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ res = do_scsi_pt(ptvp, sg_fd, tmout, vb);
+ ret = sg_cmds_process_resp(ptvp, cname, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
@@ -2362,13 +2333,13 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
int
sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
uint64_t lba, uint32_t num_blocks, int group_num,
- int timeout_secs, bool noisy, int verbose)
+ int timeout_secs, bool noisy, int vb)
{
static const char * const cdb10_name_s = "Pre-fetch(10)";
static const char * const cdb16_name_s = "Pre-fetch(16)";
static const char * const cdb_seek_name_s = "Seek(10)";
- int k, res, sense_cat, ret, cdb_len, tmout;
- const char *cdb_name_s;
+ int k, res, s_cat, ret, cdb_len, tmout;
+ const char *cdb_s;
uint8_t preFetchCdb[PRE_FETCH16_CMDLEN]; /* all use longest cdb */
uint8_t sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -2376,27 +2347,27 @@ sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
memset(preFetchCdb, 0, sizeof(preFetchCdb));
if (do_seek10) {
if (lba > UINT32_MAX) {
- if (verbose)
+ if (vb)
pr2ws("%s: LBA exceeds 2**32 in %s\n", __func__,
cdb_seek_name_s);
return -1;
}
preFetchCdb[0] = SEEK10_CMD;
cdb_len = SEEK10_CMDLEN;
- cdb_name_s = cdb_seek_name_s;
+ cdb_s = cdb_seek_name_s;
sg_put_unaligned_be32((uint32_t)lba, preFetchCdb + 2);
} else {
if ((! cdb16) &&
((lba > UINT32_MAX) || (num_blocks > UINT16_MAX))) {
cdb16 = true;
- if (noisy || verbose)
+ if (noisy || vb)
pr2ws("%s: do %s due to %s size\n", __func__, cdb16_name_s,
(lba > UINT32_MAX) ? "LBA" : "NUM_BLOCKS");
}
if (cdb16) {
preFetchCdb[0] = PRE_FETCH16_CMD;
cdb_len = PRE_FETCH16_CMDLEN;
- cdb_name_s = cdb16_name_s;
+ cdb_s = cdb16_name_s;
if (immed)
preFetchCdb[1] = 0x2;
sg_put_unaligned_be64(lba, preFetchCdb + 2);
@@ -2405,7 +2376,7 @@ sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
} else {
preFetchCdb[0] = PRE_FETCH10_CMD;
cdb_len = PRE_FETCH10_CMDLEN;
- cdb_name_s = cdb10_name_s;
+ cdb_s = cdb10_name_s;
if (immed)
preFetchCdb[1] = 0x2;
sg_put_unaligned_be32((uint32_t)lba, preFetchCdb + 2);
@@ -2414,39 +2385,38 @@ sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
}
}
tmout = (timeout_secs > 0) ? timeout_secs : DEF_PT_TIMEOUT;
- if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ if (vb) {
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < cdb_len; ++k)
pr2ws("%02x ", preFetchCdb[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, preFetchCdb, cdb_len);
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
- res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
+ res = do_scsi_pt(ptvp, sg_fd, tmout, vb);
if (0 == res) {
int sstat = get_scsi_pt_status_response(ptvp);
if (SG_LIB_CAT_CONDITION_MET == sstat) {
ret = SG_LIB_CAT_CONDITION_MET;
- if (verbose > 2)
+ if (vb > 2)
pr2ws("%s: returns SG_LIB_CAT_CONDITION_MET\n", __func__);
goto fini;
}
}
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, vb, &s_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
- switch (sense_cat) {
+ switch (s_cat) {
case SG_LIB_CAT_RECOVERED:
case SG_LIB_CAT_NO_SENSE:
ret = 0;
break;
default:
- ret = sense_cat;
+ ret = s_cat;
break;
}
} else
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
index 64ed9997..b80e988f 100644
--- a/lib/sg_cmds_mmc.c
+++ b/lib/sg_cmds_mmc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2018 Douglas Gilbert.
+ * Copyright (c) 2008-2019 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.
@@ -59,7 +59,7 @@ int
sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
int drv_write_speed, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "set cd speed";
+ static const char * const cdb_s = "set cd speed";
int res, ret, k, sense_cat;
uint8_t scsCmdBlk[SET_CD_SPEED_CMDLEN] = {SET_CD_SPEED_CMD, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
@@ -71,18 +71,17 @@ sg_ll_set_cd_speed(int sg_fd, int rot_control, int drv_read_speed,
sg_put_unaligned_be16((uint16_t)drv_write_speed, scsCmdBlk + 4);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SET_CD_SPEED_CMDLEN; ++k)
pr2ws("%02x ", scsCmdBlk[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, scsCmdBlk, sizeof(scsCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -117,7 +116,7 @@ int
sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "get configuration";
+ static const char * const cdb_s = "get configuration";
int res, k, ret, sense_cat;
uint8_t gcCmdBlk[GET_CONFIG_CMD_LEN] = {GET_CONFIG_CMD, 0, 0, 0,
0, 0, 0, 0, 0, 0};
@@ -141,20 +140,19 @@ sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
sg_put_unaligned_be16((uint16_t)mx_resp_len, gcCmdBlk + 7);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < GET_CONFIG_CMD_LEN; ++k)
pr2ws("%02x ", gcCmdBlk[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, gcCmdBlk, sizeof(gcCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -183,7 +181,7 @@ sg_ll_get_config(int sg_fd, int rt, int starting, void * resp,
if (len < 0)
len = 0;
len = (ret < len) ? ret : len;
- pr2ws(" %s: response:\n", cdb_name_s);
+ pr2ws(" %s: response:\n", cdb_s);
if (3 == verbose) {
pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (len > 256 ? 256 : len),
@@ -208,7 +206,7 @@ sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
int max_num_desc, int ttype, void * resp,
int mx_resp_len, bool noisy, int verbose)
{
- static const char * const cdb_name_s = "get performance";
+ static const char * const cdb_s = "get performance";
int res, k, ret, sense_cat;
uint8_t gpCmdBlk[GET_PERFORMANCE_CMD_LEN] = {GET_PERFORMANCE_CMD, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -233,20 +231,19 @@ sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
gpCmdBlk[10] = (uint8_t)ttype;
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < GET_PERFORMANCE_CMD_LEN; ++k)
pr2ws("%02x ", gpCmdBlk[k]);
pr2ws("\n");
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, gpCmdBlk, sizeof(gpCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -275,7 +272,7 @@ sg_ll_get_performance(int sg_fd, int data_type, unsigned int starting_lba,
if (len < 0)
len = 0;
len = (ret < len) ? ret : len;
- pr2ws(" %s: response", cdb_name_s);
+ pr2ws(" %s: response", cdb_s);
if (3 == verbose) {
pr2ws("%s:\n", (len > 256 ? ", first 256 bytes" : ""));
hex2stderr((const uint8_t *)resp, (len > 256 ? 256 : len),
@@ -300,7 +297,7 @@ int
sg_ll_set_streaming(int sg_fd, int type, void * paramp, int param_len,
bool noisy, int verbose)
{
- static const char * const cdb_name_s = "set streaming";
+ static const char * const cdb_s = "set streaming";
int k, res, ret, sense_cat;
uint8_t ssCmdBlk[SET_STREAMING_CMDLEN] =
{SET_STREAMING_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -310,24 +307,23 @@ sg_ll_set_streaming(int sg_fd, int type, void * paramp, int param_len,
ssCmdBlk[8] = type;
sg_put_unaligned_be16((uint16_t)param_len, ssCmdBlk + 9);
if (verbose) {
- pr2ws(" %s cdb: ", cdb_name_s);
+ pr2ws(" %s cdb: ", cdb_s);
for (k = 0; k < SET_STREAMING_CMDLEN; ++k)
pr2ws("%02x ", ssCmdBlk[k]);
pr2ws("\n");
if ((verbose > 1) && paramp && param_len) {
- pr2ws(" %s parameter list:\n", cdb_name_s);
+ pr2ws(" %s parameter list:\n", cdb_s);
hex2stderr((const uint8_t *)paramp, param_len, -1);
}
}
- if (NULL == ((ptvp = create_pt_obj(cdb_name_s))))
+ if (NULL == ((ptvp = create_pt_obj(cdb_s))))
return -1;
set_scsi_pt_cdb(ptvp, ssCmdBlk, sizeof(ssCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cdb_name_s, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cdb_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 465aa3e0..3e40c111 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2018 Douglas Gilbert.
+ * Copyright (c) 1999-2019 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.
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 5b40fd49..fd4176b3 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -19,7 +19,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "2.60 20190108";/* spc5r20, sbc4r15 */
+const char * sg_lib_version_str = "2.61 20190113";/* spc5r20, sbc4r15 */
/* indexed by pdt; those that map to own index do not decay */
diff --git a/lib/sg_pt_common.c b/lib/sg_pt_common.c
index 14e48ae6..ffd76c1d 100644
--- a/lib/sg_pt_common.c
+++ b/lib/sg_pt_common.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2018 Douglas Gilbert.
+ * Copyright (c) 2009-2019 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.
@@ -31,7 +31,7 @@
#include "sg_pt_nvme.h"
#endif
-static const char * scsi_pt_version_str = "3.09 20180712";
+static const char * scsi_pt_version_str = "3.10 20190113";
const char *
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index 73c376bd..3c38dbe6 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_freebsd version 1.33 20190102 */
+/* sg_pt_freebsd version 1.34 20190113 */
#include <stdio.h>
#include <stdlib.h>
@@ -88,7 +88,7 @@ struct sg_pt_freebsd_scsi {
int sense_len;
uint8_t * dxferp;
int dxfer_len;
- int dxfer_dir;
+ int dxfer_dir; /* CAM_DIR_NONE, _IN, _OUT and _BOTH */
uint8_t * dxferip;
uint8_t * dxferop;
uint8_t * mdxferp;
@@ -544,7 +544,10 @@ set_scsi_pt_data_in(struct sg_pt_base * vp, uint8_t * dxferp,
if (dxfer_len > 0) {
ptp->dxferp = dxferp;
ptp->dxfer_len = dxfer_len;
- ptp->dxfer_dir = CAM_DIR_IN;
+ if (ptp->dxfer_dir == CAM_DIR_OUT)
+ ptp->dxfer_dir = CAM_DIR_BOTH;
+ else
+ ptp->dxfer_dir = CAM_DIR_IN;
}
}
@@ -562,7 +565,10 @@ set_scsi_pt_data_out(struct sg_pt_base * vp, const uint8_t * dxferp,
if (dxfer_len > 0) {
ptp->dxferp = (uint8_t *)dxferp;
ptp->dxfer_len = dxfer_len;
- ptp->dxfer_dir = CAM_DIR_OUT;
+ if (ptp->dxfer_dir == CAM_DIR_IN)
+ ptp->dxfer_dir = CAM_DIR_BOTH;
+ else
+ ptp->dxfer_dir = CAM_DIR_OUT;
}
}
@@ -769,7 +775,49 @@ get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
- return ptp->nvme_direct ? 0 : ptp->resid;
+ return ((NULL == ptp) || ptp->nvme_direct) ? 0 : ptp->resid;
+}
+
+void
+get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
+ int * req_doutp)
+{
+ const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
+ bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH);
+
+ if (req_dinp) {
+ if (ptp->dxfer_ilen > 0)
+ *req_dinp = ptp->dxfer_ilen;
+ else
+ *req_dinp = 0;
+ }
+ if (req_doutp) {
+ if ((!bidi) && (ptp->dxfer_olen > 0))
+ *req_doutp = ptp->dxfer_olen;
+ else
+ *req_doutp = 0;
+ }
+}
+
+void
+get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
+ int * act_doutp)
+{
+ const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
+ bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH);
+
+ if (act_dinp) {
+ if (ptp->dxfer_ilen > 0)
+ *act_dinp = ptp->dxfer_ilen - ptp->resid;
+ else
+ *act_dinp = 0;
+ }
+ if (act_doutp) {
+ if ((!bidi) && (ptp->dxfer_olen > 0))
+ *act_doutp = ptp->dxfer_olen - ptp->resid;
+ else
+ *act_doutp = 0;
+ }
}
/* Returns SCSI status value (from device that received the command). If an
@@ -825,6 +873,14 @@ get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return ptp->sense_len - ptp->sense_resid;
}
+uint8_t *
+get_scsi_pt_sense_buf(const struct sg_pt_base * vp)
+{
+ const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
+
+ return ptp->sense;
+}
+
/* Not impemented so return -1 . */
int
get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused)))
@@ -1118,7 +1174,7 @@ nvme_pt_low(struct freebsd_dev_channel *fdc_p, void * dxferp, uint32_t len,
if (err < 0)
return -errno; /* Assume Unix error in normal place */
sct_sc = (NVME_STATUS_GET_SCT(npcp->cpl.status) << 8) |
- NVME_STATUS_GET_SC(npcp->cpl.status);
+ NVME_STATUS_GET_SC(npcp->cpl.status);
fdc_p->nvme_result = npcp->cpl.cdw0;
sg_put_unaligned_le32(npcp->cpl.cdw0,
fdc_p->cq_dw0_3 + SG_NVME_PT_CQ_RESULT);
@@ -1130,7 +1186,7 @@ nvme_pt_low(struct freebsd_dev_channel *fdc_p, void * dxferp, uint32_t len,
fdc_p->cq_dw0_3 + SG_NVME_PT_CQ_STATUS_P);
if (sct_sc && (vb > 1)) {
char nam[64];
-
+
sg_get_nvme_opcode_name(opcode, true, sizeof(nam), nam);
pr2ws("%s: %s [0x%x], status: %s\n", __func__, nam, opcode,
sg_get_nvme_cmd_status_str(sct_sc, sizeof(b), b));
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 1f43e227..0b50e439 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2018 Douglas Gilbert.
+ * Copyright (c) 2005-2019 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.
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_linux version 1.44 20181212 */
+/* sg_pt_linux version 1.46 20190111 */
#include <stdio.h>
@@ -680,15 +680,67 @@ set_scsi_pt_flags(struct sg_pt_base * vp, int flags)
}
}
+/* If supported it is the number of bytes requested to transfer less the
+ * number actually transferred. This it typically important for data-in
+ * transfers. For data-out (only) transfers, the 'dout_req_len -
+ * dout_act_len' is returned. For bidi transfer the "din" residual is
+ * returned. */
/* N.B. Returns din_resid and ignores dout_resid */
int
get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
- if (NULL == ptp)
+ if ((NULL == ptp) || (ptp->nvme_direct))
return 0;
- return ptp->nvme_direct ? 0 : ptp->io_hdr.din_resid;
+ else if ((ptp->io_hdr.din_xfer_len > 0) &&
+ (ptp->io_hdr.dout_xfer_len > 0))
+ return ptp->io_hdr.din_resid;
+ else if (ptp->io_hdr.dout_xfer_len > 0)
+ return ptp->io_hdr.dout_resid;
+ return ptp->io_hdr.din_resid;
+}
+
+void
+get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
+ int * req_doutp)
+{
+ const struct sg_pt_linux_scsi * ptp = &vp->impl;
+
+ if (req_dinp) {
+ if (ptp->io_hdr.din_xfer_len > 0)
+ *req_dinp = ptp->io_hdr.din_xfer_len;
+ else
+ *req_dinp = 0;
+ }
+ if (req_doutp) {
+ if (ptp->io_hdr.dout_xfer_len > 0)
+ *req_doutp = ptp->io_hdr.dout_xfer_len;
+ else
+ *req_doutp = 0;
+ }
+}
+
+void
+get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
+ int * act_doutp)
+{
+ const struct sg_pt_linux_scsi * ptp = &vp->impl;
+
+ if (act_dinp) {
+ if (ptp->io_hdr.din_xfer_len > 0) {
+ int res = ptp->io_hdr.din_xfer_len - ptp->io_hdr.din_resid;
+
+ *act_dinp = (res > 0) ? res : 0;
+ } else
+ *act_dinp = 0;
+ }
+ if (act_doutp) {
+ if (ptp->io_hdr.dout_xfer_len > 0)
+ *act_doutp = ptp->io_hdr.dout_xfer_len - ptp->io_hdr.dout_resid;
+ else
+ *act_doutp = 0;
+ }
}
int
@@ -721,6 +773,14 @@ get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return ptp->io_hdr.response_len;
}
+uint8_t *
+get_scsi_pt_sense_buf(const struct sg_pt_base * vp)
+{
+ const struct sg_pt_linux_scsi * ptp = &vp->impl;
+
+ return (uint8_t *)ptp->io_hdr.response;
+}
+
int
get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
{
diff --git a/lib/sg_pt_linux_nvme.c b/lib/sg_pt_linux_nvme.c
index abb928cc..227af330 100644
--- a/lib/sg_pt_linux_nvme.c
+++ b/lib/sg_pt_linux_nvme.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 Douglas Gilbert.
+ * Copyright (c) 2017-2019 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.
@@ -41,7 +41,7 @@
* MA 02110-1301, USA.
*/
-/* sg_pt_linux_nvme version 1.05 20180602 */
+/* sg_pt_linux_nvme version 1.06 20190113 */
/* This file contains a small "SPC-only" SNTL to support the SES pass-through
* of SEND DIAGNOSTIC and RECEIVE DIAGNOSTIC RESULTS through NVME-MI
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c
index f041ec00..6a003022 100644
--- a/lib/sg_pt_osf1.c
+++ b/lib/sg_pt_osf1.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2018 Douglas Gilbert.
+ * Copyright (c) 2005-2019 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.
@@ -30,6 +30,7 @@
#include "sg_lib.h"
#include "sg_pr2serr.h"
+/* Version 2.00 20190113 */
#define OSF1_MAXDEV 64
@@ -69,7 +70,6 @@ struct sg_pt_base {
};
-
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
int
scsi_pt_open_device(const char * device_name, bool read_only, int verbose)
@@ -462,6 +462,49 @@ get_scsi_pt_resid(const struct sg_pt_base * vp)
return ptp->resid;
}
+void
+get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
+ int * req_doutp)
+{
+ const struct sg_pt_osf1_scsi * ptp = &vp->impl;
+ bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH);
+
+ if (req_dinp) {
+ if (ptp->dxfer_len > 0)
+ *req_dinp = ptp->dxfer_len;
+ else
+ *req_dinp = 0;
+ }
+ if (req_doutp) {
+ if ((!bidi) && (ptp->dxfer_len > 0))
+ *req_doutp = ptp->dxfer_len;
+ else
+ *req_doutp = 0;
+ }
+}
+
+void
+get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
+ int * act_doutp)
+{
+ const struct sg_pt_osf1_scsi * ptp = &vp->impl;
+ bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH);
+
+ if (act_dinp) {
+ if (ptp->dxfer_len > 0)
+ *act_dinp = ptp->dxfer_len - ptp->resid;
+ else
+ *act_dinp = 0;
+ }
+ if (act_doutp) {
+ if ((!bidi) && (ptp->dxfer_len > 0))
+ *act_doutp = ptp->dxfer_len - ptp->resid;
+ else
+ *act_doutp = 0;
+ }
+}
+
+
int
get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
diff --git a/lib/sg_pt_solaris.c b/lib/sg_pt_solaris.c
index 9c3904f6..7353b448 100644
--- a/lib/sg_pt_solaris.c
+++ b/lib/sg_pt_solaris.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2018 Douglas Gilbert.
+ * Copyright (c) 2007-2019 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.
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_solaris version 1.10 20180808 */
+/* sg_pt_solaris version 1.11 20190113 */
#include <stdio.h>
#include <stdlib.h>
@@ -331,6 +331,50 @@ get_scsi_pt_resid(const struct sg_pt_base * vp)
return ptp->uscsi.uscsi_resid;
}
+void
+get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
+ int * req_doutp)
+{
+ const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
+ int dxfer_len = ptp->uscsi.uscsi_buflen
+ int flags = ptp->uscsi.uscsi_flags;
+
+ if (req_dinp) {
+ if ((dxfer_len > 0) && (USCSI_READ & flags))
+ *req_dinp = dxfer_len;
+ else
+ *req_dinp = 0;
+ }
+ if (req_doutp) {
+ if ((ptp->dxfer_len > 0) && (USCSI_WRITE & flags))
+ *req_doutp = dxfer_len;
+ else
+ *req_doutp = 0;
+ }
+}
+
+void
+get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
+ int * act_doutp)
+{
+ const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
+ int dxfer_len = ptp->uscsi.uscsi_buflen
+ int flags = ptp->uscsi.uscsi_flags;
+
+ if (act_dinp) {
+ if ((dxfer_len > 0) && (USCSI_READ & flags))
+ *act_dinp = dxfer_len - ptp->uscsi.uscsi_resid;
+ else
+ *act_dinp = 0;
+ }
+ if (act_doutp) {
+ if ((ptp->dxfer_len > 0) && (USCSI_WRITE & flags))
+ *act_doutp = dxfer_len - ptp->uscsi.uscsi_resid;
+ else
+ *act_doutp = 0;
+ }
+}
+
int
get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
@@ -352,6 +396,14 @@ get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return 0;
}
+uint8_t *
+get_scsi_pt_sense_buf(const struct sg_pt_base * vp)
+{
+ const struct sg_pt_solaris_scsi * ptp = &vp->impl;
+
+ return (uint8_t *)ptp->uscsi.uscsi_rqbuf;
+}
+
int
get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
{
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index 2b5fb837..72c0cc95 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018 Douglas Gilbert.
+ * Copyright (c) 2006-2019 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.
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_win32 version 1.28 20180615 */
+/* sg_pt_win32 version 1.29 20190111 */
#include <stdio.h>
#include <stdlib.h>
@@ -1272,6 +1272,47 @@ get_scsi_pt_resid(const struct sg_pt_base * vp)
return psp->resid;
}
+void
+get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp,
+ int * req_doutp)
+{
+ const struct sg_pt_win32_scsi * psp = vp->implp;
+
+ if (req_dinp) {
+ if (psp->is_read (&& psp->dxfer_len > 0))
+ *req_dinp = psp->dxfer_len;
+ else
+ *req_dinp = 0;
+ }
+ if (req_doutp) {
+ if ((! psp->is_read) && (psp->dxfer_len > 0))
+ *req_doutp = psp->dxfer_len;
+ else
+ *req_doutp = 0;
+ }
+}
+
+void
+get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp,
+ int * act_doutp)
+{
+ const struct sg_pt_win32_scsi * psp = vp->implp;
+
+ if (act_dinp) {
+ if (psp->is_read (&& psp->dxfer_len > 0))
+ *act_dinp = psp->dxfer_len - psp->resid;
+ else
+ *act_dinp = 0;
+ }
+ if (act_doutp) {
+ if ((! psp->is_read) && (psp->dxfer_len > 0))
+ *act_doutp = psp->dxfer_len - psp->resid;
+ else
+ *act_doutp = 0;
+ }
+}
+
+
int
get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
diff --git a/src/sg_bg_ctl.c b/src/sg_bg_ctl.c
index dfdcbc46..0f2128af 100644
--- a/src/sg_bg_ctl.c
+++ b/src/sg_bg_ctl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2018 Douglas Gilbert.
+ * Copyright (c) 2016-2019 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.
@@ -35,7 +35,7 @@
* device. Based on sbc4r10.pdf .
*/
-static const char * version_str = "1.09 20180625";
+static const char * version_str = "1.10 20190113";
#define BACKGROUND_CONTROL_SA 0x15
@@ -115,8 +115,8 @@ sg_ll_background_control(int sg_fd, unsigned int bo_ctl, unsigned int bo_time,
set_scsi_pt_cdb(ptvp, bcCDB, sizeof(bcCDB));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cmd_name, res, SG_NO_DATA_IN, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cmd_name, res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_compare_and_write.c b/src/sg_compare_and_write.c
index 2ac3304f..784907e4 100644
--- a/src/sg_compare_and_write.c
+++ b/src/sg_compare_and_write.c
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2012-2018, Kaminario Technologies LTD
+* Copyright (c) 2012-2019, Kaminario Technologies LTD
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.25 20180625";
+static const char * version_str = "1.26 20190113";
#define DEF_BLOCK_SIZE 512
#define DEF_NUM_BLOCKS (1)
@@ -381,8 +381,7 @@ sg_ll_compare_and_write(int sg_fd, uint8_t * buff, int blocks,
}
res = do_scsi_pt(ptvp, sg_fd, DEF_TIMEOUT_SECS, verbose);
ret = sg_cmds_process_resp(ptvp, "COMPARE AND WRITE", res,
- SG_NO_DATA_IN, sense_b, noisy, verbose,
- &sense_cat);
+ noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_format.c b/src/sg_format.c
index a75208d4..12fa78d1 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -6,7 +6,7 @@
*
* Copyright (C) 2003 Grant Grundler grundler at parisc-linux dot org
* Copyright (C) 2003 James Bottomley jejb at parisc-linux dot org
- * Copyright (C) 2005-2018 Douglas Gilbert dgilbert at interlog dot com
+ * Copyright (C) 2005-2019 Douglas Gilbert dgilbert at interlog dot com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@
#include "sg_pr2serr.h"
#include "sg_pt.h"
-static const char * version_str = "1.57 20190107";
+static const char * version_str = "1.58 20190113";
#define RW_ERROR_RECOVERY_PAGE 1 /* can give alternate with --mode=MP */
@@ -281,8 +281,8 @@ sg_ll_format_medium(int sg_fd, bool verify, bool immed, int format,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, transfer_len);
res = do_scsi_pt(ptvp, sg_fd, timeout, verbose);
- ret = sg_cmds_process_resp(ptvp, "format medium", res, transfer_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "format medium", res, noisy,
+ verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c
index 49e2ac1c..52032cd1 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.65 20190108"; /* spc5r20 */
+static const char * version_str = "0.66 20190113"; /* spc5r20 */
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
@@ -223,8 +223,7 @@ do_rsoc(struct sg_pt_base * ptvp, bool rctd, int rep_opts, int rq_opcode,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, -1, DEF_TIMEOUT_SECS, verbose);
- ret = sg_cmds_process_resp(ptvp, rsoc_s, res, mx_resp_len, sense_b, noisy,
- verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, rsoc_s, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -278,8 +277,8 @@ do_rstmf(struct sg_pt_base * ptvp, bool repd, void * resp, int mx_resp_len,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, -1, DEF_TIMEOUT_SECS, verbose);
- ret = sg_cmds_process_resp(ptvp, rstmf_s, res, mx_resp_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, rstmf_s, res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_read_attr.c b/src/sg_read_attr.c
index 4925b905..50e3e751 100644
--- a/src/sg_read_attr.c
+++ b/src/sg_read_attr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2018 Douglas Gilbert.
+ * Copyright (c) 2016-2019 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.
@@ -39,7 +39,7 @@
* and decodes the response. Based on spc5r08.pdf
*/
-static const char * version_str = "1.11 20180523";
+static const char * version_str = "1.12 20190113";
#define MAX_RATTR_BUFF_LEN (1024 * 1024)
#define DEF_RATTR_BUFF_LEN (1024 * 8)
@@ -280,8 +280,8 @@ sg_ll_read_attr(int sg_fd, void * resp, int * residp, bool noisy,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, op->maxlen);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, op->verbose);
- ret = sg_cmds_process_resp(ptvp, "read attribute", res, op->maxlen,
- sense_b, noisy, op->verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "read attribute", res, noisy,
+ op->verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index 812de8c2..9f92f255 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -35,7 +35,7 @@
* device.
*/
-static const char * version_str = "1.26 20190108"; /* spc5r20 */
+static const char * version_str = "1.27 20190113"; /* spc5r20 */
#ifndef SG_READ_BUFFER_10_CMD
@@ -181,8 +181,8 @@ sg_ll_read_buffer_10(int sg_fd, int rb_mode, int rb_mode_sp, int rb_id,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "Read buffer(10)", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "Read buffer(10)", res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -245,8 +245,8 @@ sg_ll_read_buffer_16(int sg_fd, int rb_mode, int rb_mode_sp, int rb_id,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "Read buffer(16)", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "Read buffer(16)", res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_rep_zones.c b/src/sg_rep_zones.c
index c9619344..02bdb773 100644
--- a/src/sg_rep_zones.c
+++ b/src/sg_rep_zones.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2018 Douglas Gilbert.
+ * Copyright (c) 2014-2019 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 @@
* and decodes the response. Based on zbc-r02.pdf
*/
-static const char * version_str = "1.17 20180628";
+static const char * version_str = "1.17 20190113";
#define MAX_RZONES_BUFF_LEN (1024 * 1024)
#define DEF_RZONES_BUFF_LEN (1024 * 8)
@@ -154,8 +154,8 @@ sg_ll_report_zones(int sg_fd, uint64_t zs_lba, bool partial, int report_opts,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "report zones", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "report zones", res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_reset_wp.c b/src/sg_reset_wp.c
index 1dc6cab6..40a2ffdb 100644
--- a/src/sg_reset_wp.c
+++ b/src/sg_reset_wp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2018 Douglas Gilbert.
+ * Copyright (c) 2014-2019 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.
@@ -37,7 +37,7 @@
* device. Based on zbc-r04c.pdf .
*/
-static const char * version_str = "1.12 20180628";
+static const char * version_str = "1.13 20190113";
#define SG_ZONING_OUT_CMDLEN 16
#define RESET_WRITE_POINTER_SA 0x4
@@ -110,9 +110,8 @@ sg_ll_reset_write_pointer(int sg_fd, uint64_t zid, uint16_t zc, bool all,
set_scsi_pt_cdb(ptvp, rwp_cdb, sizeof(rwp_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "reset write pointer", res,
- SG_NO_DATA_IN, sense_b, noisy, verbose,
- &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "reset write pointer", res, noisy,
+ verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index 6d6fc11a..b4c7a0ec 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2018 Douglas Gilbert.
+ * Copyright (c) 2011-2019 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.
@@ -33,7 +33,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.11 20180628";
+static const char * version_str = "1.12 20190113";
/* Not all environments support the Unix sleep() */
#if defined(MSC_VER) || defined(__MINGW32__)
@@ -242,8 +242,8 @@ do_sanitize(int sg_fd, const struct opts_t * op, const void * param_lstp,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)param_lstp, param_lst_len);
res = do_scsi_pt(ptvp, sg_fd, timeout, op->verbose);
- ret = sg_cmds_process_resp(ptvp, "Sanitize", res, SG_NO_DATA_IN, sense_b,
- true /*noisy */, op->verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "Sanitize", res, true /*noisy */,
+ op->verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_stream_ctl.c b/src/sg_stream_ctl.c
index 3f5eef2d..cf6ff5f4 100644
--- a/src/sg_stream_ctl.c
+++ b/src/sg_stream_ctl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Douglas Gilbert.
+ * Copyright (c) 2018-2019 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.
@@ -35,7 +35,7 @@
* to the given SCSI device. Based on sbc4r15.pdf .
*/
-static const char * version_str = "1.06 20180628";
+static const char * version_str = "1.07 20190113";
#define STREAM_CONTROL_SA 0x14
#define GET_STREAM_STATUS_SA 0x16
@@ -139,8 +139,8 @@ sg_ll_get_stream_status(int sg_fd, uint16_t s_str_id, uint8_t * resp,
set_scsi_pt_data_in(ptvp, resp, alloc_len);
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cmd_name, res, alloc_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cmd_name, res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -205,8 +205,8 @@ sg_ll_stream_control(int sg_fd, uint32_t str_ctl, uint16_t str_id,
set_scsi_pt_data_in(ptvp, resp, alloc_len);
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, cmd_name, res, alloc_len, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cmd_name, res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_sync.c b/src/sg_sync.c
index d300354a..fd81686a 100644
--- a/src/sg_sync.c
+++ b/src/sg_sync.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2018 Douglas Gilbert.
+ * Copyright (c) 2004-2019 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.
@@ -37,7 +37,7 @@
* (e.g. disks).
*/
-static const char * version_str = "1.23 20180628";
+static const char * version_str = "1.24 20190113";
#define SYNCHRONIZE_CACHE16_CMD 0x91
#define SYNCHRONIZE_CACHE16_CMDLEN 16
@@ -127,8 +127,7 @@ sg_ll_sync_cache_16(int sg_fd, bool sync_nv, bool immed, int group,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, to_secs, verbose);
ret = sg_cmds_process_resp(ptvp, "synchronize cache(16)", res,
- SG_NO_DATA_IN, sense_b, noisy, verbose,
- &sense_cat);
+ noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_timestamp.c b/src/sg_timestamp.c
index 18ddab4f..ea1e1dd8 100644
--- a/src/sg_timestamp.c
+++ b/src/sg_timestamp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2018 Douglas Gilbert.
+ * Copyright (c) 2015-2019 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.
@@ -37,7 +37,7 @@
* to the given SCSI device. Based on spc5r07.pdf .
*/
-static const char * version_str = "1.12 20180910";
+static const char * version_str = "1.13 20180113";
#define REP_TIMESTAMP_CMDLEN 12
#define SET_TIMESTAMP_CMDLEN 12
@@ -217,8 +217,8 @@ sg_ll_rep_timestamp(int sg_fd, void * resp, int mx_resp_len, int * residp,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "report timestamp", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "report timestamp", res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
@@ -280,8 +280,8 @@ sg_ll_set_timestamp(int sg_fd, void * paramp, int param_len, bool noisy,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "set timestamp", res, SG_NO_DATA_IN,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "set timestamp", res, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_turs.c b/src/sg_turs.c
index 8c6e3792..d8016aa9 100644
--- a/src/sg_turs.c
+++ b/src/sg_turs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2018 D. Gilbert
+ * Copyright (C) 2000-2019 D. Gilbert
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -42,7 +42,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "3.44 20180712";
+static const char * version_str = "3.45 20190113";
#if defined(MSC_VER) || defined(__MINGW32__)
#define HAVE_MS_SLEEP
@@ -330,9 +330,8 @@ loop_turs(struct sg_pt_base * ptvp, struct loop_res_t * resp,
set_scsi_pt_cdb(ptvp, cdb, sizeof(cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
rs = do_scsi_pt(ptvp, -1, DEF_PT_TIMEOUT, vb);
- n = sg_cmds_process_resp(ptvp, "Test unit ready", rs,
- SG_NO_DATA_IN, sense_b,
- (0 == k), vb, &sense_cat);
+ n = sg_cmds_process_resp(ptvp, "Test unit ready", rs, (0 == k),
+ vb, &sense_cat);
if (-1 == n) {
resp->ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
return k;
diff --git a/src/sg_write_same.c b/src/sg_write_same.c
index d1e7d4e9..a1721c41 100644
--- a/src/sg_write_same.c
+++ b/src/sg_write_same.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2018 Douglas Gilbert.
+ * Copyright (c) 2009-2019 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.
@@ -33,7 +33,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.26 20180723";
+static const char * version_str = "1.27 20190113";
#define ME "sg_write_same: "
@@ -270,9 +270,8 @@ do_write_same(int sg_fd, const struct opts_t * op, const void * dataoutp,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)dataoutp, op->xfer_len);
res = do_scsi_pt(ptvp, sg_fd, op->timeout, op->verbose);
- ret = sg_cmds_process_resp(ptvp, "Write same", res, SG_NO_DATA_IN,
- sense_b, true /*noisy */, op->verbose,
- &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "Write same", res, true /*noisy */,
+ op->verbose, &sense_cat);
if (-1 == ret)
get_scsi_pt_os_err(ptvp);
else if (-2 == ret) {
diff --git a/src/sg_write_verify.c b/src/sg_write_verify.c
index 781cdd4c..ab19607c 100644
--- a/src/sg_write_verify.c
+++ b/src/sg_write_verify.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2018 Douglas Gilbert
+ * Copyright (c) 2014-2019 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.
@@ -40,7 +40,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.15 20180628";
+static const char * version_str = "1.16 20190113";
#define ME "sg_write_verify: "
@@ -152,8 +152,7 @@ run_scsi_transaction(int sg_fd, const uint8_t *cdbp, int cdb_len,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, dop, do_len);
res = do_scsi_pt(ptvp, sg_fd, timeout, verbose);
- ret = sg_cmds_process_resp(ptvp, b, res, SG_NO_DATA_IN, sense_b, noisy,
- verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, b, res, noisy, verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_write_x.c b/src/sg_write_x.c
index fa84c76b..c610fa00 100644
--- a/src/sg_write_x.c
+++ b/src/sg_write_x.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 Douglas Gilbert.
+ * Copyright (c) 2017-2019 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 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.19 20180628";
+static const char * version_str = "1.20 20190113";
/* Protection Information refers to 8 bytes of extra information usually
* associated with each logical block and is often abbreviated to PI while
@@ -1329,8 +1329,8 @@ do_write_x(int sg_fd, const void * dataoutp, int dout_len,
pr2serr("%s: dout_len==0, so empty dout buffer\n",
op->cdb_name);
res = do_scsi_pt(ptvp, sg_fd, op->timeout, vb);
- ret = sg_cmds_process_resp(ptvp, op->cdb_name, res, SG_NO_DATA_IN,
- sense_b, true /*noisy */, vb, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, op->cdb_name, res, true /*noisy */, vb,
+ &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/src/sg_zone.c b/src/sg_zone.c
index b7f8391f..e4b2bccf 100644
--- a/src/sg_zone.c
+++ b/src/sg_zone.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2018 Douglas Gilbert.
+ * Copyright (c) 2014-2019 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.
@@ -37,7 +37,7 @@
* to the given SCSI device. Based on zbc-r04c.pdf .
*/
-static const char * version_str = "1.12 20180628";
+static const char * version_str = "1.13 20190113";
#define SG_ZONING_OUT_CMDLEN 16
#define CLOSE_ZONE_SA 0x1
@@ -142,9 +142,8 @@ sg_ll_zone_out(int sg_fd, int sa, uint64_t zid, uint16_t zc, bool all,
set_scsi_pt_cdb(ptvp, zo_cdb, sizeof(zo_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "reset write pointer", res,
- SG_NO_DATA_IN, sense_b, noisy, verbose,
- &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "reset write pointer", res, noisy,
+ verbose, &sense_cat);
if (-1 == ret)
ret = sg_convert_errno(get_scsi_pt_os_err(ptvp));
else if (-2 == ret) {
diff --git a/testing/bsg_queue_tst.c b/testing/bsg_queue_tst.c
index af0c42b8..011dcab3 100644
--- a/testing/bsg_queue_tst.c
+++ b/testing/bsg_queue_tst.c
@@ -20,7 +20,7 @@
The default behaviour is to "queue at head" which is useful for
error processing but not for streaming READ and WRITE commands.
-* Copyright (C) 2010-2016 D. Gilbert
+* Copyright (C) 2010-2019 D. Gilbert
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -29,7 +29,7 @@
Invocation: bsg_queue_tst [-t] <bsg_device>
-t queue at tail
- Version 0.90 (20100324)
+ Version 0.91 (20190111)
*/
@@ -55,7 +55,7 @@ int main(int argc, char * argv[])
uint8_t inq_cdb[INQ_CMD_LEN] =
{0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
uint8_t sdiag_cdb[SDIAG_CMD_LEN] =
- {0x1d, 0, 0, 0, 0, 0};
+ {0x1d, 0x10 /* PF */, 0, 0, 0, 0};
uint8_t inqBuff[16][INQ_REPLY_LEN];
struct sg_io_v4 io_hdr[16];
struct sg_io_v4 rio_hdr;
diff --git a/testing/sg_queue_tst.c b/testing/sg_queue_tst.c
index dcdeabdd..064d3885 100644
--- a/testing/sg_queue_tst.c
+++ b/testing/sg_queue_tst.c
@@ -15,7 +15,7 @@
* Invocation: sg_queue_tst [-l=Q_LEN] [-t] <sg_device>
* -t queue at tail
*
- * Version 0.94 (20190109)
+ * Version 0.95 (20190111)
*/
#include <unistd.h>
@@ -104,7 +104,7 @@ int main(int argc, char * argv[])
uint8_t inq_cdb[INQ_CMD_LEN] =
{0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
uint8_t sdiag_cdb[SDIAG_CMD_LEN] =
- {0x1d, 0, 0, 0, 0, 0};
+ {0x1d, 0x10 /* PF */, 0, 0, 0, 0};
uint8_t inqBuff[MAX_Q_LEN][INQ_REPLY_LEN];
sg_io_hdr_t io_hdr[MAX_Q_LEN];
sg_io_hdr_t rio_hdr;
diff --git a/testing/sg_tst_async.cpp b/testing/sg_tst_async.cpp
index 6b7a3e84..9c34b7a3 100644
--- a/testing/sg_tst_async.cpp
+++ b/testing/sg_tst_async.cpp
@@ -811,7 +811,6 @@ work_sync_thread(int id, const char * dev_name, unsigned int /* hi_lba */,
++thr_sync_starts;
rs = do_scsi_pt(ptp, -1, DEF_PT_TIMEOUT, vb);
n = sg_cmds_process_resp(ptp, "Test unit ready", rs,
- SG_NO_DATA_IN, sense_b,
(0 == k), vb, &sense_cat);
if (-1 == n) {
ret = sg_convert_errno(get_scsi_pt_os_err(ptp));
diff --git a/testing/sg_tst_bidi.c b/testing/sg_tst_bidi.c
index 7f6f54db..6a308995 100644
--- a/testing/sg_tst_bidi.c
+++ b/testing/sg_tst_bidi.c
@@ -52,7 +52,7 @@
is implemented by the scsi_debug driver is used. */
-static const char * version_str = "Version: 1.00 20190110";
+static const char * version_str = "Version: 1.01 20190111";
#define INQ_REPLY_LEN 96
#define INQ_CMD_OP 0x12
@@ -315,7 +315,7 @@ main(int argc, char * argv[])
uint8_t inq_cdb[INQ_CMD_LEN] =
{INQ_CMD_OP, 0, 0, 0, INQ_REPLY_LEN, 0};
uint8_t sdiag_cdb[SDIAG_CMD_LEN] =
- {SDIAG_CMD_OP, 0, 0, 0, 0, 0};
+ {SDIAG_CMD_OP, 0x10 /* PF */, 0, 0, 0, 0};
uint8_t xdwrrd10_cdb[XDWRITEREAD_10_LEN] =
{XDWRITEREAD_10_OP, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
uint8_t inqBuff[MAX_Q_LEN][INQ_REPLY_LEN];
@@ -424,7 +424,7 @@ main(int argc, char * argv[])
second_fname, sg_fd2);
}
-#if 0
+#if 1
printf("start write() calls\n");
for (k = 0; k < q_len; ++k) {
io_v4p = &io_v4[k];
@@ -436,26 +436,25 @@ main(int argc, char * argv[])
if (0 == (k % 3)) {
io_v4p->request_len = XDWRITEREAD_10_LEN;
io_v4p->request = (uint64_t)xdwrrd10_cdb;
- io_hdr[k].dxfer_direction = SG_DXFER_NONE;
+ // io_hdr[k].dxfer_direction = SG_DXFER_NONE;
} else {
- io_hdr[k].cmd_len = sizeof(inq_cdb);
- io_hdr[k].cmdp = inq_cdb;
- io_hdr[k].dxfer_direction = SG_DXFER_FROM_DEV;
- io_hdr[k].dxfer_len = INQ_REPLY_LEN;
- io_hdr[k].dxferp = inqBuff[k];
+ io_v4p->response_len = sizeof(inq_cdb);
+ io_v4p->response = inq_cdb;
+ io_v4p->din_xfer_len = INQ_REPLY_LEN;
+ io_v4p->din_xferp = (uint64_t)inqBuff[k];
}
- io_hdr[k].sbp = sense_buffer[k];
- io_hdr[k].mx_sb_len = SENSE_BUFFER_LEN;
- io_hdr[k].timeout = 20000; /* 20000 millisecs == 20 seconds */
- io_hdr[k].pack_id = k + 3; /* so pack_id doesn't start at 0 */
+ io_v4p->response = (uint64_t)sense_buffer[k];
+ io_v4p->max_response_len = SENSE_BUFFER_LEN;
+ io_v4p->timeout = 20000; /* 20000 millisecs == 20 seconds */
+ io_v4p->request_extra = k + 3; /* so pack_id doesn't start at 0 */
/* default is to queue at head (in SCSI mid level) */
if (q_at_tail)
- io_hdr[k].flags |= SG_FLAG_Q_AT_TAIL;
+ io_v4p->flags |= SG_FLAG_Q_AT_TAIL;
else
- io_hdr[k].flags |= SG_FLAG_Q_AT_HEAD;
- /* io_hdr[k].usr_ptr = NULL; */
+ io_v4p->flags |= SG_FLAG_Q_AT_HEAD;
+ /* io_v4p->usr_ptr = NULL; */
- if (write(sg_fd, &io_hdr[k], sizeof(sg_io_hdr_t)) < 0) {
+ if (write(sg_fd, io_v4p, sizeof(* io_v4p)) < 0) {
pr2serr("%ssg write errno=%d [%s]\n", cp, errno, strerror(errno));
close(sg_fd);
return 1;
diff --git a/testing/sg_tst_ioctl.c b/testing/sg_tst_ioctl.c
index e7127597..0ae34175 100644
--- a/testing/sg_tst_ioctl.c
+++ b/testing/sg_tst_ioctl.c
@@ -53,7 +53,7 @@
* later of the Linux sg driver. */
-static const char * version_str = "Version: 1.02 20190106";
+static const char * version_str = "Version: 1.02 20190111";
#define INQ_REPLY_LEN 96
#define INQ_CMD_LEN 6
@@ -451,7 +451,7 @@ main(int argc, char * argv[])
uint8_t inq_cdb[INQ_CMD_LEN] =
{0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
uint8_t sdiag_cdb[SDIAG_CMD_LEN] =
- {0x1d, 0, 0, 0, 0, 0};
+ {0x1d, 0x10 /* PF */, 0, 0, 0, 0};
uint8_t inqBuff[MAX_Q_LEN][INQ_REPLY_LEN];
sg_io_hdr_t io_hdr[MAX_Q_LEN];
sg_io_hdr_t rio_hdr;
diff --git a/testing/sg_tst_nvme.c b/testing/sg_tst_nvme.c
index 6ba16476..6ec9734e 100644
--- a/testing/sg_tst_nvme.c
+++ b/testing/sg_tst_nvme.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Douglas Gilbert
+ * Copyright (c) 2018-2019 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.
@@ -39,7 +39,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-static const char * version_str = "1.05 20181207";
+static const char * version_str = "1.06 20190113";
#define ME "sg_tst_nvme: "
@@ -539,8 +539,7 @@ sg_scsi_inquiry(struct sg_pt_base * ptvp, bool evpd, int pg_op, void * resp,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (uint8_t *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, -1, timeout_secs, vb);
- ret = sg_cmds_process_resp(ptvp, "inquiry", res, mx_resp_len, sense_b,
- noisy, vb, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "inquiry", res, noisy, vb, &sense_cat);
resid = get_scsi_pt_resid(ptvp);
if (residp)
*residp = resid;