summaryrefslogtreecommitdiff
path: root/sys/arch/alpha
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-06-09 23:06:47 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-06-09 23:06:47 +0000
commitbf5598aa66e79a8ff8eafdb8ca244c24338b015a (patch)
tree8816cd9f0a35a0c2f86285a31df8462aa494d15d /sys/arch/alpha
parent88666c312fa635e655afe7d84a00a0c52035a4ba (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/alpha')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c58
1 files changed, 1 insertions, 57 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c
index a02595d5086..f2d1bd2e6e8 100644
--- a/sys/arch/alpha/alpha/disksubr.c
+++ b/sys/arch/alpha/alpha/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.81 2007/06/09 18:05:45 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.82 2007/06/09 23:06:45 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -444,59 +444,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) +
- osdep->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);
-}