From 6eb4b7b6e592d358dd613b9da887b9e823895a57 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Wed, 14 Oct 2020 20:43:11 +0200 Subject: [PATCH] lib: parse Information sense descriptor type The Information descriptor type is defined in SPC-5 (r17 4.4.2.2) and may be used to provide the data offset on COMPARE_AND_WRITE miscompare. Signed-off-by: David Disseldorp --- include/scsi-lowlevel.h | 2 ++ lib/iscsi-command.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/scsi-lowlevel.h b/include/scsi-lowlevel.h index a70dcf7..2561b01 100644 --- a/include/scsi-lowlevel.h +++ b/include/scsi-lowlevel.h @@ -281,8 +281,10 @@ struct scsi_sense { unsigned sense_specific:1; unsigned ill_param_in_cdb:1; unsigned bit_pointer_valid:1; + unsigned info_valid:1; unsigned char bit_pointer; uint16_t field_pointer; + uint64_t information; }; struct scsi_data { diff --git a/lib/iscsi-command.c b/lib/iscsi-command.c index a45b8dd..582517b 100644 --- a/lib/iscsi-command.c +++ b/lib/iscsi-command.c @@ -330,6 +330,13 @@ static void parse_sense_descriptors(struct scsi_sense *sense, const uint8_t *sb, if (addl_len < 4) break; switch (p[0]) { + case 0: + /* Information descriptor with VALID flag */ + if (addl_len == 0x0a && p[2] & 0x80) { + sense->info_valid = 1; + sense->information = scsi_get_uint64(p + 4); + } + break; case 2: /* Sense key specific sense data descriptor */ if (addl_len == 0x06)