summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-10-18 17:51:26 +0000
committerphk <phk@FreeBSD.org>2003-10-18 17:51:26 +0000
commit5a1c5c9c133e6203cc6a02b83c76730842c39948 (patch)
tree6dd8b4e0842295c60c66ee9264f9a862629057b3 /sys
parent42120d22ead76258f3a3435c06d03782daa9d7ad (diff)
downloadFreeBSD-src-5a1c5c9c133e6203cc6a02b83c76730842c39948.zip
FreeBSD-src-5a1c5c9c133e6203cc6a02b83c76730842c39948.tar.gz
Eliminate use bio_blkno.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdc/fdc.c26
-rw-r--r--sys/isa/fd.c26
-rw-r--r--sys/pc98/cbus/fdc.c29
-rw-r--r--sys/pc98/pc98/fd.c29
4 files changed, 38 insertions, 72 deletions
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 8699bb8..0c0d59c 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -1707,10 +1707,10 @@ fdstrategy(struct bio *bp)
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- if (bp->bio_blkno < 0) {
+ if (bp->bio_offset < 0) {
printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->bio_blkno, bp->bio_bcount);
+ "fd%d: fdstrat: bad request offset = %ju, bcount = %ld\n",
+ fdu, (intmax_t)bp->bio_offset, bp->bio_bcount);
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
@@ -1725,16 +1725,12 @@ fdstrategy(struct bio *bp)
/*
* Set up block calculations.
*/
- if (bp->bio_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
+ if (bp->bio_offset >= ((off_t)128 << fd->ft->secsize) * fd->ft->size) {
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- blknum = bp->bio_blkno * DEV_BSIZE / fdblk;
+ blknum = bp->bio_offset / fdblk;
nblocks = fd->ft->size;
if (blknum + bp->bio_bcount / fdblk > nblocks) {
if (blknum >= nblocks) {
@@ -2593,23 +2589,21 @@ fdmisccmd(dev_t dev, u_int cmd, void *data)
bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO);
/*
- * Set up a bio request for fdstrategy(). bio_blkno is faked
+ * Set up a bio request for fdstrategy(). bio_offset is faked
* so that fdstrategy() will seek to the the requested
* cylinder, and use the desired head.
*/
bp->bio_cmd = cmd;
if (cmd == FDBIO_FORMAT) {
- bp->bio_blkno =
+ bp->bio_offset =
(finfo->cyl * (fd->ft->sectrac * fd->ft->heads) +
- finfo->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ finfo->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fd_idfield_data) *
finfo->fd_formb_nsecs;
} else if (cmd == FDBIO_RDSECTID) {
- bp->bio_blkno =
+ bp->bio_offset =
(idfield->cyl * (fd->ft->sectrac * fd->ft->heads) +
- idfield->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ idfield->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fdc_readid);
} else
panic("wrong cmd in fdmisccmd()");
diff --git a/sys/isa/fd.c b/sys/isa/fd.c
index 8699bb8..0c0d59c 100644
--- a/sys/isa/fd.c
+++ b/sys/isa/fd.c
@@ -1707,10 +1707,10 @@ fdstrategy(struct bio *bp)
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- if (bp->bio_blkno < 0) {
+ if (bp->bio_offset < 0) {
printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->bio_blkno, bp->bio_bcount);
+ "fd%d: fdstrat: bad request offset = %ju, bcount = %ld\n",
+ fdu, (intmax_t)bp->bio_offset, bp->bio_bcount);
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
@@ -1725,16 +1725,12 @@ fdstrategy(struct bio *bp)
/*
* Set up block calculations.
*/
- if (bp->bio_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
+ if (bp->bio_offset >= ((off_t)128 << fd->ft->secsize) * fd->ft->size) {
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- blknum = bp->bio_blkno * DEV_BSIZE / fdblk;
+ blknum = bp->bio_offset / fdblk;
nblocks = fd->ft->size;
if (blknum + bp->bio_bcount / fdblk > nblocks) {
if (blknum >= nblocks) {
@@ -2593,23 +2589,21 @@ fdmisccmd(dev_t dev, u_int cmd, void *data)
bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO);
/*
- * Set up a bio request for fdstrategy(). bio_blkno is faked
+ * Set up a bio request for fdstrategy(). bio_offset is faked
* so that fdstrategy() will seek to the the requested
* cylinder, and use the desired head.
*/
bp->bio_cmd = cmd;
if (cmd == FDBIO_FORMAT) {
- bp->bio_blkno =
+ bp->bio_offset =
(finfo->cyl * (fd->ft->sectrac * fd->ft->heads) +
- finfo->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ finfo->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fd_idfield_data) *
finfo->fd_formb_nsecs;
} else if (cmd == FDBIO_RDSECTID) {
- bp->bio_blkno =
+ bp->bio_offset =
(idfield->cyl * (fd->ft->sectrac * fd->ft->heads) +
- idfield->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ idfield->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fdc_readid);
} else
panic("wrong cmd in fdmisccmd()");
diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c
index 3fc145a..77961b3 100644
--- a/sys/pc98/cbus/fdc.c
+++ b/sys/pc98/cbus/fdc.c
@@ -2135,10 +2135,10 @@ fdstrategy(struct bio *bp)
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- if (bp->bio_blkno < 0) {
+ if (bp->bio_offset < 0) {
printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->bio_blkno, bp->bio_bcount);
+ "fd%d: fdstrat: bad request offset = %ju, bcount = %ld\n",
+ fdu, (intmax_t)bp->bio_offset, bp->bio_bcount);
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
@@ -2153,16 +2153,7 @@ fdstrategy(struct bio *bp)
/*
* Set up block calculations.
*/
- if (bp->bio_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
- bp->bio_error = EINVAL;
- bp->bio_flags |= BIO_ERROR;
- goto bad;
- }
- blknum = bp->bio_blkno * DEV_BSIZE / fdblk;
+ blknum = bp->bio_offset / fdblk;
nblocks = fd->ft->size;
if (blknum + bp->bio_bcount / fdblk > nblocks) {
if (blknum >= nblocks) {
@@ -3140,23 +3131,21 @@ fdmisccmd(dev_t dev, u_int cmd, void *data)
bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO);
/*
- * Set up a bio request for fdstrategy(). bio_blkno is faked
+ * Set up a bio request for fdstrategy(). bio_offset is faked
* so that fdstrategy() will seek to the the requested
* cylinder, and use the desired head.
*/
bp->bio_cmd = cmd;
if (cmd == FDBIO_FORMAT) {
- bp->bio_blkno =
+ bp->bio_offset =
(finfo->cyl * (fd->ft->sectrac * fd->ft->heads) +
- finfo->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ finfo->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fd_idfield_data) *
finfo->fd_formb_nsecs;
} else if (cmd == FDBIO_RDSECTID) {
- bp->bio_blkno =
+ bp->bio_offset =
(idfield->cyl * (fd->ft->sectrac * fd->ft->heads) +
- idfield->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ idfield->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fdc_readid);
} else
panic("wrong cmd in fdmisccmd()");
diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c
index 3fc145a..77961b3 100644
--- a/sys/pc98/pc98/fd.c
+++ b/sys/pc98/pc98/fd.c
@@ -2135,10 +2135,10 @@ fdstrategy(struct bio *bp)
bp->bio_flags |= BIO_ERROR;
goto bad;
}
- if (bp->bio_blkno < 0) {
+ if (bp->bio_offset < 0) {
printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->bio_blkno, bp->bio_bcount);
+ "fd%d: fdstrat: bad request offset = %ju, bcount = %ld\n",
+ fdu, (intmax_t)bp->bio_offset, bp->bio_bcount);
bp->bio_error = EINVAL;
bp->bio_flags |= BIO_ERROR;
goto bad;
@@ -2153,16 +2153,7 @@ fdstrategy(struct bio *bp)
/*
* Set up block calculations.
*/
- if (bp->bio_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
- bp->bio_error = EINVAL;
- bp->bio_flags |= BIO_ERROR;
- goto bad;
- }
- blknum = bp->bio_blkno * DEV_BSIZE / fdblk;
+ blknum = bp->bio_offset / fdblk;
nblocks = fd->ft->size;
if (blknum + bp->bio_bcount / fdblk > nblocks) {
if (blknum >= nblocks) {
@@ -3140,23 +3131,21 @@ fdmisccmd(dev_t dev, u_int cmd, void *data)
bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO);
/*
- * Set up a bio request for fdstrategy(). bio_blkno is faked
+ * Set up a bio request for fdstrategy(). bio_offset is faked
* so that fdstrategy() will seek to the the requested
* cylinder, and use the desired head.
*/
bp->bio_cmd = cmd;
if (cmd == FDBIO_FORMAT) {
- bp->bio_blkno =
+ bp->bio_offset =
(finfo->cyl * (fd->ft->sectrac * fd->ft->heads) +
- finfo->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ finfo->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fd_idfield_data) *
finfo->fd_formb_nsecs;
} else if (cmd == FDBIO_RDSECTID) {
- bp->bio_blkno =
+ bp->bio_offset =
(idfield->cyl * (fd->ft->sectrac * fd->ft->heads) +
- idfield->head * fd->ft->sectrac) *
- fdblk / DEV_BSIZE;
+ idfield->head * fd->ft->sectrac) * fdblk;
bp->bio_bcount = sizeof(struct fdc_readid);
} else
panic("wrong cmd in fdmisccmd()");
OpenPOWER on IntegriCloud