summaryrefslogtreecommitdiff
path: root/sys/arch
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
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')
-rw-r--r--sys/arch/alpha/alpha/disksubr.c58
-rw-r--r--sys/arch/amd64/amd64/disksubr.c58
-rw-r--r--sys/arch/arm/arm/disksubr.c58
-rw-r--r--sys/arch/aviion/aviion/disksubr.c58
-rw-r--r--sys/arch/hp300/hp300/disksubr.c58
-rw-r--r--sys/arch/hppa/hppa/disksubr.c58
-rw-r--r--sys/arch/hppa64/hppa64/disksubr.c58
-rw-r--r--sys/arch/i386/i386/disksubr.c57
-rw-r--r--sys/arch/landisk/landisk/disksubr.c58
-rw-r--r--sys/arch/luna88k/luna88k/disksubr.c58
-rw-r--r--sys/arch/mac68k/mac68k/disksubr.c58
-rw-r--r--sys/arch/macppc/macppc/disksubr.c58
-rw-r--r--sys/arch/mips64/mips64/disksubr.c58
-rw-r--r--sys/arch/mvme68k/mvme68k/disksubr.c59
-rw-r--r--sys/arch/mvme88k/mvme88k/disksubr.c59
-rw-r--r--sys/arch/mvmeppc/mvmeppc/disksubr.c58
-rw-r--r--sys/arch/sparc/sparc/disksubr.c58
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c58
-rw-r--r--sys/arch/vax/vax/disksubr.c57
19 files changed, 19 insertions, 1083 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);
-}
diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c
index 883e5651b7b..ba152aec806 100644
--- a/sys/arch/amd64/amd64/disksubr.c
+++ b/sys/arch/amd64/amd64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.44 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.45 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -407,59 +407,3 @@ done:
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);
-}
diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c
index c45b188a7d2..d4ee2767673 100644
--- a/sys/arch/arm/arm/disksubr.c
+++ b/sys/arch/arm/arm/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.39 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.40 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -380,59 +380,3 @@ done:
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);
-}
diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c
index 693f53f9522..1214ff4d0fc 100644
--- a/sys/arch/aviion/aviion/disksubr.c
+++ b/sys/arch/aviion/aviion/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.30 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.31 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -379,59 +379,3 @@ done:
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);
-}
diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c
index 7f08b6e4252..2bdf804bc14 100644
--- a/sys/arch/hp300/hp300/disksubr.c
+++ b/sys/arch/hp300/hp300/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.35 2007/06/09 04:08:39 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.36 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */
/*
@@ -175,59 +175,3 @@ done:
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);
-}
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index a33d94ee953..718c8e85026 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.61 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.62 2007/06/09 23:06:46 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -589,59 +589,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);
-}
diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c
index 0e82bae17f9..73070bf248c 100644
--- a/sys/arch/hppa64/hppa64/disksubr.c
+++ b/sys/arch/hppa64/hppa64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.44 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.45 2007/06/09 23:06:46 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -589,59 +589,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);
-}
diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c
index a3f8b1628b3..04c1dd1f59c 100644
--- a/sys/arch/i386/i386/disksubr.c
+++ b/sys/arch/i386/i386/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.84 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.85 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -408,58 +408,3 @@ done:
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);
-}
diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c
index e52648d697c..09ba4d46fea 100644
--- a/sys/arch/landisk/landisk/disksubr.c
+++ b/sys/arch/landisk/landisk/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.27 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.28 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -380,59 +380,3 @@ done:
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);
-}
diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c
index ee14e7cea9d..431af300d22 100644
--- a/sys/arch/luna88k/luna88k/disksubr.c
+++ b/sys/arch/luna88k/luna88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.23 2007/06/09 04:08:39 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.24 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */
/*
@@ -249,62 +249,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
diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c
index 567f8456fe0..23b1bcf65db 100644
--- a/sys/arch/mac68k/mac68k/disksubr.c
+++ b/sys/arch/mac68k/mac68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.43 2007/06/09 04:08:39 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.44 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */
/*
@@ -484,59 +484,3 @@ done:
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);
-}
diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c
index 9d2c3f466f8..293e1e609ed 100644
--- a/sys/arch/macppc/macppc/disksubr.c
+++ b/sys/arch/macppc/macppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.49 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.50 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -492,59 +492,3 @@ done:
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);
-}
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);
-}
diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c
index 72cc292ae3b..5c56e139d92 100644
--- a/sys/arch/mvme68k/mvme68k/disksubr.c
+++ b/sys/arch/mvme68k/mvme68k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.52 2007/06/09 04:33:12 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.53 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)
{
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)
{
diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c
index 0f7cb2531ba..3b03f6a7142 100644
--- a/sys/arch/mvmeppc/mvmeppc/disksubr.c
+++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.45 2007/06/09 18:05:47 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.46 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
/*
@@ -382,59 +382,3 @@ done:
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);
-}
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
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 91c5c0be0c6..9597405a53b 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.36 2007/06/09 04:08:39 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.37 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
@@ -222,62 +222,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
diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c
index 6db98f3c998..8963697fe87 100644
--- a/sys/arch/vax/vax/disksubr.c
+++ b/sys/arch/vax/vax/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.46 2007/06/09 04:08:39 deraadt Exp $ */
+/* $OpenBSD: disksubr.c,v 1.47 2007/06/09 23:06:46 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */
/*
@@ -51,61 +51,6 @@
#include <vax/mscp/mscp.h> /* For disk encoding scheme */
/*
- * 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 = DL_GETPOFFSET(&lp->d_partitions[RAW_PART]);
- int maxsz = DL_GETPSIZE(p);
- int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* avoid division by zero */
- if (lp->d_secpercyl == 0) {
- bp->b_error = EINVAL;
- goto bad;
- }
-
- /* beyond partition? */
- if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
- /* if exactly at end of disk, return EOF. */
- if (bp->b_blkno == maxsz) {
- bp->b_resid = bp->b_bcount;
- return (-1);
- }
- /* Otherwise, truncate request. */
- sz = maxsz - bp->b_blkno;
- if (sz <= 0) {
- bp->b_error = EINVAL;
- goto bad;
- }
- /* Otherwise, truncate request. */
- bp->b_bcount = sz << DEV_BSHIFT;
- }
-
- /* overwriting disk label ? */
- if (bp->b_blkno + DL_GETPOFFSET(p) <= LABELSECTOR + 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 + DL_GETPOFFSET(p)) / lp->d_secpercyl;
- return (1);
-
-bad:
- bp->b_flags |= B_ERROR;
- return (-1);
-}
-
-/*
* Attempt to read a disk label from a device
* using the indicated strategy routine.
* The label must be partly set up before this: