diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 00:09:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 00:09:41 +0000 |
commit | 02a365840c38e842976e2e6bfb8a24990aaa23e6 (patch) | |
tree | 40b28e93438bd0c49cdee7b2a2acc9bdab782d28 /sys/arch/sgi | |
parent | 7e97643755bb45a839c99309ba46c6c5b31c0669 (diff) |
Don't mess with the bounds in the lp if *partoffp is non-NULL, since this
indicates that writedisklabel is trying to find the location for writing
the label. If the lp is messed with, an invalid checksum is written.
done with miod and kettenis, lots of moaning and gnashing of teeth, etc
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r-- | sys/arch/sgi/sgi/disksubr.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/arch/sgi/sgi/disksubr.c b/sys/arch/sgi/sgi/disksubr.c index 481fa2df5fc..534a579fced 100644 --- a/sys/arch/sgi/sgi/disksubr.c +++ b/sys/arch/sgi/sgi/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.15 2009/06/05 09:12:25 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.16 2009/06/14 00:09:39 deraadt Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -120,9 +120,6 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *), u_int fsend; int offset; - if (partoffp) - *partoffp = fsoffs; - bp->b_blkno = 0; bp->b_bcount = lp->d_secsize; bp->b_flags = B_BUSY | B_READ | B_RAW; @@ -145,10 +142,7 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *), fsoffs = dlp->partitions[0].first * (dlp->dp.dp_secbytes / DEV_BSIZE); fsend = fsoffs + dlp->partitions[0].blocks * (dlp->dp.dp_secbytes / DEV_BSIZE); - /* - * If the disklabel is about to be written to disk, don't modify it! - * just bail out. - */ + /* Only came here to find the offset... */ if (partoffp) { *partoffp = fsoffs; goto finished; @@ -199,6 +193,15 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *), lp->d_checksum = dkcksum(lp); finished: + /* record the OpenBSD partition's placement for the caller */ + if (partoffp) + *partoffp = fsoffs; + else { + DL_SETBSTART(lp, fsoffs); + DL_SETBEND(lp, fsend); + } + + /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) goto done; |