[PATCH] added CDB_CONTROL macro to get control field from CDB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John A. Chandy <john.chandy@xxxxxxxxx>

Fixes a bug in tgt/usr/scsi.c where the code expects the SCSI CONTROL
field in the last byte of the CDB.  This doesn't work for VARLEN CDBs
like OSD where the CONTROL field is the second byte of the CDB.

Signed-off-by: John Chandy <john.chandy at uconn.edu>
---
 usr/scsi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/usr/scsi.c b/usr/scsi.c
index 4ec81d1..3d46ac1 100644
--- a/usr/scsi.c
+++ b/usr/scsi.c
@@ -43,6 +43,8 @@ static unsigned char scsi_command_size[8] = {6, 10, 10, 12, 16, 12, 10, 10};
 #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
 #define CDB_SIZE(cmd) (((((cmd)->scb[0] >> 5) & 7) < 6) ? \
 				COMMAND_SIZE((cmd)->scb[0]) : (cmd)->scb_len)
+#define CDB_CONTROL(cmd) (((cmd)->scb[0] == 0x7f) ? (cmd)->scb[1] \
+			  : (cmd)->scb[CDB_SIZE((cmd))-1])
 
 int get_scsi_command_size(unsigned char op)
 {
@@ -189,7 +191,7 @@ int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd)
 	unsigned char op = cmd->scb[0];
 	struct it_nexus_lu_info *itn_lu;
 
-	if (cmd->scb[CDB_SIZE(cmd) - 1] & ((1U << 0) | (1U << 2))) {
+	if (CDB_CONTROL(cmd) & ((1U << 0) | (1U << 2))) {
 		/*
 		 * We don't support a linked command. SAM-3 say that
 		 * it's optional. It's obsolete in SAM-4.
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux