Add VERIFY16 support and tests

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-06-04 20:16:44 +10:00
parent f6fd18ee3a
commit 6003000809
14 changed files with 725 additions and 1 deletions

View File

@@ -978,6 +978,53 @@ scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int byt
return task;
}
/*
* VERIFY16
*/
struct scsi_task *
scsi_cdb_verify16(uint64_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize)
{
struct scsi_task *task;
task = malloc(sizeof(struct scsi_task));
if (task == NULL) {
return NULL;
}
memset(task, 0, sizeof(struct scsi_task));
task->cdb[0] = SCSI_OPCODE_VERIFY16;
if (vprotect) {
task->cdb[1] |= ((vprotect << 5) & 0xe0);
}
if (dpo) {
task->cdb[1] |= 0x10;
}
if (bytchk) {
task->cdb[1] |= 0x02;
}
*(uint32_t *)&task->cdb[2] = htonl(lba >> 32);
*(uint32_t *)&task->cdb[6] = htonl(lba & 0xffffffff);
*(uint32_t *)&task->cdb[10] = htonl(xferlen/blocksize);
task->cdb_size = 16;
if (xferlen != 0) {
task->xfer_dir = SCSI_XFER_WRITE;
} else {
task->xfer_dir = SCSI_XFER_NONE;
}
task->expxferlen = xferlen;
task->params.verify16.lba = lba;
task->params.verify16.num_blocks = xferlen/blocksize;
task->params.verify16.vprotect = vprotect;
task->params.verify16.dpo = dpo;
task->params.verify16.bytchk = bytchk;
return task;
}
/*
* UNMAP