diff options
author | 2015-08-29 20:48:55 +0000 | |
---|---|---|
committer | 2015-08-29 20:48:55 +0000 | |
commit | 0e73d8e33c511db9db26d91d238f2872b250ddb3 (patch) | |
tree | 83ba1b4bbad92cce81e6756ba083cca7940202d3 /sys/kern/subr_disk.c | |
parent | Minimal implementation of the read-only number register \n(.$ (diff) | |
download | wireguard-openbsd-0e73d8e33c511db9db26d91d238f2872b250ddb3.tar.xz wireguard-openbsd-0e73d8e33c511db9db26d91d238f2872b250ddb3.zip |
In readgptlabel() the block offsets of the GPT header and GPT partition
entries within a disk sector are always 0. i.e. both must start on a
sector boundary. So stop calculating the offset value and adding it to
b_data when pulling data out of the buf.
Part of larger refactoring, eyed by jsing@, tested by bmercer@ as
part of that larger diff.
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r-- | sys/kern/subr_disk.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index fa0587efb52..e0e69d4dc5b 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.192 2015/08/28 22:42:05 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.193 2015/08/29 20:48:55 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -656,7 +656,6 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *), /* read header record */ bp->b_blkno = DL_BLKTOSEC(lp, part_blkno) * DL_BLKSPERSEC(lp); - offset = DL_BLKOFFSET(lp, part_blkno); bp->b_bcount = lp->d_secsize; bp->b_error = 0; /* B_ERROR and b_error may have stale data. */ CLR(bp->b_flags, B_READ | B_WRITE | B_DONE | B_ERROR); @@ -671,7 +670,7 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *), return (error); } - bcopy(bp->b_data + offset, &gh, sizeof(gh)); + bcopy(bp->b_data, &gh, sizeof(gh)); ghsize = letoh32(gh.gh_size); ghpartsize = letoh32(gh.gh_part_size); ghpartspersec = lp->d_secsize / ghpartsize; @@ -745,7 +744,6 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *), /* read partition record */ bp->b_blkno = DL_BLKTOSEC(lp, part_blkno) * DL_BLKSPERSEC(lp); - offset = DL_BLKOFFSET(lp, part_blkno); bp->b_bcount = lp->d_secsize; /* B_ERROR and b_error may have stale data. */ bp->b_error = 0; @@ -760,7 +758,7 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *), return (error); } - bcopy(bp->b_data + offset, gp + i * ghpartspersec, + bcopy(bp->b_data, gp + i * ghpartspersec, ghpartspersec * sizeof(struct gpt_partition)); } |