From 280b7a0e095c91bf6c65971480168f20a723d09a Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 7 Apr 1997 12:00:17 +0000 Subject: [PATCH] unconfuse partition/block sizing stuff --- sys/arch/powerpc/powerpc/disksubr.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sys/arch/powerpc/powerpc/disksubr.c b/sys/arch/powerpc/powerpc/disksubr.c index f84372b3e16..31443bc7579 100644 --- a/sys/arch/powerpc/powerpc/disksubr.c +++ b/sys/arch/powerpc/powerpc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.2 1996/12/28 06:21:55 rahnds Exp $ */ +/* $OpenBSD: disksubr.c,v 1.3 1997/04/07 12:00:17 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.1 1996/09/30 16:34:43 ws Exp $ */ /* @@ -334,13 +334,12 @@ bounds_check_with_label(bp, lp, wlabel) 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); - int sz; + int sz = howmany(bp->b_bcount, DEV_BSIZE); - sz = howmany(bp->b_bcount, lp->d_secsize); - - if (bp->b_blkno + sz > p->p_size) { - sz = p->p_size - bp->b_blkno; + if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) { + sz = blockpersec(p->p_size, lp) - bp->b_blkno; if (sz == 0) { /* If axactly at end of disk, return EOF. */ bp->b_resid = bp->b_bcount; @@ -352,13 +351,12 @@ bounds_check_with_label(bp, lp, wlabel) goto bad; } /* Otherwise truncate request. */ - bp->b_bcount = sz * lp->d_secsize; + bp->b_bcount = sz << DEV_BSHIFT; } /* calculate cylinder for disksort to order transfers with */ - bp->b_cylinder = (bp->b_blkno + p->p_offset) - / (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl; - + bp->b_cylinder = (bp->b_blkno + blockpersec(p->p_offset, lp)) / + lp->d_secpercyl; return 1; bad: -- 2.20.1