summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-05-08 16:48:23 +0000
committerbde <bde@FreeBSD.org>1995-05-08 16:48:23 +0000
commit7f38b208c83af34b2c8848ac8efb57b0a5acf548 (patch)
treea740bb57e36dd24bd61d1cbbe1561698f98f4a36 /sys/i386/isa
parent53382aa7235aee2eb6b44fa6c221fe60d93900ea (diff)
downloadFreeBSD-src-7f38b208c83af34b2c8848ac8efb57b0a5acf548.zip
FreeBSD-src-7f38b208c83af34b2c8848ac8efb57b0a5acf548.tar.gz
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.
Diffstat (limited to 'sys/i386/isa')
-rw-r--r--sys/i386/isa/wd.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c
index 557aa2d..8c2e955 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));
}
/*
OpenPOWER on IntegriCloud