diff options
author | bde <bde@FreeBSD.org> | 1995-08-28 16:09:11 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-08-28 16:09:11 +0000 |
commit | 9d58b7eb431a526e0959673cb54d7475d8663bb1 (patch) | |
tree | e26f0cf6c73c62e4956aad0f749722b5820618c2 /sys/kern/subr_disklabel.c | |
parent | 0e4c4a45a134780cf77e87c785e45184a61f057f (diff) | |
download | FreeBSD-src-9d58b7eb431a526e0959673cb54d7475d8663bb1.zip FreeBSD-src-9d58b7eb431a526e0959673cb54d7475d8663bb1.tar.gz |
Fix correct_writedisklabel() and writedisklabel(). Their setting of
bp->b_flags has been broken for many years:
a) they didn't set B_BUSY for doing i/o. This has been fatal since
1995/07/25 when biodone() started checking that B_BUSY is set.
b) they didn't set B_INVAL for releasing the buffer. This at best
just put a useless buffer in the LRU queue for a little while.
Fix a couple of spelling errors and complete a couple of function
pointer declarations.
Diffstat (limited to 'sys/kern/subr_disklabel.c')
-rw-r--r-- | sys/kern/subr_disklabel.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c index 828776f..442a0ad 100644 --- a/sys/kern/subr_disklabel.c +++ b/sys/kern/subr_disklabel.c @@ -42,7 +42,7 @@ * SUCH DAMAGE. * * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 - * $Id: ufs_disksubr.c,v 1.16 1995/08/07 11:55:32 davidg Exp $ + * $Id: ufs_disksubr.c,v 1.17 1995/08/07 14:20:27 davidg Exp $ */ #include <sys/param.h> @@ -148,7 +148,7 @@ insert: } /* - * Attempt to read a disk label from a device using the indicated stategy + * Attempt to read a disk label from a device using the indicated strategy * routine. The label must be partly set up before this: secpercyl and * anything required in the strategy routine (e.g., sector size) must be * filled in before calling us. Returns NULL on success and an error @@ -212,7 +212,7 @@ correct_readdisklabel(dev, strat, lp) #ifdef PRE_DISKSLICE_COMPAT /* - * Attempt to read a disk label from a device using the indicated stategy + * Attempt to read a disk label from a device using the indicated strategy * routine. The label must be partly set up before this: secpercyl and * anything required in the strategy routine (e.g., sector size) must be * filled in before calling us. Returns NULL on success and an error @@ -224,7 +224,7 @@ correct_readdisklabel(dev, strat, lp) char * readdisklabel(dev, strat, lp, dp, bdp) dev_t dev; - void (*strat)(); + d_strategy_t *strat; register struct disklabel *lp; struct dos_partition *dp; struct dkbad *bdp; @@ -418,7 +418,7 @@ correct_writedisklabel(dev, strat, lp) bp->b_dev = dkmodpart(dev, labelpart); bp->b_blkno = LABELSECTOR; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_READ; + bp->b_flags = B_BUSY | B_READ; (*strat)(bp); error = biowait(bp); if (error) @@ -430,7 +430,7 @@ correct_writedisklabel(dev, strat, lp) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { *dlp = *lp; - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); goto done; @@ -438,6 +438,7 @@ correct_writedisklabel(dev, strat, lp) } error = ESRCH; done: + bp->b_flags = B_INVAL | B_AGE; brelse(bp); return (error); } @@ -459,7 +460,7 @@ done: int writedisklabel(dev, strat, lp) dev_t dev; - void (*strat)(); + d_strategy_t *strat; register struct disklabel *lp; { struct buf *bp = NULL; @@ -537,7 +538,7 @@ writedisklabel(dev, strat, lp) * Note that you can't write a label out over a corrupted label! * (also stupid.. how do you write the first one? by raw writes?) */ - bp->b_flags = B_READ; + bp->b_flags = B_BUSY | B_READ; (*strat)(bp); error = biowait(bp); if (error) @@ -549,7 +550,7 @@ writedisklabel(dev, strat, lp) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { bcopy(&label,dlp,sizeof(label)); - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); goto done; @@ -559,14 +560,16 @@ writedisklabel(dev, strat, lp) #else /* Stupid */ dlp = (struct disklabel *)bp->b_data; bcopy(&label,dlp,sizeof(label)); - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); #endif /* Stupid */ done: bcopy(&label,lp,sizeof(label)); /* start using the new label again */ - if(bp) + if (bp) { + bp->b_flags = B_INVAL | B_AGE; brelse(bp); + } return (error); } #endif /* PRE_DISKSLICE_COMPAT */ |