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
This commit is contained in:
Joerg Wunsch 2000-05-22 17:21:50 +00:00
parent 07da07565e
commit d082442a09

View File

@ -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;