Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/miscfs/specfs change spec_{read, write}() to specify the ...



details:   https://anonhg.NetBSD.org/src/rev/e2b9f0d53cd6
branches:  trunk
changeset: 515379:e2b9f0d53cd6
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Sep 23 04:39:25 2001 +0000

description:
change spec_{read,write}() to specify the device blkno in units of DEV_BSIZE
rather than the device's sector size.  this allows /dev/rcd0a and /dev/cd0a
to return the same data.  fixes PRs 3261 and 14026.

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diffs (73 lines):

diff -r 3150be5d4ddd -r e2b9f0d53cd6 sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Sun Sep 23 01:37:03 2001 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Sun Sep 23 04:39:25 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.58 2001/09/21 08:02:55 chs Exp $      */
+/*     $NetBSD: spec_vnops.c,v 1.59 2001/09/23 04:39:25 chs Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -263,7 +263,7 @@
        struct proc *p = uio->uio_procp;
        struct buf *bp;
        daddr_t bn;
-       int bsize, bscale, ssize;
+       int bsize, bscale;
        struct partinfo dpart;
        int n, on, majordev;
        int (*ioctl) __P((dev_t, u_long, caddr_t, int, struct proc *));
@@ -291,7 +291,6 @@
                if (uio->uio_offset < 0)
                        return (EINVAL);
                bsize = BLKDEV_IOSIZE;
-               ssize = DEV_BSIZE;
                if ((majordev = major(vp->v_rdev)) < nblkdev &&
                    (ioctl = bdevsw[majordev].d_ioctl) != NULL &&
                    (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) {
@@ -299,12 +298,10 @@
                            dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
                                bsize = dpart.part->p_frag *
                                    dpart.part->p_fsize;
-                       if (dpart.disklab->d_secsize != 0)
-                               ssize = dpart.disklab->d_secsize;
                }
-               bscale = bsize / ssize;
+               bscale = bsize >> DEV_BSHIFT;
                do {
-                       bn = (uio->uio_offset / ssize) &~ (bscale - 1);
+                       bn = (uio->uio_offset >> DEV_BSHIFT) &~ (bscale - 1);
                        on = uio->uio_offset % bsize;
                        n = min((unsigned)(bsize - on), uio->uio_resid);
                        error = bread(vp, bn, bsize, NOCRED, &bp);
@@ -343,7 +340,7 @@
        struct proc *p = uio->uio_procp;
        struct buf *bp;
        daddr_t bn;
-       int bsize, bscale, ssize;
+       int bsize, bscale;
        struct partinfo dpart;
        int n, on, majordev;
        int (*ioctl) __P((dev_t, u_long, caddr_t, int, struct proc *));
@@ -371,7 +368,6 @@
                if (uio->uio_offset < 0)
                        return (EINVAL);
                bsize = BLKDEV_IOSIZE;
-               ssize = DEV_BSIZE;
                if ((majordev = major(vp->v_rdev)) < nblkdev &&
                    (ioctl = bdevsw[majordev].d_ioctl) != NULL &&
                    (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) {
@@ -379,12 +375,10 @@
                            dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
                                bsize = dpart.part->p_frag *
                                    dpart.part->p_fsize;
-                       if (dpart.disklab->d_secsize != 0)
-                               ssize = dpart.disklab->d_secsize;
                }
-               bscale = bsize / ssize;
+               bscale = bsize >> DEV_BSHIFT;
                do {
-                       bn = (uio->uio_offset / ssize) &~ (bscale - 1);
+                       bn = (uio->uio_offset >> DEV_BSHIFT) &~ (bscale - 1);
                        on = uio->uio_offset % bsize;
                        n = min((unsigned)(bsize - on), uio->uio_resid);
                        if (n == bsize)



Home | Main Index | Thread Index | Old Index