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/sparc | |
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/sparc')
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index cff6fc33180..4c35a05adfd 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.57 2007/06/09 18:06:50 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.58 2007/06/09 23:06:46 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -223,62 +223,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); -} - /************************************************************************ * * The rest of this was taken from arch/sparc/scsi/sun_disklabel.c |