diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-08-08 23:49:54 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-08-08 23:49:54 +0000 |
commit | 39fbf175f3c3d2f6af075622e52b06c981b78656 (patch) | |
tree | 0793e726574a7b0c41ad408a213cf10b6409a203 /sys/kern | |
parent | 6c6bcec1e5b311470799378c970ce1cff6ade984 (diff) |
Admit b_blkno means block number; a block is DEV_BSIZE (a.k.a.
512) bytes; ffs is inextricably tied to using b_blkno and disklabel
always uses sectorsize units.
Thus use DEV_BSIZE units for all fields describing ffs filesystems
and convert to/from sectors where required. This enables the creation
and use of ffs filesystems on non-512 byte sectorsize devices.
This diff allows i386 and sgi (the two test platforms) to find
disklabels that are not on a sectorsize boundary. Same change to
further archs coming.
This is a no-op on 512-byte sectorsize devices.
This work triggered by jsing@'s need to create ffs filesystems on
sgi cdroms so we can create cdrom install media for sgi.
sgi testing by jsing@
ok jsing@ pedro@ "looks sane" beck@ weingart@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_disk.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 186ff615e10..41deb07f29b 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.79 2008/06/25 15:26:43 reyk Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.80 2008/08/08 23:49:53 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -378,6 +378,7 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), daddr64_t part_blkno = DOSBBSECTOR; int dospartoff = 0, i, ourpart = -1; int wander = 1, n = 0, loop = 0; + int offset; if (lp->d_secpercyl == 0) return ("invalid label, d_secpercyl == 0"); @@ -397,7 +398,8 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), part_blkno = extoff; /* read boot record */ - bp->b_blkno = part_blkno; + bp->b_blkno = DL_BLKTOSEC(lp, part_blkno) * DL_BLKSPERSEC(lp); + offset = DL_BLKOFFSET(lp, part_blkno) + DOSPARTOFF; bp->b_bcount = lp->d_secsize; bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); @@ -407,7 +409,7 @@ readdoslabel(struct buf *bp, void (*strat)(struct buf *), return ("dos partition I/O error"); } - bcopy(bp->b_data + DOSPARTOFF, dp, sizeof(dp)); + bcopy(bp->b_data + offset, dp, sizeof(dp)); if (ourpart == -1) { /* Search for our MBR partition */ @@ -548,7 +550,9 @@ notfat: if (spoofonly) return (NULL); - bp->b_blkno = dospartoff + DOS_LABELSECTOR; + bp->b_blkno = DL_BLKTOSEC(lp, dospartoff + DOS_LABELSECTOR) * + DL_BLKSPERSEC(lp); + offset = DL_BLKOFFSET(lp, dospartoff + DOS_LABELSECTOR); bp->b_bcount = lp->d_secsize; bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); @@ -556,7 +560,7 @@ notfat: return ("disk label I/O error"); /* sub-MBR disklabels are always at a LABELOFFSET of 0 */ - return checkdisklabel(bp->b_data, lp); + return checkdisklabel(bp->b_data + offset, lp); } /* @@ -620,7 +624,6 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_int openmask) int bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) { -#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) struct partition *p = &lp->d_partitions[DISKPART(bp->b_dev)]; daddr64_t sz = howmany(bp->b_bcount, DEV_BSIZE); @@ -632,8 +635,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) panic("bounds_check_with_label %lld %lld\n", bp->b_blkno, sz); /* beyond partition? */ - if (bp->b_blkno + sz > blockpersec(DL_GETPSIZE(p), lp)) { - sz = blockpersec(DL_GETPSIZE(p), lp) - bp->b_blkno; + if (bp->b_blkno + sz > DL_SECTOBLK(lp, DL_GETPSIZE(p))) { + sz = DL_SECTOBLK(lp, DL_GETPSIZE(p)) - bp->b_blkno; if (sz == 0) { /* If exactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; @@ -648,8 +651,8 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) } /* calculate cylinder for disksort to order transfers with */ - bp->b_cylinder = (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp)) / - blockpersec(lp->d_secpercyl, lp); + bp->b_cylinder = (bp->b_blkno + DL_SECTOBLK(lp, DL_GETPOFFSET(p))) / + DL_SECTOBLK(lp, lp->d_secpercyl); return (1); bad: |