From 6041dcd1367b099aa88e3dc6f9293c98fefaeef3 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 4 Aug 2013 13:12:13 -0700 Subject: [PATCH] Add a new function to create a scsi_task using an existing CDB --- include/scsi-lowlevel.h | 7 +++++++ lib/libiscsi.def | 1 + lib/libiscsi.syms | 1 + lib/scsi-lowlevel.c | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index da2278a..90841b1 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -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. diff --git a/lib/libiscsi.def b/lib/libiscsi.def index bf68dbf..5695b94 100644 --- a/lib/libiscsi.def +++ b/lib/libiscsi.def @@ -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 diff --git a/lib/libiscsi.syms b/lib/libiscsi.syms index e887506..685a168 100644 --- a/lib/libiscsi.syms +++ b/lib/libiscsi.syms @@ -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 diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 1bb03af..d766772 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -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) {