summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2000-05-22 17:21:50 +0000
committerjoerg <joerg@FreeBSD.org>2000-05-22 17:21:50 +0000
commite2d6681912c8ed0bd7bab4d020fc4e7e4b2cdffc (patch)
tree81786a9ee2df1041da619ff38c61ce6780494f7e /sys
parenta9b64c96d9ae4ee08b83d18df111e57d62a78f6f (diff)
downloadFreeBSD-src-e2d6681912c8ed0bd7bab4d020fc4e7e4b2cdffc.zip
FreeBSD-src-e2d6681912c8ed0bd7bab4d020fc4e7e4b2cdffc.tar.gz
Apply a `fixup' to the blocksize gathered from the device after a READ
CAPACITY operation. SCSI-3 mandates this to be 2048, but some older drives like my old Plasmon CD-R report weird numbers between 2048 and up to 2352 bytes depending on the mode of the last track etc. This in turn confuses stuff like the slice code since it refuses to work with devices that do not have a blocksize which is a multiple of 512 bytes. Reviewed by: ken
Diffstat (limited to 'sys')
-rw-r--r--sys/cam/scsi/scsi_cd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index 4f23117..e862e62 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -2518,6 +2518,16 @@ cdsize(dev_t dev, u_int32_t *size)
softc->params.disksize = scsi_4btoul(rcap_buf->addr) + 1;
softc->params.blksize = scsi_4btoul(rcap_buf->length);
+ /*
+ * SCSI-3 mandates that the reported blocksize shall be 2048.
+ * Older drives sometimes report funny values, trim it down to
+ * 2048, or other parts of the kernel will get confused.
+ *
+ * XXX we leave drives alone that might report 512 bytes, as
+ * well as drives reporting more weird sizes like perhaps 4K.
+ */
+ if (softc->params.blksize > 2048 && softc->params.blksize <= 2352)
+ softc->params.blksize = 2048;
free(rcap_buf, M_TEMP);
*size = softc->params.disksize;
OpenPOWER on IntegriCloud