summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-09-01 14:08:26 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-09-01 14:08:26 +0000
commit0333dfb0a57f569bf4883e20c0e62a3bc74be17f (patch)
tree231306219535e72e59c7c638318f59137e18bb27 /sys
parentb584ad474d01d8f5e7f5710d8c5a46710799ebbb (diff)
Allow sgi to spoof the native label. But don't spoof when just
looking for the place to write the disklabel, i.e. partoffp != NULL. tested & ok jsing@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sgi/sgi/disksubr.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/arch/sgi/sgi/disksubr.c b/sys/arch/sgi/sgi/disksubr.c
index f0745769e71..ef59b5e3ef2 100644
--- a/sys/arch/sgi/sgi/disksubr.c
+++ b/sys/arch/sgi/sgi/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.9 2008/08/08 23:49:53 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.10 2008/09/01 14:08:25 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -118,6 +118,9 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
int fsoffs = 0;
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;
@@ -130,10 +133,8 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
}
dlp = (struct sgilabel *)(bp->b_data + LABELOFFSET);
- if (dlp->magic != htobe32(SGILABEL_MAGIC)) {
- fsoffs = 0;
+ if (dlp->magic != htobe32(SGILABEL_MAGIC))
goto finished;
- }
if (dlp->partitions[0].blocks == 0) {
msg = "no BSD partition";
@@ -141,8 +142,14 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
}
fsoffs = dlp->partitions[0].first * (dlp->dp.dp_secbytes / DEV_BSIZE);
- if (spoofonly)
+ /*
+ * If the disklabel is about to be written to disk, don't modify it!
+ * just bail out.
+ */
+ if (partoffp) {
+ *partoffp = fsoffs;
goto finished;
+ }
p = (int *)dlp;
i = sizeof(struct sgilabel) / sizeof(int);
@@ -183,9 +190,6 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
lp->d_checksum = dkcksum(lp);
finished:
- if (partoffp)
- *partoffp = fsoffs;
-
if (spoofonly)
goto done;