diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-06-09 23:06:47 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-06-09 23:06:47 +0000 |
commit | bf5598aa66e79a8ff8eafdb8ca244c24338b015a (patch) | |
tree | 8816cd9f0a35a0c2f86285a31df8462aa494d15d /sys/arch/mvme88k | |
parent | 88666c312fa635e655afe7d84a00a0c52035a4ba (diff) |
The differences in the last non-homogeneous bounds_check_with_label()
routines (alpha, vax) prove to be not worth keeping. Move
bounds_check_with_label() into the MI world. Eliminate unreliable and
almost certainly useless checks for overwriting a disklabel.
After discussion with deraadt@
Diffstat (limited to 'sys/arch/mvme88k')
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 07ff2186ab7..2e5633dd0d6 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.48 2007/06/09 04:33:14 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.49 2007/06/09 23:06:46 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -183,63 +183,6 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), return (error); } -/* - * Determine the size of the transfer, and make sure it is - * within the boundaries of the partition. Adjust transfer - * if needed, and signal errors or early completion. - */ -int -bounds_check_with_label(struct buf *bp, struct disklabel *lp, - struct cpu_disklabel *osdep, int wlabel) -{ -#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE)) - struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); - int labelsector = blockpersec(DL_GETPOFFSET(&lp->d_partitions[RAW_PART]), lp) + - LABELSECTOR; - int sz = howmany(bp->b_bcount, DEV_BSIZE); - - /* avoid division by zero */ - if (lp->d_secpercyl == 0) { - bp->b_error = EINVAL; - goto bad; - } - - /* beyond partition? */ - if (bp->b_blkno + sz > blockpersec(DL_GETPSIZE(p), lp)) { - sz = blockpersec(DL_GETPSIZE(p), lp) - bp->b_blkno; - if (sz == 0) { - /* If exactly at end of disk, return EOF. */ - bp->b_resid = bp->b_bcount; - return (-1); - } - if (sz < 0) { - /* If past end of disk, return EINVAL. */ - bp->b_error = EINVAL; - goto bad; - } - /* Otherwise, truncate request. */ - bp->b_bcount = sz << DEV_BSHIFT; - } - - /* Overwriting disk label? */ - if (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) <= labelsector && - bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp) + sz > labelsector && - (bp->b_flags & B_READ) == 0 && !wlabel) { - bp->b_error = EROFS; - goto bad; - } - - /* calculate cylinder for disksort to order transfers with */ - bp->b_cylinder = (bp->b_blkno + blockpersec(DL_GETPOFFSET(p), lp)) / - lp->d_secpercyl; - return (1); - -bad: - bp->b_flags |= B_ERROR; - return (-1); -} - - void bsdtocpulabel(struct disklabel *lp, struct cpu_disklabel *clp) { |