Move the sector size check to the right place,

also cope with some drives that return funny values.
The correct fix will come in a few days.
This commit is contained in:
Julian Elischer 1997-12-28 07:10:54 +00:00
parent 88754aaf0e
commit fb05cb0121
1 changed files with 25 additions and 14 deletions

View File

@ -15,7 +15,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*
* $Id: sd.c,v 1.115 1997/12/02 21:07:03 phk Exp $
* $Id: sd.c,v 1.116 1997/12/06 14:27:56 bde Exp $
*/
#include "opt_bounce.h"
@ -318,18 +318,6 @@ sd_open(dev, mode, fmt, p, sc_link)
*/
if(errcode = sd_get_parms(unit, 0)) /* sets SDEV_MEDIA_LOADED */
goto bad;
switch (sd->params.secsiz) {
case 512:
case 1024:
case 2048:
break;
default:
printf("sd%ld: Can't deal with %d bytes logical blocks\n",
unit, sd->params.secsiz);
Debugger("sd");
errcode = ENXIO;
goto bad;
}
SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded "));
@ -423,7 +411,7 @@ sd_strategy(struct buf *bp, struct scsi_link *sc_link)
/*
* check it's not too big a transfer for our adapter
*/
scsi_minphys(bp,&sd_switch);
scsi_minphys(bp,&sd_switch);
/*
* Odd number of bytes or negative offset
@ -849,6 +837,29 @@ sd_get_parms(unit, flags)
disk_parms->cyls = scsi_3btou(&scsi_sense.pages.rigid_geometry.ncyl_2);
disk_parms->secsiz = scsi_3btou(scsi_sense.blk_desc.blklen);
switch (sd->params.secsiz) {
case 528:/*
* This is not the correct fix but will do till
* I get to my scsi docs. Some drives return this value
* for physical size when actually presenting
* a 512 byte logical sector size. The correct
* fix involves figuring out what hte correct
* command sequence is to get teh logical blocksize,
* and figuring out what to do if it doesn't
* work on an old drive. Possibly only do this
* if the value here is not a power of 2.
*/
sd->params.secsiz = 512;
case 512:
case 1024:
case 2048:
break;
default:
printf("sd%ld: Can't deal with %d byte blocks\n",
unit, sd->params.secsiz);
Debugger("sd");
return (ENXIO);
}
sectors = sd_size(unit, flags);
disk_parms->disksize = sectors;
/* Check if none of these values are zero */