summaryrefslogtreecommitdiff
path: root/sys/arch/amiga
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-04-10 08:52:53 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-04-10 08:52:53 +0000
commit0bc554df771db883a14fbb1eb629998606c01b8f (patch)
tree962bbf63b2ea8cb90913609c15d5b6bbe6faf266 /sys/arch/amiga
parentbd929358a1e201a6a8b9113336a0c5e4b733ec13 (diff)
Do block/sector handling like the other ports
Diffstat (limited to 'sys/arch/amiga')
-rw-r--r--sys/arch/amiga/amiga/disksubr.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/sys/arch/amiga/amiga/disksubr.c b/sys/arch/amiga/amiga/disksubr.c
index 80533c08e76..d923aacd9fc 100644
--- a/sys/arch/amiga/amiga/disksubr.c
+++ b/sys/arch/amiga/amiga/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.11 1997/02/23 02:33:05 niklas Exp $ */
+/* $OpenBSD: disksubr.c,v 1.12 1997/04/10 08:52:52 niklas Exp $ */
/* $NetBSD: disksubr.c,v 1.27 1996/10/13 03:06:34 christos Exp $ */
/*
@@ -506,46 +506,35 @@ bounds_check_with_label(bp, lp, wlabel)
struct disklabel *lp;
int wlabel;
{
- struct partition *pp;
- long maxsz, sz;
-
- pp = &lp->d_partitions[DISKPART(bp->b_dev)];
- if (bp->b_flags & B_RAW) {
- maxsz = pp->p_size * (lp->d_secsize / DEV_BSIZE);
- sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
- } else {
- maxsz = pp->p_size;
- sz = (bp->b_bcount + lp->d_secsize - 1) / lp->d_secsize;
- }
-
- if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
- if (bp->b_blkno == maxsz) {
- /*
- * trying to get one block beyond return EOF.
- */
+#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
+ struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
+ int sz = howmany(bp->b_bcount, DEV_BSIZE);
+
+ if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) {
+ sz = blockpersec(p->p_size, lp) - bp->b_blkno;
+ if (sz == 0) {
+ /* If exactly at end of disk, return EOF. */
bp->b_resid = bp->b_bcount;
- return(0);
+ goto done;
}
- sz = maxsz - bp->b_blkno;
- if (sz <= 0 || bp->b_blkno < 0) {
+ if (sz < 0) {
+ /* If past end of disk, return EINVAL. */
bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- return(-1);
+ goto bad;
}
- /*
- * adjust count down
- */
- if (bp->b_flags & B_RAW)
- bp->b_bcount = sz << DEV_BSHIFT;
- else
- bp->b_bcount = sz * lp->d_secsize;
+ /* Otherwise, truncate request. */
+ bp->b_bcount = sz << DEV_BSHIFT;
}
- /*
- * calc cylinder for disksort to order transfers with
- */
- bp->b_cylin = (bp->b_blkno + pp->p_offset) / lp->d_secpercyl;
- return(1);
+ /* Calculate cylinder for disksort to order transfers with. */
+ bp->b_cylin = (bp->b_blkno + blockpersec(p->p_offset, lp)) /
+ lp->d_secpercyl;
+ return (1);
+
+bad:
+ bp->b_flags |= B_ERROR;
+done:
+ return (0);
}
u_long