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/mips64 | |
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/mips64')
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index b2e2a2748e0..c1c0241a923 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.51 2007/06/09 18:05:47 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.52 2007/06/09 23:06:46 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -547,59 +547,3 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), brelse(bp); 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); -} |