summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/alpha/machdep.c60
-rw-r--r--sys/amd64/amd64/machdep.c59
-rw-r--r--sys/i386/i386/machdep.c59
-rw-r--r--sys/ia64/ia64/machdep.c62
-rw-r--r--sys/kern/subr_disklabel.c58
-rw-r--r--sys/pc98/i386/machdep.c59
-rw-r--r--sys/pc98/pc98/machdep.c59
7 files changed, 58 insertions, 358 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index 276fd3c..db64fd3 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -1917,66 +1917,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-
-}
-
static int
sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS)
{
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 3516f1c..fcf7434 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -2451,65 +2451,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-}
-
#ifdef DDB
/*
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 3516f1c..fcf7434 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -2451,65 +2451,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-}
-
#ifdef DDB
/*
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c
index 89d61cb..89cb3ff 100644
--- a/sys/ia64/ia64/machdep.c
+++ b/sys/ia64/ia64/machdep.c
@@ -1319,68 +1319,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
-#if 0
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
-#endif
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-
-}
-
static int
sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS)
{
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c
index 000c1f0..9e27a96 100644
--- a/sys/kern/subr_disklabel.c
+++ b/sys/kern/subr_disklabel.c
@@ -216,3 +216,61 @@ 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 bio *bp, struct disklabel *lp, int wlabel)
+{
+ struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
+ int labelsect = lp->d_partitions[0].p_offset;
+ int maxsz = p->p_size,
+ sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
+
+ /* overwriting disk label ? */
+ /* XXX should also protect bootstrap in first 8K */
+ if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
+#if LABELSECTOR != 0
+ bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
+#endif
+ (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
+ bp->bio_error = EROFS;
+ goto bad;
+ }
+
+#if defined(DOSBBSECTOR) && defined(notyet)
+ /* overwriting master boot record? */
+ if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
+ (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
+ bp->bio_error = EROFS;
+ goto bad;
+ }
+#endif
+
+ /* beyond partition? */
+ if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
+ /* if exactly at end of disk, return an EOF */
+ if (bp->bio_blkno == maxsz) {
+ bp->bio_resid = bp->bio_bcount;
+ return(0);
+ }
+ /* or truncate if part of it fits */
+ sz = maxsz - bp->bio_blkno;
+ if (sz <= 0) {
+ bp->bio_error = EINVAL;
+ goto bad;
+ }
+ bp->bio_bcount = sz << DEV_BSHIFT;
+ }
+
+ bp->bio_pblkno = bp->bio_blkno + p->p_offset;
+ return(1);
+
+bad:
+ bp->bio_flags |= BIO_ERROR;
+ return(-1);
+}
+
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index 5208263..a4aba5a 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -2515,65 +2515,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-}
-
#ifdef DDB
/*
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 5208263..a4aba5a 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -2515,65 +2515,6 @@ Debugger(const char *msg)
}
#endif /* no DDB */
-#include <sys/disklabel.h>
-
-/*
- * 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 bio *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->bio_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->bio_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->bio_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->bio_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->bio_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->bio_cmd == BIO_WRITE) && wlabel == 0) {
- bp->bio_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->bio_blkno < 0 || bp->bio_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->bio_blkno == maxsz) {
- bp->bio_resid = bp->bio_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->bio_blkno;
- if (sz <= 0) {
- bp->bio_error = EINVAL;
- goto bad;
- }
- bp->bio_bcount = sz << DEV_BSHIFT;
- }
-
- bp->bio_pblkno = bp->bio_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->bio_flags |= BIO_ERROR;
- return(-1);
-}
-
#ifdef DDB
/*
OpenPOWER on IntegriCloud