mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-17 08:00:48 +01:00
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.
This commit is contained in:
parent
edde522e19
commit
dac9a9e66d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8357
@ -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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user