From 8e254fca996307fb46bd2ba004e096f7971db922 Mon Sep 17 00:00:00 2001 From: bde Date: Mon, 8 May 1995 16:48:23 +0000 Subject: [PATCH] Fix numerous bugs in wdsize(). It closed the wrong device (usually the B partition instead of the C partition). It closed a device without having opened it. It didn't open a device often enough. This caused swap partitions on slices other than the first slice looked at to be unavailable for swapping. It didn't check the device number sufficiently. --- sys/i386/isa/wd.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c index 557aa2d224da..8c2e95579f7a 100644 --- a/sys/i386/isa/wd.c +++ b/sys/i386/isa/wd.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)wd.c 7.2 (Berkeley) 5/9/91 - * $Id: wd.c,v 1.77 1995/04/24 05:12:29 phk Exp $ + * $Id: wd.c,v 1.78 1995/04/30 15:14:16 bde Exp $ */ /* TODO: @@ -1615,24 +1615,16 @@ wdformat(struct buf *bp) int wdsize(dev_t dev) { - int lunit = dkunit(dev), part = dkpart(dev), val; struct disk *du; - struct disklabel *lp; - int size; + int lunit; - if (lunit >= NWD || (du = wddrives[lunit]) == NULL) { + lunit = dkunit(dev); + if (lunit >= NWD || dktype(dev) != 0) return (-1); - } - val = 0; - if (du->dk_state == CLOSED) { - val = wdopen(dkmodpart(dev, RAW_PART), FREAD, S_IFBLK, 0); - dsclose(dev, S_IFBLK, du->dk_slices); - } - if (val != 0 || (lp = dsgetlabel(dev, du->dk_slices)) == NULL) { + du = wddrives[lunit]; + if (du == NULL) return (-1); - } - size = ((int)lp->d_partitions[part].p_size); - return size; + return (dssize(dev, &du->dk_slices, wdopen, wdclose)); } /*