patch-2.3.47 linux/drivers/scsi/scsi_ioctl.c

Next file: linux/drivers/scsi/scsi_lib.c
Previous file: linux/drivers/scsi/scsi_error.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.46/linux/drivers/scsi/scsi_ioctl.c linux/drivers/scsi/scsi_ioctl.c
@@ -105,6 +105,7 @@
                 return -EINTR;
         }
 
+	SCpnt->sc_data_direction = SCSI_DATA_NONE;
         scsi_wait_cmd(SCpnt, cmd, NULL, 0, timeout, retries);
 
 	SCSI_LOG_IOCTL(2, printk("Ioctl returned  0x%x\n", SCpnt->result));
@@ -197,6 +198,7 @@
 	int inlen, outlen, cmdlen;
 	int needed, buf_needed;
 	int timeout, retries, result;
+	int data_direction;
 
 	if (!sic)
 		return -EINVAL;
@@ -232,8 +234,21 @@
 		if (!buf)
 			return -ENOMEM;
 		memset(buf, 0, buf_needed);
-	} else
+		if( inlen == 0 ) {
+			data_direction = SCSI_DATA_WRITE;
+		} else if (outlen == 0 ) {
+			data_direction = SCSI_DATA_READ;
+		} else {
+			/*
+			 * Can this ever happen?
+			 */
+			data_direction = SCSI_DATA_UNKNOWN;
+		}
+
+	} else {
 		buf = NULL;
+		data_direction = SCSI_DATA_NONE;
+	}
 
 	/*
 	 * Obtain the command from the user's address space.
@@ -288,6 +303,7 @@
                 return -EINTR;
         }
 
+	SCpnt->sc_data_direction = data_direction;
         scsi_wait_cmd(SCpnt, cmd, buf, needed, timeout, retries);
 
 	/* 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)