From 39fbf175f3c3d2f6af075622e52b06c981b78656 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Fri, 8 Aug 2008 23:49:54 +0000 Subject: 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@ --- sys/arch/sgi/sgi/disksubr.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'sys/arch/sgi') 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); -- cgit v1.2.3