From 89795c51ed2b586f78803fc550d71069c1d05611 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 2 May 1998 05:36:59 +0000 Subject: If computed value for d_nsectors truncated to 0, set it to 32 and adjust d_ncylinders instead of just setting d_nsectors to 1 (which is not useful for putting a filesystem on a device). --- sys/arch/hp300/dev/sd.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sys/arch/hp300/dev/sd.c') diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c index 791ce329ef6..58abd418d18 100644 --- a/sys/arch/hp300/dev/sd.c +++ b/sys/arch/hp300/dev/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.17 1998/05/02 05:04:44 millert Exp $ */ +/* $OpenBSD: sd.c,v 1.18 1998/05/02 05:36:58 millert Exp $ */ /* $NetBSD: sd.c,v 1.34 1997/07/10 18:14:10 kleink Exp $ */ /* @@ -442,8 +442,18 @@ sdgetinfo(dev) lp->d_ncylinders = sc->sc_cyls; lp->d_nsectors = lp->d_secperunit / (lp->d_ntracks * lp->d_ncylinders); - if (lp->d_nsectors < 1) - lp->d_nsectors = 1; /* must be >= 1 */ + /* + * We must make sure d_nsectors is a sane value. + * Adjust d_ncylinders to be reasonable if we + * monkey with d_nsectors. + */ + if (lp->d_nsectors < 1) { + lp->d_nsectors = 32; + lp->d_ncylinders = lp->d_secperunit / + ( lp->d_ntracks * lp->d_nsectors); + if (lp->d_ncylinders == 0) + lp->d_ncylinders = sc->sc_cyls; + } } else { lp->d_ntracks = 20; lp->d_ncylinders = 1; -- cgit v1.2.3