aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-01-22 04:23:22 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-01-22 04:23:22 +0000
commit2bb9e742c191f73cf50ad5e113fef7bf88f46f61 (patch)
tree1475ccb6a8003948033315eee968918e3eaff5c1
parent07b9f9dcf8c2f836be3d35ac35a457a993de23e0 (diff)
downloadsg3_utils-2bb9e742c191f73cf50ad5e113fef7bf88f46f61.tar.gz
sg_cmds_extra: fix sa bug in sg_ll_3party_copy_out()
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@546 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog3
-rw-r--r--include/sg_cmds_extra.h8
-rw-r--r--lib/sg_cmds_extra.c33
3 files changed, 20 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 1fc1aff5..fc10ddfd 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.38 [20140117] [svn: r545]
+Changelog for sg3_utils-1.38 [20140121] [svn: r546]
- sg_ses: add --dev-slot-num= and --sas-addr=
- fix --data=- problem with large buffers
- new --data=@FN to read hex data from file FN
@@ -27,6 +27,7 @@ Changelog for sg3_utils-1.38 [20140117] [svn: r545]
- sg_write_same: repeat if unit attention
- sg_rtpg: fix indexing bug with --extended option
- sg_lib_data: sync asc/ascq codes with T10 dated 20131110
+ - sg_cmds_extra: fix sa bug in sg_ll_3party_copy_out()
- examples: add sg_tst_excl3 for testing O_EXCL
- improve sg_tst_excl and sg_tst_excl2
- add sg_tst_context for testing file handle contexts
diff --git a/include/sg_cmds_extra.h b/include/sg_cmds_extra.h
index 198d33ce..fa019eeb 100644
--- a/include/sg_cmds_extra.h
+++ b/include/sg_cmds_extra.h
@@ -273,7 +273,9 @@ int sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock,
int sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
int mx_resp_len, int noisy, int verbose);
-/* Invokes a SCSI EXTENDED COPY(LID1) command. Return of 0 -> success,
+/* Invokes a SCSI EXTENDED COPY(LID1) command. For EXTENDED COPY(LID4)
+ * including POPULATE TOKEN and WRITE USING TOKEN use
+ * sg_ll_3party_copy_out(). Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Extended copy not supported,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
@@ -282,8 +284,8 @@ int sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, int noisy,
int verbose);
/* Handles various service actions associated with opcode 0x83 which is
- * called THIRD PARTY COPY OUT. These include the EXTENDED COPY(LID4) and
- * WRITE USING TOKEN commands. Return of 0 -> success,
+ * called THIRD PARTY COPY OUT. These include the EXTENDED COPY(LID4),
+ * POPULATE TOKEN and WRITE USING TOKEN commands. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> opcode 0x83 not supported,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index d359b2e0..4831123f 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -83,10 +83,6 @@
#define READ_MEDIA_SERIAL_NUM_SA 0x1
#define REPORT_IDENTIFYING_INFORMATION_SA 0x5
#define REPORT_TGT_PRT_GRP_SA 0xa
-#define RECEIVE_COPY_RES_COPY_STATUS_SA 0x00
-#define RECEIVE_COPY_RES_RECEIVE_DATA_SA 0x01
-#define RECEIVE_COPY_RES_OPERATING_PARMS_SA 0x03
-#define RECEIVE_COPY_RES_FAILED_SEGMENT_DETAILS_SA 0x04
#define SET_IDENTIFYING_INFORMATION_SA 0x6
#define SET_TGT_PRT_GRP_SA 0xa
#define WRITE_LONG_16_SA 0x11
@@ -2385,23 +2381,22 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
{EXTENDED_COPY_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
- const char * opcode_name = "bad sa";
+ char cname[80];
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
+ sg_get_opcode_sa_name(EXTENDED_COPY_CMD, sa, 0, sizeof(cname), cname);
+ xcopyCmdBlk[1] = (unsigned char)(sa & 0x1f);
switch (sa) {
- case 0x0:
- case 0x1:
- opcode_name = (0x0 == sa) ? "Extended copy (LID1)" :
- "Extended copy (LID4)";
+ case 0x0: /* XCOPY(LID1) */
+ case 0x1: /* XCOPY(LID4) */
xcopyCmdBlk[10] = (unsigned char)((param_len >> 24) & 0xff);
xcopyCmdBlk[11] = (unsigned char)((param_len >> 16) & 0xff);
xcopyCmdBlk[12] = (unsigned char)((param_len >> 8) & 0xff);
xcopyCmdBlk[13] = (unsigned char)(param_len & 0xff);
break;
- case 0x10:
- case 0x11:
- opcode_name = (0x10 == sa) ? "Populate token" : "Write using token";
+ case 0x10: /* POPULATE TOKEN (SBC-3) */
+ case 0x11: /* WRITE USING TOKEN (SBC-3) */
xcopyCmdBlk[6] = (unsigned char)((list_id >> 24) & 0xff);
xcopyCmdBlk[7] = (unsigned char)((list_id >> 16) & 0xff);
xcopyCmdBlk[8] = (unsigned char)((list_id >> 8) & 0xff);
@@ -2412,8 +2407,7 @@ sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id, int group_num,
xcopyCmdBlk[13] = (unsigned char)(param_len & 0xff);
xcopyCmdBlk[14] = (unsigned char)(group_num & 0x1f);
break;
- case 0x1c:
- opcode_name = "Copy operation abort";
+ case 0x1c: /* COPY OPERATION ABORT */
xcopyCmdBlk[2] = (unsigned char)((list_id >> 24) & 0xff);
xcopyCmdBlk[3] = (unsigned char)((list_id >> 16) & 0xff);
xcopyCmdBlk[4] = (unsigned char)((list_id >> 8) & 0xff);
@@ -2427,28 +2421,27 @@ 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) {
- fprintf(sg_warnings_strm, " %s cmd: ", opcode_name);
+ fprintf(sg_warnings_strm, " %s cmd: ", cname);
for (k = 0; k < EXTENDED_COPY_CMDLEN; ++k)
fprintf(sg_warnings_strm, "%02x ", xcopyCmdBlk[k]);
fprintf(sg_warnings_strm, "\n");
if ((verbose > 1) && paramp && param_len) {
- fprintf(sg_warnings_strm, " %s parameter list:\n",
- opcode_name);
+ fprintf(sg_warnings_strm, " %s parameter list:\n", cname);
dStrHexErr((const char *)paramp, param_len, -1);
}
}
ptvp = construct_scsi_pt_obj();
if (NULL == ptvp) {
- fprintf(sg_warnings_strm, "%s: out of memory\n", opcode_name);
+ fprintf(sg_warnings_strm, "%s: out of memory\n", cname);
return -1;
}
set_scsi_pt_cdb(ptvp, xcopyCmdBlk, sizeof(xcopyCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (unsigned char *)paramp, param_len);
res = do_scsi_pt(ptvp, sg_fd, tmout, verbose);
- ret = sg_cmds_process_resp(ptvp, opcode_name, res, 0, sense_b,
- noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, cname, res, 0, sense_b, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
;
else if (-2 == ret) {