diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-07-06 15:26:51 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-07-06 15:26:51 +0000 |
commit | df677abb48ad2764d16ae4ffb79e42d4b9cdfbe2 (patch) | |
tree | b7172bfb1c1cee7d5b15600eff998e42b79067ac /sys/arch/loongson | |
parent | 553ecec87d3691559c4520022538b9fcb0380f49 (diff) |
On those archs that read their disk (vs iso/udf) disklabels exclusively
via readdoslabel(), tweak writedisklabel() to write disklabels at
the same place readdoslabel() reads them from. Irregardless of the
physical disk sector size. As is done in i386/amd64 already.
No change in behaviour for the 'normal' 512-byte sector case.
ok deraadt@
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r-- | sys/arch/loongson/loongson/disksubr.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/arch/loongson/loongson/disksubr.c b/sys/arch/loongson/loongson/disksubr.c index 89a6f23d74a..d592707e693 100644 --- a/sys/arch/loongson/loongson/disksubr.c +++ b/sys/arch/loongson/loongson/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.5 2011/04/16 03:21:15 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.6 2011/07/06 15:26:50 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -97,6 +97,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; @@ -108,7 +109,8 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp) goto done; /* Read it in, slap the new label in, and write it back out */ - bp->b_blkno = partoff + LABELSECTOR; + bp->b_blkno = DL_BLKTOSEC(lp, partoff+LABELSECTOR) * DL_BLKSPERSEC(lp); + offset = DL_BLKOFFSET(lp, partoff + LABELSECTOR) + LABELOFFSET; 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); @@ -116,7 +118,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); |