diff options
author | phk <phk@FreeBSD.org> | 1999-05-11 19:55:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-05-11 19:55:07 +0000 |
commit | 7e26ca1d1a4bb6507cb6f9241f2d35b1048eaecd (patch) | |
tree | 31ecebf331e4a644fafb96ecafe7d2b6b1a24d39 /sys/kern/vfs_subr.c | |
parent | c783fdfffac012af2a31c3939b62a23b94680404 (diff) | |
download | FreeBSD-src-7e26ca1d1a4bb6507cb6f9241f2d35b1048eaecd.zip FreeBSD-src-7e26ca1d1a4bb6507cb6f9241f2d35b1048eaecd.tar.gz |
Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.
Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()
For now they're functions, they will become in-line functions
after one of the next two steps in this process.
Return major/minor/makedev to macro-hood for userland.
Register a name in cdevsw[] for the "filedescriptor" driver.
In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.
In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).
A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.
Without DEVT_FASCIST I belive this patch is a no-op.
Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.
Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ff42b06..bce703f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.192 1999/05/08 06:39:48 phk Exp $ + * $Id: vfs_subr.c,v 1.193 1999/05/08 07:02:38 phk Exp $ */ /* @@ -1188,7 +1188,7 @@ bdevvp(dev, vpp) } vp = nvp; vp->v_type = VBLK; - if ((nvp = checkalias(vp, dev, (struct mount *)0)) != NULL) { + if ((nvp = checkalias(vp, dev2udev(dev), (struct mount *)0)) != NULL) { vput(vp); vp = nvp; } @@ -1207,22 +1207,25 @@ bdevvp(dev, vpp) struct vnode * checkalias(nvp, nvp_rdev, mp) register struct vnode *nvp; - dev_t nvp_rdev; + udev_t nvp_rdev; struct mount *mp; { struct proc *p = curproc; /* XXX */ struct vnode *vp; struct vnode **vpp; - int rmaj = major(nvp_rdev); + int rmaj = umajor(nvp_rdev); + dev_t dev; if (nvp->v_type != VBLK && nvp->v_type != VCHR) return (NULLVP); + dev = udev2dev(nvp_rdev, 2); + vpp = &speclisth[SPECHASH(nvp_rdev)]; loop: simple_lock(&spechash_slock); for (vp = *vpp; vp; vp = vp->v_specnext) { - if (nvp_rdev != vp->v_rdev || nvp->v_type != vp->v_type) + if (dev != vp->v_rdev || nvp->v_type != vp->v_type) continue; /* * Alias, but not in use, so flush it out. @@ -1262,7 +1265,7 @@ loop: sizeof(struct specinfo), M_VNODE, M_WAITOK); bzero(sinfo, sizeof(struct specinfo)); nvp->v_specinfo = sinfo; - sinfo->si_rdev = nvp_rdev; + sinfo->si_rdev = dev; sinfo->si_hashchain = vpp; sinfo->si_specnext = *vpp; sinfo->si_bsize_phys = DEV_BSIZE; @@ -1275,12 +1278,12 @@ loop: */ if (nvp->v_type == VBLK && rmaj < nblkdev) { - if (bdevsw(nvp_rdev) && bdevsw(nvp_rdev)->d_parms) + if (bdevsw(dev) && bdevsw(dev)->d_parms) - (*bdevsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET); + (*bdevsw(dev)->d_parms)(dev, sinfo, DPARM_GET); } else if (nvp->v_type == VCHR && rmaj < nchrdev) { - if (devsw(nvp_rdev) && devsw(nvp_rdev)->d_parms) - (*devsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET); + if (devsw(dev) && devsw(dev)->d_parms) + (*devsw(dev)->d_parms)(dev, sinfo, DPARM_GET); } simple_unlock(&spechash_slock); |