From 91566c87743eb52736e6cc55d2137449cd902532 Mon Sep 17 00:00:00 2001 From: agc Date: Tue, 25 Sep 2007 22:15:00 +0000 Subject: [PATCH] As part of the initial checks to se ethat a writable disk really is writable, do the touch(1) dance with 512 bytes of information, rather than just a single byte - the single byte read and write causes problems on newer versions of FreeBSD, I am informed. Patch from Andrey Yakovlev, cleaned up to compile by myself. Add support for Extended Inquiry Data VPD Page (0x86), reported to be necessary to interoperate with the AIX initiator. Add preliminary support for the Write and Verify SCSI operation (0x2e). --- dist/iscsi/src/disk.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/dist/iscsi/src/disk.c b/dist/iscsi/src/disk.c index 5e3c41ad35ae..7742a01440b1 100644 --- a/dist/iscsi/src/disk.c +++ b/dist/iscsi/src/disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: disk.c,v 1.27 2007/09/19 19:54:09 agc Exp $ */ +/* $NetBSD: disk.c,v 1.28 2007/09/25 22:15:00 agc Exp $ */ /* * Copyright © 2006 Alistair Crooks. All rights reserved. @@ -759,18 +759,18 @@ static int de_allocate(disc_de_t *de, char *filename) { off_t size; - char ch; + char block[DEFAULT_TARGET_BLOCK_LEN]; size = de_getsize(de); if (de_lseek(de, size - 1, SEEK_SET) == -1) { iscsi_trace_error(__FILE__, __LINE__, "error seeking \"%s\"\n", filename); return 0; } - if (de_read(de, &ch, 1) == -1) { + if (de_read(de, block, sizeof(block)) == -1) { iscsi_trace_error(__FILE__, __LINE__, "error reading \"%s\"", filename); return 0; } - if (de_write(de, &ch, 1) == -1) { + if (de_write(de, block, sizeof(block)) == -1) { iscsi_trace_error(__FILE__, __LINE__, "error writing \"%s\"", filename); return 0; } @@ -1059,11 +1059,20 @@ device_command(target_session_t * sess, target_cmd_t * cmd) case INQUIRY_SUPPORTED_VPD_PAGES: data[0] = DISK_PERIPHERAL_DEVICE; data[1] = INQUIRY_SUPPORTED_VPD_PAGES; - *totlen = 2; /* # of supported pages */ + *totlen = 3; /* # of supported pages */ data[4] = INQUIRY_SUPPORTED_VPD_PAGES; data[5] = INQUIRY_DEVICE_IDENTIFICATION_VPD; + data[6] = EXTENDED_INQUIRY_DATA_VPD; args->length = *totsize + 1; break; + case EXTENDED_INQUIRY_DATA_VPD: + data[0] = DISK_PERIPHERAL_DEVICE; + data[1] = EXTENDED_INQUIRY_DATA_VPD; + data[3] = 0x3c; /* length is defined to be 60 */ + data[4] = 0; + data[5] = 0; + args->length = 64; + break; default: iscsi_trace_error(__FILE__, __LINE__, "Unsupported INQUIRY VPD page %x\n", cdb[2]); args->status = SCSI_CHECK_CONDITION; @@ -1158,9 +1167,10 @@ device_command(target_session_t * sess, target_cmd_t * cmd) break; case WRITE_10: + case WRITE_VERIFY: cdb2lba(&lba, &len, cdb); - iscsi_trace(TRACE_SCSI_CMD, __FILE__, __LINE__, "WRITE_10(lba %u, len %u blocks)\n", lba, len); + iscsi_trace(TRACE_SCSI_CMD, __FILE__, __LINE__, "WRITE_10 | WRITE_VERIFY(lba %u, len %u blocks)\n", lba, len); if (disk_write(sess, args, lun, lba, (unsigned) len) != 0) { iscsi_trace_error(__FILE__, __LINE__, "disk_write() failed\n"); args->status = SCSI_CHECK_CONDITION;