Subject: faking disk geometry
To: None <tech-kern@NetBSD.ORG>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-kern
Date: 04/19/2003 00:22:34
I came across a USB flash reader that has broken mode sense.
sd0: 124 MB, 678400 cyl, 4 head, 0 sec, 512 bytes/sect x 253952 sectors
sd1: 0, 678432 cyl, 4 head, 0 sec, 512 bytes/sect x 0 sectors
[...]
If the following workaround is ok, I will commit it.
sd0: 124 MB, 124 cyl, 64 head, 32 sec, 512 bytes/sect x 253952 sectors
sd1: drive offline
[...]
Index: sd_scsi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/scsipi/sd_scsi.c,v
retrieving revision 1.27
diff -u -p -r1.27 sd_scsi.c
--- sd_scsi.c 2003/03/07 16:18:57 1.27
+++ sd_scsi.c 2003/04/18 20:10:05
@@ -357,6 +357,8 @@ sd_scsibus_get_parms(sd, dp, flags)
sectors = scsipi_size(sd->sc_periph, flags);
dp->disksize = sectors;
sectors /= (dp->heads * dp->cyls);
+ if (sectors == 0)
+ goto fake_it;
dp->sectors = sectors; /* XXX dubious on SCSI */
return (SDGP_RESULT_OK);
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen