test-tool: fix SG_IO

Handle io_hdr.resid and adjust datain.size.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
This commit is contained in:
Sebastian Herbszt
2015-02-15 22:26:32 +01:00
committed by Ronnie Sahlberg
parent 4fbf802d32
commit cb7882a84c

View File

@@ -277,6 +277,17 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi
return NULL;
}
task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL;
task->residual = 0;
if (io_hdr.resid) {
task->residual_status = SCSI_RESIDUAL_UNDERFLOW;
task->residual = io_hdr.resid;
}
if (task->xfer_dir == SCSI_XFER_READ)
task->datain.size -= task->residual;
/* now for the error processing */
if(io_hdr.sb_len_wr > 0){
task->status = SCSI_STATUS_CHECK_CONDITION;