summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-06-04 01:25:03 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-06-04 01:25:03 +0000
commit8fa93c8e129db89e65d6b737281a95b5c7444727 (patch)
tree21de5a883a28e9a66ac9e316304d527c34921f9e /sys/scsi
parentcc08a0235632a2598ccdda1a7fc939726372e593 (diff)
Make scsi_do_mode_sense() aware of the difference between the 8 byte
general block descriptor and the 8 byte direct block descriptor, and return the correct values for density, block_count and block_size based on the type of the device. First cut has T_SEQUENTIAL (i.e. tape devices) as the only device type using general block descriptors, so the behaviour change is minimal.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_base.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index d8dea358476..7c6fa23e255 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.78 2005/06/03 15:50:10 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.79 2005/06/04 01:25:02 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -465,9 +465,10 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
void **page_data;
{
struct scsi_mode_blk_desc_big *desc_big;
- struct scsi_mode_direct_blk_desc *desc;
+ struct scsi_mode_direct_blk_desc *direct;
struct scsi_mode_header_big *hdr_big;
struct scsi_mode_header *hdr;
+ struct scsi_blk_desc *general;
u_char *cbuf = (u_char *)buf;
int error, blk_desc_len;
@@ -525,16 +526,35 @@ scsi_do_mode_sense(sc_link, page, buf, page_data, density, block_count,
blk_desc_len = hdr->blk_desc_len;
eight_byte:
+ /* Both scsi_blk_desc and scsi_mode_direct_blk_desc are 8 bytes. */
if (blk_desc_len < sizeof(struct scsi_mode_direct_blk_desc))
return (0);
- desc = (struct scsi_mode_direct_blk_desc *)cbuf;
- if (density)
- *density = desc->density;
- if (block_size)
- *block_size = _3btol(desc->blklen);
- if (block_count)
- *block_count = (u_int64_t)_4btol(desc->nblocks);
+ switch (sc_link->inqdata.device & SID_TYPE) {
+ case T_SEQUENTIAL:
+ /*
+ * XXX What other device types will return general block
+ * descriptors other than tape drives?
+ */
+ general = (struct scsi_blk_desc *)cbuf;
+ if (density)
+ *density = general->density;
+ if (block_size)
+ *block_size = _3btol(general->blklen);
+ if (block_count)
+ *block_count = (u_int64_t)_3btol(general->nblocks);
+ break;
+
+ default:
+ direct = (struct scsi_mode_direct_blk_desc *)cbuf;
+ if (density)
+ *density = direct->density;
+ if (block_size)
+ *block_size = _3btol(direct->blklen);
+ if (block_count)
+ *block_count = (u_int64_t)_4btol(direct->nblocks);
+ break;
+ }
return (0);
}