summaryrefslogtreecommitdiff
path: root/sys/arch/hp300
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-05-02 05:04:45 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-05-02 05:04:45 +0000
commit06e9ec017feb47785da400103d3a692d751f098b (patch)
treecd39f575be0137e1b08046ff89fa5e3afab884a8 /sys/arch/hp300
parent74e4b14be0cd47abbc941622b82370a893dd57fb (diff)
Fix problem with zip drive correctly this time. The real deal is
that the hp300 scsi subsystem does not glean d_secpercyl from the device so we have to calculate a reasonable value. In the case of a zip drive, the calculated value gets truncated to zero. This change adds a sanity check and forces the calculated d_secpercyl to be >= 1. Also includes some minor code reorg.
Diffstat (limited to 'sys/arch/hp300')
-rw-r--r--sys/arch/hp300/dev/sd.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index 6ca16d60237..791ce329ef6 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.16 1998/04/30 04:55:46 millert Exp $ */
+/* $OpenBSD: sd.c,v 1.17 1998/05/02 05:04:44 millert Exp $ */
/* $NetBSD: sd.c,v 1.34 1997/07/10 18:14:10 kleink Exp $ */
/*
@@ -377,6 +377,7 @@ sdgetcapacity(sc, dev)
sc->sc_dev.dv_xname, sc->sc_blks, sc->sc_blksize,
sc->sc_bshift);
#endif
+ sc->sc_heads = sc->sc_cyls = 0;
sdgetgeom(sc);
return (0);
}
@@ -435,12 +436,14 @@ sdgetinfo(dev)
sc->sc_blksize = DEV_BSIZE;
/* Fill in info from disk geometry if it exists. */
- if (sc->sc_format_pid >= 0 && sc->sc_blks > 0 &&
- sc->sc_heads > 0 && sc->sc_cyls > 0) {
- lp->d_secperunit = sc->sc_blks >> sc->sc_bshift;
+ lp->d_secperunit = sc->sc_blks >> sc->sc_bshift;
+ if (lp->d_secperunit > 0 && sc->sc_heads > 0 && sc->sc_cyls > 0) {
lp->d_ntracks = sc->sc_heads;
lp->d_ncylinders = sc->sc_cyls;
- lp->d_nsectors = lp->d_secperunit / (lp->d_ntracks * lp->d_ncylinders);
+ lp->d_nsectors = lp->d_secperunit /
+ (lp->d_ntracks * lp->d_ncylinders);
+ if (lp->d_nsectors < 1)
+ lp->d_nsectors = 1; /* must be >= 1 */
} else {
lp->d_ntracks = 20;
lp->d_ncylinders = 1;
@@ -473,8 +476,12 @@ sdgetinfo(dev)
lp->d_sbsize = SBSIZE;
lp->d_partitions[RAW_PART].p_offset = 0;
- lp->d_partitions[RAW_PART].p_size =
- lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+ if (lp->d_secperunit > 0)
+ lp->d_partitions[RAW_PART].p_size =
+ lp->d_secperunit * (lp->d_secsize / DEV_BSIZE);
+ else
+ lp->d_partitions[RAW_PART].p_size =
+ roundup(LABELSECTOR+1, btodb(sc->sc_blksize));
lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
lp->d_npartitions = RAW_PART + 1;