From 9dce01bbea58848764e71e3d4a217f7edcbdcca9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 29 May 2013 18:06:17 +0200 Subject: [PATCH] Fix PERSISTENT RESERVE IN / READ RESERVATION response unmarshalling The code that verifies the pr_type response must compare only the lower four bits of byte 21 of the response ("TYPE") and must ignore the upper four bits ("SCOPE"). Signed-off-by: Bart Van Assche --- include/scsi-lowlevel.h | 1 + lib/scsi-lowlevel.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index b974c9b..e37be0a 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -803,6 +803,7 @@ struct scsi_persistent_reserve_in_read_reservation { int reserved; uint64_t reservation_key; + unsigned char pr_scope; unsigned char pr_type; }; diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 4b04f63..b953e94 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -815,7 +815,8 @@ scsi_persistentreservein_datain_unmarshall(struct scsi_task *task) rr->reserved = 1; rr->reservation_key = task_get_uint64(task, 8); - rr->pr_type = task_get_uint8(task, 21) & 0xff; + rr->pr_scope = task_get_uint8(task, 21) >> 4; + rr->pr_type = task_get_uint8(task, 21) & 0xf; } return rr;