summaryrefslogtreecommitdiff
path: root/sys/arch/sgi
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r--sys/arch/sgi/sgi/disksubr.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/arch/sgi/sgi/disksubr.c b/sys/arch/sgi/sgi/disksubr.c
index 9926730f4ae..f0745769e71 100644
--- a/sys/arch/sgi/sgi/disksubr.c
+++ b/sys/arch/sgi/sgi/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.8 2008/07/20 13:46:16 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.9 2008/08/08 23:49:53 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -116,6 +116,7 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
char *msg = NULL;
int i, *p, cs = 0;
int fsoffs = 0;
+ int offset;
bp->b_blkno = 0;
bp->b_bcount = lp->d_secsize;
@@ -138,7 +139,7 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
msg = "no BSD partition";
goto done;
}
- fsoffs = dlp->partitions[0].first;
+ fsoffs = dlp->partitions[0].first * (dlp->dp.dp_secbytes / DEV_BSIZE);
if (spoofonly)
goto finished;
@@ -153,6 +154,7 @@ readsgilabel(struct buf *bp, void (*strat)(struct buf *),
}
/* Set up partitions i-l if there is no BSD label. */
+ DL_SETDSIZE(lp, (DL_GETDSIZE(lp)*lp->d_secsize) / dlp->dp.dp_secbytes);
lp->d_secsize = dlp->dp.dp_secbytes;
lp->d_nsectors = dlp->dp.dp_secs;
lp->d_ntracks = dlp->dp.dp_trks0;
@@ -187,7 +189,8 @@ finished:
if (spoofonly)
goto done;
- bp->b_blkno = fsoffs + LABELSECTOR;
+ bp->b_blkno = DL_BLKTOSEC(lp, fsoffs + LABELSECTOR) * DL_BLKSPERSEC(lp);
+ offset = DL_BLKOFFSET(lp, fsoffs + LABELSECTOR) + LABELOFFSET;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ | B_RAW;
(*strat)(bp);
@@ -196,7 +199,7 @@ finished:
goto done;
}
- return checkdisklabel(bp->b_data + LABELOFFSET, lp);
+ return checkdisklabel(bp->b_data + offset, lp);
done:
return (msg);
@@ -209,6 +212,7 @@ int
writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp)
{
int error = EIO, partoff = -1;
+ int offset;
struct buf *bp = NULL;
struct disklabel *dlp;
@@ -221,14 +225,15 @@ 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;
bp->b_flags = B_BUSY | B_READ | B_RAW;
(*strat)(bp);
if ((error = biowait(bp)) != 0)
goto done;
- dlp = (struct disklabel *)(bp->b_data + LABELOFFSET);
+ dlp = (struct disklabel *)(bp->b_data + offset);
*dlp = *lp;
bp->b_flags = B_BUSY | B_WRITE | B_RAW;
(*strat)(bp);