From 09df905d309a739745afe9ac23acd39d6b71fcc8 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 18 Dec 2012 21:19:25 -0800 Subject: [PATCH] Add unmarshalling ot REPORT_CAPABILITIES --- include/scsi-lowlevel.h | 12 ++++++++++++ lib/scsi-lowlevel.c | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index e4744fa..4f99e07 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -727,6 +727,18 @@ struct scsi_persistent_reserve_in_read_reservation { uint32_t additional_length; }; +struct scsi_persistent_reserve_in_report_capabilities { + uint16_t length; + uint8_t crh; + uint8_t sip_c; + uint8_t atp_c; + uint8_t ptpl_c; + uint8_t tmv; + uint8_t allow_commands; + uint8_t ptpl_a; + uint16_t persistent_reservation_type_mask; +}; + struct scsi_read10_cdb { enum scsi_opcode opcode; uint8_t rdprotect; diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 0611b67..e95cb3c 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -635,6 +635,8 @@ scsi_persistentreservein_datain_getfullsize(struct scsi_task *task) return scsi_get_uint32(&task->datain.data[4]) + 8; case SCSI_PERSISTENT_RESERVE_READ_RESERVATION: return 8; + case SCSI_PERSISTENT_RESERVE_REPORT_CAPABILITIES: + return 8; default: return -1; } @@ -645,6 +647,7 @@ scsi_persistentreservein_datain_unmarshall(struct scsi_task *task) { struct scsi_persistent_reserve_in_read_keys *rk; struct scsi_persistent_reserve_in_read_reservation *rr; + struct scsi_persistent_reserve_in_report_capabilities *rc; int i; switch (scsi_persistentreservein_sa(task)) { @@ -672,6 +675,21 @@ scsi_persistentreservein_datain_unmarshall(struct scsi_task *task) rr->additional_length = scsi_get_uint32(&task->datain.data[4]); return rr; + case SCSI_PERSISTENT_RESERVE_REPORT_CAPABILITIES: + rc = scsi_malloc(task, sizeof(struct scsi_persistent_reserve_in_report_capabilities)); + if (rc == NULL) { + return NULL; + } + rc->length = scsi_get_uint16(&task->datain.data[0]); + rc->crh = !!(task->datain.data[2] & 0x10); + rc->sip_c = !!(task->datain.data[2] & 0x08); + rc->atp_c = !!(task->datain.data[2] & 0x04); + rc->ptpl_c = !!(task->datain.data[2] & 0x01); + rc->tmv = !!(task->datain.data[3] & 0x80); + rc->allow_commands = task->datain.data[3] >> 4; + rc->persistent_reservation_type_mask = scsi_get_uint16(&task->datain.data[4]); + + return rc; default: return NULL; }