Add a new function to create a scsi_task using an existing CDB

This commit is contained in:
Ronnie Sahlberg
2013-08-04 13:12:13 -07:00
parent 06eab264f6
commit 6041dcd136
4 changed files with 29 additions and 0 deletions

View File

@@ -292,6 +292,13 @@ struct scsi_task {
struct scsi_iovector iovector_out;
};
/* Create a task using a pre-built CDB which can later be passed to
iscsi_scsi_command_[a]sync()
*/
EXTERN struct scsi_task *scsi_create_task(int cdb_size, unsigned char *cdb,
int xfer_dir, int expxferlen);
/* This function will free a scsi task structure.
You may NOT cancel a task until the callback has been invoked
and the command has completed on the transport layer.

View File

@@ -196,6 +196,7 @@ scsi_cdb_writeverify16
scsi_cdb_writesame10
scsi_cdb_writesame16
scsi_codeset_to_str
scsi_create_task
scsi_datain_getfullsize
scsi_datain_unmarshall
scsi_cdb_unmarshall

View File

@@ -194,6 +194,7 @@ scsi_cdb_writeverify16
scsi_cdb_writesame10
scsi_cdb_writesame16
scsi_codeset_to_str
scsi_create_task
scsi_datain_getfullsize
scsi_datain_unmarshall
scsi_cdb_unmarshall

View File

@@ -73,6 +73,26 @@ scsi_free_scsi_task(struct scsi_task *task)
free(task);
}
struct scsi_task *
scsi_create_task(int cdb_size, unsigned char *cdb, int xfer_dir, int expxferlen)
{
struct scsi_task *task;
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
return NULL;
}
memset(task, 0, sizeof(struct scsi_task));
memcpy(&task->cdb[0], cdb, cdb_size);
task->xfer_dir = xfer_dir;
task->expxferlen = expxferlen;
return task;
}
void *
scsi_malloc(struct scsi_task *task, size_t size)
{