On Thu, Jan 26, 2012 at 12:00 PM, FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> wrote: > On Thu, 26 Jan 2012 11:17:39 +1100 > ronnie sahlberg <ronniesahlberg@xxxxxxxxx> wrote: > >> From dfb19f35441d137ef4b82cec924a8746cb1c040d Mon Sep 17 00:00:00 2001 >> From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> >> Date: Thu, 26 Jan 2012 10:35:22 +1100 >> Subject: [PATCH] SBC VERIFY: Update VERIFY to check vprotect argument >> >> TGTD does not support formatting protection information so make >> TGTD fail a VERIFY command requesting vprotect != 0 with a proper >> check condition. >> >> Add VERIFY12/VERIFY16. These are both identical to the already existing VERIFY10 as far as we are converned. >> >> See SBC 5.22 VERIFY 10 COMMAND, tables 65 and 66 >> If the media is not formatted with protection information (as in TGTD) >> any value of vprotect other than 000b is an error condition and the device h >> >> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> >> --- >> usr/sbc.c | 25 ++++++++++++++++++++++--- >> 1 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/usr/sbc.c b/usr/sbc.c >> index 53e785b..23b1778 100644 >> --- a/usr/sbc.c >> +++ b/usr/sbc.c >> @@ -265,7 +265,26 @@ sense: >> >> static int sbc_verify(int host_no, struct scsi_cmd *cmd) >> { >> - return SAM_STAT_GOOD; >> + unsigned char key; >> + uint16_t asc; >> + int vprotect; >> + >> + vprotect = cmd->scb[1] & 0xe0; >> + if (vprotect != 0) { >> + /* we dont support formatting with protection information, >> + * so all verify with vprotect!=0 is an error condition >> + */ >> + key = ILLEGAL_REQUEST; >> + asc = ASC_INVALID_FIELD_IN_CDB; >> + goto sense; >> + } >> + >> + return SAM_STAT_GOOD; > > Hmm, should we implement VERIFY (such as data comparison) instead of > returning GOOD if we replace illegal_op? The original VERIFY10 did not do any checks at all, but you are right. We should not just verify that 'vprotect' is good, we should read and compare the data too. Ill send a new patch to add read-and-verify. regards ronnie sahlberg -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html