summaryrefslogtreecommitdiff
path: root/sys/arch/hppa
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2011-07-07 22:48:24 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2011-07-07 22:48:24 +0000
commita4c10d765061e98acbf92e758cbf0b7ec14190b1 (patch)
tree9bd020d972902abb26459113759cb53f3b26323f /sys/arch/hppa
parent7c375cf7e321162fcfa54b6f23b0626bc5fdb14f (diff)
Take more care to write 'dos' labels in the same place readdoslabel()
will look for them. Without changing native label handling. Compile tested on hppa by kettenis@. "I see no issues" deraadt@
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r--sys/arch/hppa/hppa/disksubr.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index 950c30e50bc..2ca75fa3471 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.80 2011/04/16 03:21:15 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.81 2011/07/07 22:48:23 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -108,7 +108,7 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *),
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
(*strat)(bp);
if (biowait(bp))
- return bp->b_error;
+ return (bp->b_error);
lvp = (struct lifvol *)bp->b_data;
if (lvp->vol_id != LIF_VOL_ID) {
@@ -252,6 +252,7 @@ int
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp)
{
int error = EIO, partoff = -1;
+ int offset;
struct disklabel *dlp;
struct buf *bp = NULL;
@@ -259,12 +260,17 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp)
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
- if (readliflabel(bp, strat, lp, &partoff, 1) != 0 &&
- readdoslabel(bp, strat, lp, &partoff, 1) != 0)
+ if (readliflabel(bp, strat, lp, &partoff, 1) == 0) {
+ bp->b_blkno = partoff + LABELSECTOR;
+ offset = LABELOFFSET;
+ } else if (readdoslabel(bp, strat, lp, &partoff, 1) == 0) {
+ bp->b_blkno = DL_BLKTOSEC(lp, partoff + LABELSECTOR) *
+ DL_BLKSPERSEC(lp);
+ offset = DL_BLKOFFSET(lp, partoff + LABELSECTOR) + LABELOFFSET;
+ } else
goto done;
/* Read it in, slap the new label in, and write it back out */
- bp->b_blkno = partoff + LABELSECTOR;
bp->b_bcount = lp->d_secsize;
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
@@ -272,7 +278,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp)
if ((error = biowait(bp)) != 0)
goto done;
- dlp = (struct disklabel *)(bp->b_data + LABELOFFSET);
+ dlp = (struct disklabel *)(bp->b_data + offset);
*dlp = *lp;
CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
SET(bp->b_flags, B_BUSY | B_WRITE | B_RAW);