summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2015-07-28 23:10:13 +0000
committerkrw <krw@openbsd.org>2015-07-28 23:10:13 +0000
commit34321ffbf268b21e051c74eb1004da96540b1cf0 (patch)
tree76b2ffe4f2c9e75eff83ea54c97052a99a15eee0 /sys/kern/subr_disk.c
parentARG_MAX is the standard name (not NCARGS); probab[l]y guenther (diff)
downloadwireguard-openbsd-34321ffbf268b21e051c74eb1004da96540b1cf0.tar.xz
wireguard-openbsd-34321ffbf268b21e051c74eb1004da96540b1cf0.zip
Convert sectors to DEV_BSIZE block values were necessary to find,
read and validate disklabels on GPT partitioned disks. Makes it much more likely GPT partitioned disks with non-512-byte sectors will work. Part of the larger reverted GPT work. ok deraadt@
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 08ce9348005..57c8eb909c4 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.185 2015/07/26 14:01:07 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.186 2015/07/28 23:10:13 krw Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -841,7 +841,7 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *),
/* record the OpenBSD partition's placement for the caller */
if (partoffp)
- *partoffp = gptpartoff;
+ *partoffp = DL_SECTOBLK(lp, gptpartoff);
else {
DL_SETBSTART(lp, gptpartoff);
DL_SETBEND(lp, (gptpartend < DL_GETDSIZE(lp)) ? gptpartend :
@@ -852,9 +852,10 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *),
if (spoofonly)
return (0);
- bp->b_blkno = DL_BLKTOSEC(lp, gptpartoff + DOS_LABELSECTOR) *
- DL_BLKSPERSEC(lp);
- offset = DL_BLKOFFSET(lp, gptpartoff + DOS_LABELSECTOR);
+ bp->b_blkno = DL_BLKTOSEC(lp, DL_SECTOBLK(lp, gptpartoff) +
+ DOS_LABELSECTOR) * DL_BLKSPERSEC(lp);
+ offset = DL_BLKOFFSET(lp, DL_SECTOBLK(lp, gptpartoff) +
+ DOS_LABELSECTOR);
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);
@@ -863,8 +864,11 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *),
if (biowait(bp))
return (bp->b_error);
- /* sub-GPT disklabels are always at a LABELOFFSET of 0 */
- return checkdisklabel(bp->b_data + offset, lp, gptpartoff, gptpartend);
+ error = checkdisklabel(bp->b_data + offset, lp,
+ DL_GETBSTART((struct disklabel*)(bp->b_data+offset)),
+ DL_GETBEND((struct disklabel *)(bp->b_data+offset)));
+
+ return (error);
}
#endif