I got tired of seeing all the cdevsw[major(foo)] all over the place.

Made a new (inline) function devsw(dev_t dev) and substituted it.

Changed to the BDEV variant to this format as well: bdevsw(dev_t dev)

DEVFS will eventually benefit from this change too.
This commit is contained in:
phk 1999-05-08 06:40:31 +00:00
parent f67af4878b
commit f1da116583
40 changed files with 214 additions and 188 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: autoconf.c,v 1.17 1999/05/03 09:36:26 dfr Exp $
* $Id: autoconf.c,v 1.18 1999/05/07 17:48:44 mjacob Exp $
*/
#include "opt_bootp.h"
@ -296,11 +296,11 @@ setdumpdev(dev)
return (0);
}
maj = major(dev);
if (maj >= nblkdev || bdevsw(maj) == NULL)
if (maj >= nblkdev || bdevsw(dev) == NULL)
return (ENXIO); /* XXX is this right? */
if (bdevsw(maj)->d_psize == NULL)
if (bdevsw(dev)->d_psize == NULL)
return (ENXIO); /* XXX should be ENODEV ? */
psize = bdevsw(maj)->d_psize(dev);
psize = bdevsw(dev)->d_psize(dev);
if (psize == -1)
return (ENXIO); /* XXX should be ENODEV ? */
/*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.4 1999/04/27 11:13:16 phk Exp $
* $Id: cons.c,v 1.5 1999/04/27 12:20:52 phk Exp $
*/
#include "opt_devfs.h"
@ -168,7 +168,7 @@ cninit_finish()
/*
* Hook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cn_phys_close = cdp->d_close;
cdp->d_close = cnclose;
cn_phys_open = cdp->d_open;
@ -188,7 +188,7 @@ cnuninit(void)
/*
* Unhook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cdp->d_close = cn_phys_close;
cn_phys_close = NULL;
cdp->d_open = cn_phys_open;
@ -331,7 +331,7 @@ cnread(dev, uio, flag)
if ((cn_tab == NULL) || cn_mute)
return (0);
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_read)(dev, uio, flag));
return ((*devsw(dev)->d_read)(dev, uio, flag));
}
static int
@ -348,7 +348,7 @@ cnwrite(dev, uio, flag)
dev = constty->t_dev;
else
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_write)(dev, uio, flag));
return ((*devsw(dev)->d_write)(dev, uio, flag));
}
static int
@ -375,7 +375,7 @@ cnioctl(dev, cmd, data, flag, p)
return (0);
}
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_ioctl)(dev, cmd, data, flag, p));
return ((*devsw(dev)->d_ioctl)(dev, cmd, data, flag, p));
}
static int
@ -389,7 +389,7 @@ cnpoll(dev, events, p)
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_poll)(dev, events, p));
return ((*devsw(dev)->d_poll)(dev, events, p));
}
int

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.115 1999/05/06 22:16:19 peter Exp $
* $Id: autoconf.c,v 1.116 1999/05/07 10:10:21 phk Exp $
*/
/*
@ -153,7 +153,7 @@ find_cdrom_root()
if (try_cdrom[j].major >= nblkdev)
continue;
rootdev = makedev(try_cdrom[j].major, i * 8);
bd = bdevsw(major(rootdev));
bd = bdevsw(rootdev);
if (bd == NULL || bd->d_open == NULL)
continue;
if (bootverbose)

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_vfsops.c,v 1.10 1998/12/04 22:54:43 archie Exp $
* $Id: coda_vfsops.c,v 1.11 1999/01/17 20:25:17 peter Exp $
*
*/
@ -47,6 +47,9 @@
/*
* HISTORY
* $Log: coda_vfsops.c,v $
* Revision 1.11 1999/01/17 20:25:17 peter
* Clean up the KLD/LKM goop a bit.
*
* Revision 1.10 1998/12/04 22:54:43 archie
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
* for possible buffer overflow problems. Replaced most sprintf()'s
@ -337,7 +340,7 @@ coda_mount(vfsp, path, data, ndp, p)
/*
* See if the device table matches our expectations.
*/
if (cdevsw[major(dev)]->d_open != vc_nb_open)
if (devsw(dev)->d_open != vc_nb_open)
{
MARK_INT_FAIL(CODA_MOUNT_STATS);
return(ENXIO);

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: linux_file.c,v 1.23 1999/01/10 23:15:35 eivind Exp $
* $Id: linux_file.c,v 1.24 1999/05/06 18:44:20 peter Exp $
*/
#include "opt_compat.h"
@ -306,7 +306,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
return error;
d_tty = cdevsw[major(va.va_rdev)]->d_devtotty;
d_tty = devsw(va.va_rdev)->d_devtotty;
if (!d_tty || (!(tp = (*d_tty)(va.va_rdev))))
return EINVAL;
if (args->cmd == LINUX_F_GETOWN) {

View File

@ -71,7 +71,7 @@ snpdevtotty (dev)
maj = major(dev);
if ((u_int)maj >= nchrdev)
return (NULL);
cdp = cdevsw[maj];
cdp = devsw(dev);
if (cdp == NULL)
return (NULL);
return ((*cdp->d_devtotty)(dev));

View File

@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
* $Id: vinumio.c,v 1.23 1999/05/07 01:32:09 grog Exp $
* $Id: vinumio.c,v 1.24 1999/05/07 10:10:04 phk Exp $
*/
#include <dev/vinum/vinumhdr.h>
@ -285,7 +285,7 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag)
bp->b_bcount = len;
bp->b_bufsize = len;
(*bdevsw(major(bp->b_dev))->d_strategy) (bp); /* initiate the transfer */
(*bdevsw(bp->b_dev)->d_strategy) (bp); /* initiate the transfer */
error = biowait(bp);
printf("driveio: %s dev 0x%x, block 0x%x, len 0x%lx, error %d\n", /* XXX */

View File

@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
* $Id: vinumrequest.c,v 1.21 1999/05/07 08:07:09 grog Exp $
* $Id: vinumrequest.c,v 1.22 1999/05/07 10:10:07 phk Exp $
*/
#include <dev/vinum/vinumhdr.h>
@ -390,7 +390,7 @@ launch_requests(struct request *rq, int reviveok)
logrq(loginfo_rqe, (union rqinfou) rqe, rq->bp);
#endif
/* fire off the request */
(*bdevsw(major(rqe->b.b_dev))->d_strategy) (&rqe->b);
(*bdevsw(rqe->b.b_dev)->d_strategy) (&rqe->b);
}
/* XXX Do we need caching? Think about this more */
}
@ -865,7 +865,7 @@ sdio(struct buf *bp)
sbp->b.b_vp->v_numoutput);
#endif
s = splbio();
(*bdevsw(major(sbp->b.b_dev))->d_strategy) (&sbp->b);
(*bdevsw(sbp->b.b_dev)->d_strategy) (&sbp->b);
splx(s);
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
* $Id: cd9660_vfsops.c,v 1.53 1999/04/27 11:15:47 phk Exp $
* $Id: cd9660_vfsops.c,v 1.54 1999/05/07 10:10:46 phk Exp $
*/
#include <sys/param.h>
@ -118,7 +118,7 @@ iso_get_ssector(dev, p)
struct cdevsw *bd;
d_ioctl_t *ioctlp;
bd = bdevsw(major(dev));
bd = bdevsw(dev);
ioctlp = bd->d_ioctl;
if (ioctlp == NULL)
return 0;
@ -189,7 +189,7 @@ cd9660_mount(mp, path, data, ndp, p)
struct iso_mnt *imp = 0;
if ((mp->mnt_flag & MNT_ROOTFS) != 0) {
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
return (iso_mountroot(mp, p));
}
@ -206,7 +206,7 @@ cd9660_mount(mp, path, data, ndp, p)
*/
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOISOFS(mp);
if (bdevsw(major(imp->im_devvp->v_rdev))->d_flags &
if (bdevsw(imp->im_devvp->v_rdev)->d_flags &
D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (args.fspec == 0)
@ -226,7 +226,7 @@ cd9660_mount(mp, path, data, ndp, p)
return ENOTBLK;
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return ENXIO;
}
@ -247,7 +247,7 @@ cd9660_mount(mp, path, data, ndp, p)
VOP_UNLOCK(devvp, 0, p);
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
error = iso_mountfs(devvp, mp, p, &args);
} else {

View File

@ -27,7 +27,7 @@
* Mellon the rights to redistribute these changes without encumbrance.
*
* @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
* $Id: coda_vfsops.c,v 1.10 1998/12/04 22:54:43 archie Exp $
* $Id: coda_vfsops.c,v 1.11 1999/01/17 20:25:17 peter Exp $
*
*/
@ -47,6 +47,9 @@
/*
* HISTORY
* $Log: coda_vfsops.c,v $
* Revision 1.11 1999/01/17 20:25:17 peter
* Clean up the KLD/LKM goop a bit.
*
* Revision 1.10 1998/12/04 22:54:43 archie
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
* for possible buffer overflow problems. Replaced most sprintf()'s
@ -337,7 +340,7 @@ coda_mount(vfsp, path, data, ndp, p)
/*
* See if the device table matches our expectations.
*/
if (cdevsw[major(dev)]->d_open != vc_nb_open)
if (devsw(dev)->d_open != vc_nb_open)
{
MARK_INT_FAIL(CODA_MOUNT_STATS);
return(ENXIO);

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.42 1999/05/06 18:12:50 peter Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.43 1999/05/07 10:11:10 phk Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */
/*-
@ -299,7 +299,7 @@ msdosfs_mount(mp, path, data, ndp, p)
return (ENOTBLK);
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return (ENXIO);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95
* $Id: spec_vnops.c,v 1.83 1999/05/06 20:00:27 phk Exp $
* $Id: spec_vnops.c,v 1.84 1999/05/07 10:11:05 phk Exp $
*/
#include <sys/param.h>
@ -165,6 +165,7 @@ spec_open(ap)
dev_t bdev, dev = (dev_t)vp->v_rdev;
int maj = major(dev);
int error;
struct cdevsw *dsw;
/*
* Don't allow open if fs is mounted -nodev.
@ -177,7 +178,8 @@ spec_open(ap)
case VCHR:
if ((u_int)maj >= nchrdev)
return (ENXIO);
if ( (cdevsw[maj] == NULL) || (cdevsw[maj]->d_open == NULL))
dsw = devsw(dev);
if ( (dsw == NULL) || (dsw->d_open == NULL))
return ENXIO;
if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) {
/*
@ -185,8 +187,8 @@ spec_open(ap)
* opens for writing of any disk character devices.
*/
if (securelevel >= 2
&& cdevsw[maj]->d_bmaj != -1
&& (cdevsw[maj]->d_flags & D_TYPEMASK) == D_DISK)
&& dsw->d_bmaj != -1
&& (dsw->d_flags & D_TYPEMASK) == D_DISK)
return (EPERM);
/*
* When running in secure mode, do not allow opens
@ -204,17 +206,18 @@ spec_open(ap)
return (EPERM);
}
}
if ((cdevsw[maj]->d_flags & D_TYPEMASK) == D_TTY)
if ((dsw->d_flags & D_TYPEMASK) == D_TTY)
vp->v_flag |= VISTTY;
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[maj]->d_open)(dev, ap->a_mode, S_IFCHR, p);
error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
/* NOT REACHED */
case VBLK:
if ((u_int)maj >= nblkdev)
return (ENXIO);
if ( (bdevsw(maj) == NULL) || (bdevsw(maj)->d_open == NULL))
dsw = bdevsw(dev);
if ( (dsw == NULL) || (dsw->d_open == NULL))
return ENXIO;
/*
* When running in very secure mode, do not allow
@ -222,7 +225,7 @@ spec_open(ap)
*/
if (securelevel >= 2 && ap->a_cred != FSCRED &&
(ap->a_mode & FWRITE) &&
(bdevsw(maj)->d_flags & D_TYPEMASK) == D_DISK)
(dsw->d_flags & D_TYPEMASK) == D_DISK)
return (EPERM);
/*
@ -232,7 +235,7 @@ spec_open(ap)
error = vfs_mountedon(vp);
if (error)
return (error);
return ((*bdevsw(maj)->d_open)(dev, ap->a_mode, S_IFBLK, p));
return ((*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p));
/* NOT REACHED */
default:
break;
@ -278,7 +281,7 @@ spec_read(ap)
case VCHR:
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[major(vp->v_rdev)]->d_read)
error = (*devsw(vp->v_rdev)->d_read)
(vp->v_rdev, uio, ap->a_ioflag);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
@ -295,7 +298,7 @@ spec_read(ap)
bsize = vp->v_specinfo->si_bsize_best;
if ((ioctl = bdevsw(major(dev))->d_ioctl) != NULL &&
if ((ioctl = bdevsw(dev)->d_ioctl) != NULL &&
(*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 &&
dpart.part->p_fstype == FS_BSDFFS &&
dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
@ -362,7 +365,7 @@ spec_write(ap)
case VCHR:
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[major(vp->v_rdev)]->d_write)
error = (*devsw(vp->v_rdev)->d_write)
(vp->v_rdev, uio, ap->a_ioflag);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
@ -379,7 +382,7 @@ spec_write(ap)
*/
bsize = vp->v_specinfo->si_bsize_best;
if ((*bdevsw(major(vp->v_rdev))->d_ioctl)(vp->v_rdev, DIOCGPART,
if ((*bdevsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
(caddr_t)&dpart, FREAD, p) == 0) {
if (dpart.part->p_fstype == FS_BSDFFS &&
dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
@ -434,10 +437,10 @@ spec_ioctl(ap)
switch (ap->a_vp->v_type) {
case VCHR:
return ((*cdevsw[major(dev)]->d_ioctl)(dev, ap->a_command,
return ((*devsw(dev)->d_ioctl)(dev, ap->a_command,
ap->a_data, ap->a_fflag, ap->a_p));
case VBLK:
return ((*bdevsw(major(dev))->d_ioctl)(dev, ap->a_command,
return ((*bdevsw(dev)->d_ioctl)(dev, ap->a_command,
ap->a_data, ap->a_fflag, ap->a_p));
default:
panic("spec_ioctl");
@ -461,7 +464,7 @@ spec_poll(ap)
case VCHR:
dev = ap->a_vp->v_rdev;
return (*cdevsw[major(dev)]->d_poll)(dev, ap->a_events, ap->a_p);
return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_p);
default:
return (vop_defaultop((struct vop_generic_args *)ap));
@ -553,7 +556,7 @@ spec_strategy(ap)
if (((bp->b_flags & B_READ) == 0) &&
(LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
(*bioops.io_start)(bp);
(*bdevsw(major(bp->b_dev))->d_strategy)(bp);
(*bdevsw(bp->b_dev)->d_strategy)(bp);
return (0);
}
@ -568,7 +571,7 @@ spec_freeblks(ap)
struct cdevsw *bsw;
struct buf *bp;
bsw = bdevsw(major(ap->a_vp->v_rdev));
bsw = bdevsw(ap->a_vp->v_rdev);
if ((bsw->d_flags & D_CANFREE) == 0)
return (0);
bp = geteblk(ap->a_length);
@ -650,7 +653,7 @@ spec_close(ap)
*/
if (vcount(vp) > 1 && (vp->v_flag & VXLOCK) == 0)
return (0);
devclose = cdevsw[major(dev)]->d_close;
devclose = devsw(dev)->d_close;
mode = S_IFCHR;
break;
@ -678,7 +681,7 @@ spec_close(ap)
if ((vcount(vp) > 1) && (vp->v_flag & VXLOCK) == 0)
return (0);
devclose = bdevsw(major(dev))->d_close;
devclose = bdevsw(dev)->d_close;
mode = S_IFBLK;
break;
@ -956,7 +959,7 @@ spec_getattr(ap)
vap->va_blocksize = MAXBSIZE;
}
if ((*bdevsw(major(vp->v_rdev))->d_ioctl)(vp->v_rdev, DIOCGPART,
if ((*bdevsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
(caddr_t)&dpart, FREAD, ap->a_p) == 0) {
vap->va_bytes = dbtob(dpart.disklab->d_partitions
[minor(vp->v_rdev)].p_size);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95
* $Id: ufs_bmap.c,v 1.26 1999/05/02 23:57:04 alc Exp $
* $Id: ufs_bmap.c,v 1.27 1999/05/07 10:11:36 phk Exp $
*/
#include <sys/param.h>
@ -151,12 +151,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
if (devvp != NULL && devvp->v_tag != VT_MFS &&
devvp->v_type == VBLK) {
if (bdevsw(major(devvp->v_rdev))->d_maxio > MAXPHYS) {
if (bdevsw(devvp->v_rdev)->d_maxio > MAXPHYS) {
maxrun = MAXPHYS;
vp->v_maxio = MAXPHYS;
} else {
maxrun = bdevsw(major(devvp->v_rdev))->d_maxio;
vp->v_maxio = bdevsw(major(devvp->v_rdev))->d_maxio;
maxrun = bdevsw(devvp->v_rdev)->d_maxio;
vp->v_maxio = bdevsw(devvp->v_rdev)->d_maxio;
}
maxrun = maxrun / blksize;
maxrun -= 1;

View File

@ -136,9 +136,9 @@ ext2_mountroot()
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = &ext2fs_vfsops;
mp->mnt_flag = MNT_RDONLY;
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if (error = ext2_mountfs(rootvp, mp, p)) {
bsd_free(mp, M_MOUNT);
@ -201,9 +201,9 @@ ext2_mount(mp, path, data, ndp, p)
ump = VFSTOUFS(mp);
fs = ump->um_e2fs;
error = 0;
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERR)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERW)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) {
flags = WRITECLOSE;
@ -277,7 +277,7 @@ ext2_mount(mp, path, data, ndp, p)
return (ENOTBLK);
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return (ENXIO);
}
@ -299,9 +299,9 @@ ext2_mount(mp, path, data, ndp, p)
}
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
error = ext2_mountfs(devvp, mp, p);
} else {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95
* $Id: ufs_bmap.c,v 1.26 1999/05/02 23:57:04 alc Exp $
* $Id: ufs_bmap.c,v 1.27 1999/05/07 10:11:36 phk Exp $
*/
#include <sys/param.h>
@ -151,12 +151,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
if (devvp != NULL && devvp->v_tag != VT_MFS &&
devvp->v_type == VBLK) {
if (bdevsw(major(devvp->v_rdev))->d_maxio > MAXPHYS) {
if (bdevsw(devvp->v_rdev)->d_maxio > MAXPHYS) {
maxrun = MAXPHYS;
vp->v_maxio = MAXPHYS;
} else {
maxrun = bdevsw(major(devvp->v_rdev))->d_maxio;
vp->v_maxio = bdevsw(major(devvp->v_rdev))->d_maxio;
maxrun = bdevsw(devvp->v_rdev)->d_maxio;
vp->v_maxio = bdevsw(devvp->v_rdev)->d_maxio;
}
maxrun = maxrun / blksize;
maxrun -= 1;

View File

@ -136,9 +136,9 @@ ext2_mountroot()
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = &ext2fs_vfsops;
mp->mnt_flag = MNT_RDONLY;
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if (error = ext2_mountfs(rootvp, mp, p)) {
bsd_free(mp, M_MOUNT);
@ -201,9 +201,9 @@ ext2_mount(mp, path, data, ndp, p)
ump = VFSTOUFS(mp);
fs = ump->um_e2fs;
error = 0;
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERR)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERW)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) {
flags = WRITECLOSE;
@ -277,7 +277,7 @@ ext2_mount(mp, path, data, ndp, p)
return (ENOTBLK);
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return (ENXIO);
}
@ -299,9 +299,9 @@ ext2_mount(mp, path, data, ndp, p)
}
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
error = ext2_mountfs(devvp, mp, p);
} else {

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.115 1999/05/06 22:16:19 peter Exp $
* $Id: autoconf.c,v 1.116 1999/05/07 10:10:21 phk Exp $
*/
/*
@ -153,7 +153,7 @@ find_cdrom_root()
if (try_cdrom[j].major >= nblkdev)
continue;
rootdev = makedev(try_cdrom[j].major, i * 8);
bd = bdevsw(major(rootdev));
bd = bdevsw(rootdev);
if (bd == NULL || bd->d_open == NULL)
continue;
if (bootverbose)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.63 1999/04/27 12:21:03 phk Exp $
* $Id: cons.c,v 1.64 1999/04/28 10:52:04 dt Exp $
*/
#include "opt_devfs.h"
@ -158,7 +158,7 @@ cninit_finish()
/*
* Hook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cn_phys_close = cdp->d_close;
cdp->d_close = cnclose;
cn_phys_open = cdp->d_open;
@ -178,7 +178,7 @@ cnuninit(void)
/*
* Unhook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cdp->d_close = cn_phys_close;
cn_phys_close = NULL;
cdp->d_open = cn_phys_open;
@ -321,7 +321,7 @@ cnread(dev, uio, flag)
if ((cn_tab == NULL) || cn_mute)
return (0);
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_read)(dev, uio, flag));
return ((*devsw(dev)->d_read)(dev, uio, flag));
}
static int
@ -338,7 +338,7 @@ cnwrite(dev, uio, flag)
dev = constty->t_dev;
else
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_write)(dev, uio, flag));
return ((*devsw(dev)->d_write)(dev, uio, flag));
}
static int
@ -365,7 +365,7 @@ cnioctl(dev, cmd, data, flag, p)
return (0);
}
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_ioctl)(dev, cmd, data, flag, p));
return ((*devsw(dev)->d_ioctl)(dev, cmd, data, flag, p));
}
static int
@ -379,7 +379,7 @@ cnpoll(dev, events, p)
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_poll)(dev, events, p));
return ((*devsw(dev)->d_poll)(dev, events, p));
}
int

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: linux_file.c,v 1.23 1999/01/10 23:15:35 eivind Exp $
* $Id: linux_file.c,v 1.24 1999/05/06 18:44:20 peter Exp $
*/
#include "opt_compat.h"
@ -306,7 +306,7 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
return error;
d_tty = cdevsw[major(va.va_rdev)]->d_devtotty;
d_tty = devsw(va.va_rdev)->d_devtotty;
if (!d_tty || (!(tp = (*d_tty)(va.va_rdev))))
return EINVAL;
if (args->cmd == LINUX_F_GETOWN) {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
* $Id: cd9660_vfsops.c,v 1.53 1999/04/27 11:15:47 phk Exp $
* $Id: cd9660_vfsops.c,v 1.54 1999/05/07 10:10:46 phk Exp $
*/
#include <sys/param.h>
@ -118,7 +118,7 @@ iso_get_ssector(dev, p)
struct cdevsw *bd;
d_ioctl_t *ioctlp;
bd = bdevsw(major(dev));
bd = bdevsw(dev);
ioctlp = bd->d_ioctl;
if (ioctlp == NULL)
return 0;
@ -189,7 +189,7 @@ cd9660_mount(mp, path, data, ndp, p)
struct iso_mnt *imp = 0;
if ((mp->mnt_flag & MNT_ROOTFS) != 0) {
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
return (iso_mountroot(mp, p));
}
@ -206,7 +206,7 @@ cd9660_mount(mp, path, data, ndp, p)
*/
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOISOFS(mp);
if (bdevsw(major(imp->im_devvp->v_rdev))->d_flags &
if (bdevsw(imp->im_devvp->v_rdev)->d_flags &
D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (args.fspec == 0)
@ -226,7 +226,7 @@ cd9660_mount(mp, path, data, ndp, p)
return ENOTBLK;
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return ENXIO;
}
@ -247,7 +247,7 @@ cd9660_mount(mp, path, data, ndp, p)
VOP_UNLOCK(devvp, 0, p);
if ((mp->mnt_flag & MNT_UPDATE) == 0) {
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
error = iso_mountfs(devvp, mp, p, &args);
} else {

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_conf.c,v 1.31 1999/03/23 21:11:47 dfr Exp $
* $Id: kern_conf.c,v 1.32 1999/05/07 10:10:50 phk Exp $
*/
#include <sys/param.h>
@ -58,7 +58,7 @@ chrtoblk(dev_t dev)
{
struct cdevsw *cd;
if((cd = cdevsw[major(dev)]) != NULL) {
if((cd = devsw(dev)) != NULL) {
if (cd->d_bmaj != -1)
return(makedev(cd->d_bmaj,minor(dev)));
}

View File

@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
* $Id: kern_physio.c,v 1.32 1999/05/06 20:00:25 phk Exp $
* $Id: kern_physio.c,v 1.33 1999/05/07 07:03:39 phk Exp $
*/
#include <sys/param.h>
@ -35,13 +35,13 @@ static struct buf * phygetvpbuf(dev_t dev, int resid);
int
physread(dev_t dev, struct uio *uio, int ioflag)
{
return(physio(cdevsw[major(dev)]->d_strategy, NULL, dev, 1, minphys, uio));
return(physio(devsw(dev)->d_strategy, NULL, dev, 1, minphys, uio));
}
int
physwrite(dev_t dev, struct uio *uio, int ioflag)
{
return(physio(cdevsw[major(dev)]->d_strategy, NULL, dev, 0, minphys, uio));
return(physio(devsw(dev)->d_strategy, NULL, dev, 0, minphys, uio));
}
int
@ -181,7 +181,7 @@ minphys(bp)
u_int maxphys = DFLTPHYS;
struct cdevsw *bdsw;
bdsw = cdevsw[major(bp->b_dev)];
bdsw = devsw(bp->b_dev);
if (bdsw && bdsw->d_maxio) {
maxphys = bdsw->d_maxio;
@ -206,7 +206,7 @@ phygetvpbuf(dev_t dev, int resid)
struct cdevsw *bdsw;
int maxio;
bdsw = cdevsw[major(dev)];
bdsw = devsw(dev);
if ((bdsw == NULL) || (bdsw->d_bmaj == -1))
return getpbuf(NULL);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
* $Id: kern_shutdown.c,v 1.49 1999/05/06 18:12:44 peter Exp $
* $Id: kern_shutdown.c,v 1.50 1999/05/07 10:10:53 phk Exp $
*/
#include "opt_ddb.h"
@ -377,14 +377,14 @@ dumpsys(void)
return;
if (dumpdev == NODEV)
return;
if (!(bdevsw(major(dumpdev))))
if (!(bdevsw(dumpdev)))
return;
if (!(bdevsw(major(dumpdev))->d_dump))
if (!(bdevsw(dumpdev)->d_dump))
return;
dumpsize = Maxmem;
printf("\ndumping to dev %lx, offset %ld\n", (u_long)dumpdev, dumplo);
printf("dump ");
switch ((*bdevsw(major(dumpdev))->d_dump)(dumpdev)) {
switch ((*bdevsw(dumpdev)->d_dump)(dumpdev)) {
case ENXIO:
printf("device bad\n");

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.116 1999/04/27 11:16:17 phk Exp $
* $Id: tty.c,v 1.117 1999/05/06 18:12:47 peter Exp $
*/
/*-
@ -419,7 +419,7 @@ ttyinput(c, tp)
#ifdef sun4c /* XXX */
(*tp->t_stop)(tp, 0);
#else
(*cdevsw[major(tp->t_dev)]->d_stop)(tp,
(*devsw(tp->t_dev)->d_stop)(tp,
0);
#endif
return (0);
@ -996,7 +996,7 @@ ttioctl(tp, cmd, data, flag)
#ifdef sun4c /* XXX */
(*tp->t_stop)(tp, 0);
#else
(*cdevsw[major(tp->t_dev)]->d_stop)(tp, 0);
(*devsw(tp->t_dev)->d_stop)(tp, 0);
#endif
}
splx(s);
@ -1097,7 +1097,7 @@ ttpoll(dev, events, p)
int events;
struct proc *p;
{
return ttypoll((*cdevsw[major(dev)]->d_devtotty)(dev), events, p);
return ttypoll((*devsw(dev)->d_devtotty)(dev), events, p);
}
/*
@ -1189,7 +1189,7 @@ ttyflush(tp, rw)
#ifdef sun4c /* XXX */
(*tp->t_stop)(tp, rw);
#else
(*cdevsw[major(tp->t_dev)]->d_stop)(tp, rw);
(*devsw(tp->t_dev)->d_stop)(tp, rw);
#endif
if (rw & FREAD) {
FLUSHQ(&tp->t_canq);
@ -1374,7 +1374,7 @@ ttymodem(tp, flag)
#ifdef sun4c /* XXX */
(*tp->t_stop)(tp, 0);
#else
(*cdevsw[major(tp->t_dev)]->d_stop)(tp, 0);
(*devsw(tp->t_dev)->d_stop)(tp, 0);
#endif
}
} else if (flag == 0) {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.63 1999/04/27 12:21:03 phk Exp $
* $Id: cons.c,v 1.64 1999/04/28 10:52:04 dt Exp $
*/
#include "opt_devfs.h"
@ -158,7 +158,7 @@ cninit_finish()
/*
* Hook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cn_phys_close = cdp->d_close;
cdp->d_close = cnclose;
cn_phys_open = cdp->d_open;
@ -178,7 +178,7 @@ cnuninit(void)
/*
* Unhook the open and close functions.
*/
cdp = cdevsw[major(cn_tab->cn_dev)];
cdp = devsw(cn_tab->cn_dev);
cdp->d_close = cn_phys_close;
cn_phys_close = NULL;
cdp->d_open = cn_phys_open;
@ -321,7 +321,7 @@ cnread(dev, uio, flag)
if ((cn_tab == NULL) || cn_mute)
return (0);
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_read)(dev, uio, flag));
return ((*devsw(dev)->d_read)(dev, uio, flag));
}
static int
@ -338,7 +338,7 @@ cnwrite(dev, uio, flag)
dev = constty->t_dev;
else
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_write)(dev, uio, flag));
return ((*devsw(dev)->d_write)(dev, uio, flag));
}
static int
@ -365,7 +365,7 @@ cnioctl(dev, cmd, data, flag, p)
return (0);
}
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_ioctl)(dev, cmd, data, flag, p));
return ((*devsw(dev)->d_ioctl)(dev, cmd, data, flag, p));
}
static int
@ -379,7 +379,7 @@ cnpoll(dev, events, p)
dev = cn_tab->cn_dev;
return ((*cdevsw[major(dev)]->d_poll)(dev, events, p));
return ((*devsw(dev)->d_poll)(dev, events, p));
}
int

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
* $Id: tty_pty.c,v 1.55 1999/01/30 12:17:37 phk Exp $
* $Id: tty_pty.c,v 1.56 1999/04/27 11:16:19 phk Exp $
*/
/*
@ -675,7 +675,7 @@ ptyioctl(dev, cmd, data, flag, p)
}
return(0);
} else
if (cdevsw[major(dev)]->d_open == ptcopen)
if (devsw(dev)->d_open == ptcopen)
switch (cmd) {
case TIOCGPGRP:

View File

@ -71,7 +71,7 @@ snpdevtotty (dev)
maj = major(dev);
if ((u_int)maj >= nchrdev)
return (NULL);
cdp = cdevsw[maj];
cdp = devsw(dev);
if (cdp == NULL)
return (NULL);
return ((*cdp->d_devtotty)(dev));

View File

@ -13,7 +13,7 @@
* bad that happens because of using this software isn't the responsibility
* of the author. This software is distributed AS-IS.
*
* $Id: vfs_aio.c,v 1.47 1999/05/06 18:44:42 peter Exp $
* $Id: vfs_aio.c,v 1.48 1999/05/06 20:00:25 phk Exp $
*/
/*
@ -963,7 +963,7 @@ aio_qphysio(p, aiocbe)
return -1;
}
cdev = cdevsw[major(vp->v_rdev)];
cdev = devsw(vp->v_rdev);
if (cdev == NULL) {
return -1;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.190 1999/05/03 23:57:24 billf Exp $
* $Id: vfs_subr.c,v 1.191 1999/05/07 10:10:58 phk Exp $
*/
/*
@ -1177,7 +1177,7 @@ bdevvp(dev, vpp)
/* XXX 255 is for mfs. */
if (dev == NODEV || (major(dev) != 255 && (major(dev) >= nblkdev ||
bdevsw(major(dev)) == NULL))) {
bdevsw(dev) == NULL))) {
*vpp = NULLVP;
return (ENXIO);
}
@ -1275,12 +1275,12 @@ checkalias(nvp, nvp_rdev, mp)
*/
if (nvp->v_type == VBLK && rmaj < nblkdev) {
if (bdevsw(rmaj) && bdevsw(rmaj)->d_parms)
if (bdevsw(nvp_rdev) && bdevsw(nvp_rdev)->d_parms)
(*bdevsw(rmaj)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
(*bdevsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
} else if (nvp->v_type == VCHR && rmaj < nchrdev) {
if (cdevsw[rmaj] && cdevsw[rmaj]->d_parms)
(*cdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET);
if (devsw(nvp_rdev) && devsw(nvp_rdev)->d_parms)
(*devsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
}
simple_unlock(&spechash_slock);
@ -2585,7 +2585,7 @@ vfs_object_create(vp, p, cred)
goto retn;
object = vnode_pager_alloc(vp, vat.va_size, 0, 0);
} else if (major(vp->v_rdev) < nblkdev &&
bdevsw(major(vp->v_rdev)) != NULL) {
bdevsw(vp->v_rdev) != NULL) {
/*
* This simply allocates the biggest object possible
* for a VBLK vnode. This should be fixed, but doesn't

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.190 1999/05/03 23:57:24 billf Exp $
* $Id: vfs_subr.c,v 1.191 1999/05/07 10:10:58 phk Exp $
*/
/*
@ -1177,7 +1177,7 @@ bdevvp(dev, vpp)
/* XXX 255 is for mfs. */
if (dev == NODEV || (major(dev) != 255 && (major(dev) >= nblkdev ||
bdevsw(major(dev)) == NULL))) {
bdevsw(dev) == NULL))) {
*vpp = NULLVP;
return (ENXIO);
}
@ -1275,12 +1275,12 @@ checkalias(nvp, nvp_rdev, mp)
*/
if (nvp->v_type == VBLK && rmaj < nblkdev) {
if (bdevsw(rmaj) && bdevsw(rmaj)->d_parms)
if (bdevsw(nvp_rdev) && bdevsw(nvp_rdev)->d_parms)
(*bdevsw(rmaj)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
(*bdevsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
} else if (nvp->v_type == VCHR && rmaj < nchrdev) {
if (cdevsw[rmaj] && cdevsw[rmaj]->d_parms)
(*cdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET);
if (devsw(nvp_rdev) && devsw(nvp_rdev)->d_parms)
(*devsw(nvp_rdev)->d_parms)(nvp_rdev, sinfo, DPARM_GET);
}
simple_unlock(&spechash_slock);
@ -2585,7 +2585,7 @@ vfs_object_create(vp, p, cred)
goto retn;
object = vnode_pager_alloc(vp, vat.va_size, 0, 0);
} else if (major(vp->v_rdev) < nblkdev &&
bdevsw(major(vp->v_rdev)) != NULL) {
bdevsw(vp->v_rdev) != NULL) {
/*
* This simply allocates the biggest object possible
* for a VBLK vnode. This should be fixed, but doesn't

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)kernfs_vfsops.c 8.10 (Berkeley) 5/14/95
* $Id: kernfs_vfsops.c,v 1.24 1998/12/07 21:58:31 archie Exp $
* $Id: kernfs_vfsops.c,v 1.25 1999/05/07 10:11:02 phk Exp $
*/
/*
@ -88,7 +88,7 @@ kernfs_get_rrootdev()
}
tried = 1;
if (!bdevsw(bmaj)) {
if (!bdevsw(rootdev)) {
panic("root dev has no bdevsw");
}
if (rootdev == NODEV)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95
* $Id: spec_vnops.c,v 1.83 1999/05/06 20:00:27 phk Exp $
* $Id: spec_vnops.c,v 1.84 1999/05/07 10:11:05 phk Exp $
*/
#include <sys/param.h>
@ -165,6 +165,7 @@ spec_open(ap)
dev_t bdev, dev = (dev_t)vp->v_rdev;
int maj = major(dev);
int error;
struct cdevsw *dsw;
/*
* Don't allow open if fs is mounted -nodev.
@ -177,7 +178,8 @@ spec_open(ap)
case VCHR:
if ((u_int)maj >= nchrdev)
return (ENXIO);
if ( (cdevsw[maj] == NULL) || (cdevsw[maj]->d_open == NULL))
dsw = devsw(dev);
if ( (dsw == NULL) || (dsw->d_open == NULL))
return ENXIO;
if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) {
/*
@ -185,8 +187,8 @@ spec_open(ap)
* opens for writing of any disk character devices.
*/
if (securelevel >= 2
&& cdevsw[maj]->d_bmaj != -1
&& (cdevsw[maj]->d_flags & D_TYPEMASK) == D_DISK)
&& dsw->d_bmaj != -1
&& (dsw->d_flags & D_TYPEMASK) == D_DISK)
return (EPERM);
/*
* When running in secure mode, do not allow opens
@ -204,17 +206,18 @@ spec_open(ap)
return (EPERM);
}
}
if ((cdevsw[maj]->d_flags & D_TYPEMASK) == D_TTY)
if ((dsw->d_flags & D_TYPEMASK) == D_TTY)
vp->v_flag |= VISTTY;
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[maj]->d_open)(dev, ap->a_mode, S_IFCHR, p);
error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
/* NOT REACHED */
case VBLK:
if ((u_int)maj >= nblkdev)
return (ENXIO);
if ( (bdevsw(maj) == NULL) || (bdevsw(maj)->d_open == NULL))
dsw = bdevsw(dev);
if ( (dsw == NULL) || (dsw->d_open == NULL))
return ENXIO;
/*
* When running in very secure mode, do not allow
@ -222,7 +225,7 @@ spec_open(ap)
*/
if (securelevel >= 2 && ap->a_cred != FSCRED &&
(ap->a_mode & FWRITE) &&
(bdevsw(maj)->d_flags & D_TYPEMASK) == D_DISK)
(dsw->d_flags & D_TYPEMASK) == D_DISK)
return (EPERM);
/*
@ -232,7 +235,7 @@ spec_open(ap)
error = vfs_mountedon(vp);
if (error)
return (error);
return ((*bdevsw(maj)->d_open)(dev, ap->a_mode, S_IFBLK, p));
return ((*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p));
/* NOT REACHED */
default:
break;
@ -278,7 +281,7 @@ spec_read(ap)
case VCHR:
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[major(vp->v_rdev)]->d_read)
error = (*devsw(vp->v_rdev)->d_read)
(vp->v_rdev, uio, ap->a_ioflag);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
@ -295,7 +298,7 @@ spec_read(ap)
bsize = vp->v_specinfo->si_bsize_best;
if ((ioctl = bdevsw(major(dev))->d_ioctl) != NULL &&
if ((ioctl = bdevsw(dev)->d_ioctl) != NULL &&
(*ioctl)(dev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0 &&
dpart.part->p_fstype == FS_BSDFFS &&
dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
@ -362,7 +365,7 @@ spec_write(ap)
case VCHR:
VOP_UNLOCK(vp, 0, p);
error = (*cdevsw[major(vp->v_rdev)]->d_write)
error = (*devsw(vp->v_rdev)->d_write)
(vp->v_rdev, uio, ap->a_ioflag);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
return (error);
@ -379,7 +382,7 @@ spec_write(ap)
*/
bsize = vp->v_specinfo->si_bsize_best;
if ((*bdevsw(major(vp->v_rdev))->d_ioctl)(vp->v_rdev, DIOCGPART,
if ((*bdevsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
(caddr_t)&dpart, FREAD, p) == 0) {
if (dpart.part->p_fstype == FS_BSDFFS &&
dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
@ -434,10 +437,10 @@ spec_ioctl(ap)
switch (ap->a_vp->v_type) {
case VCHR:
return ((*cdevsw[major(dev)]->d_ioctl)(dev, ap->a_command,
return ((*devsw(dev)->d_ioctl)(dev, ap->a_command,
ap->a_data, ap->a_fflag, ap->a_p));
case VBLK:
return ((*bdevsw(major(dev))->d_ioctl)(dev, ap->a_command,
return ((*bdevsw(dev)->d_ioctl)(dev, ap->a_command,
ap->a_data, ap->a_fflag, ap->a_p));
default:
panic("spec_ioctl");
@ -461,7 +464,7 @@ spec_poll(ap)
case VCHR:
dev = ap->a_vp->v_rdev;
return (*cdevsw[major(dev)]->d_poll)(dev, ap->a_events, ap->a_p);
return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_p);
default:
return (vop_defaultop((struct vop_generic_args *)ap));
@ -553,7 +556,7 @@ spec_strategy(ap)
if (((bp->b_flags & B_READ) == 0) &&
(LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
(*bioops.io_start)(bp);
(*bdevsw(major(bp->b_dev))->d_strategy)(bp);
(*bdevsw(bp->b_dev)->d_strategy)(bp);
return (0);
}
@ -568,7 +571,7 @@ spec_freeblks(ap)
struct cdevsw *bsw;
struct buf *bp;
bsw = bdevsw(major(ap->a_vp->v_rdev));
bsw = bdevsw(ap->a_vp->v_rdev);
if ((bsw->d_flags & D_CANFREE) == 0)
return (0);
bp = geteblk(ap->a_length);
@ -650,7 +653,7 @@ spec_close(ap)
*/
if (vcount(vp) > 1 && (vp->v_flag & VXLOCK) == 0)
return (0);
devclose = cdevsw[major(dev)]->d_close;
devclose = devsw(dev)->d_close;
mode = S_IFCHR;
break;
@ -678,7 +681,7 @@ spec_close(ap)
if ((vcount(vp) > 1) && (vp->v_flag & VXLOCK) == 0)
return (0);
devclose = bdevsw(major(dev))->d_close;
devclose = bdevsw(dev)->d_close;
mode = S_IFBLK;
break;
@ -956,7 +959,7 @@ spec_getattr(ap)
vap->va_blocksize = MAXBSIZE;
}
if ((*bdevsw(major(vp->v_rdev))->d_ioctl)(vp->v_rdev, DIOCGPART,
if ((*bdevsw(vp->v_rdev)->d_ioctl)(vp->v_rdev, DIOCGPART,
(caddr_t)&dpart, FREAD, ap->a_p) == 0) {
vap->va_bytes = dbtob(dpart.disklab->d_partitions
[minor(vp->v_rdev)].p_size);

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.42 1999/05/06 18:12:50 peter Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.43 1999/05/07 10:11:10 phk Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */
/*-
@ -299,7 +299,7 @@ msdosfs_mount(mp, path, data, ndp, p)
return (ENOTBLK);
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
vrele(devvp);
return (ENXIO);
}

View File

@ -70,7 +70,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
/* $Id: ppp_tty.c,v 1.38 1999/01/17 20:53:47 peter Exp $ */
/* $Id: ppp_tty.c,v 1.39 1999/04/27 11:17:07 phk Exp $ */
#include "ppp.h"
#if NPPP > 0
@ -896,7 +896,7 @@ pppinput(c, tp)
if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
if ((tp->t_state & TS_TTSTOP) == 0) {
tp->t_state |= TS_TTSTOP;
(*cdevsw[major(tp->t_dev)]->d_stop)(tp, 0);
(*devsw(tp->t_dev)->d_stop)(tp, 0);
}
return 0;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.50 1999/02/25 05:22:28 dillon Exp $
* $Id: conf.h,v 1.51 1999/05/07 10:11:23 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -133,9 +133,16 @@ extern int bmaj2cmaj[];
static __inline
struct cdevsw *
bdevsw(int maj)
devsw(dev_t dev)
{
struct cdevsw *c = cdevsw[bmaj2cmaj[maj]];
return(cdevsw[major(dev)]);
}
static __inline
struct cdevsw *
bdevsw(dev_t dev)
{
struct cdevsw *c = cdevsw[bmaj2cmaj[major(dev)]];
/* CMAJ zero is the console, which has no strategy so this works */
if (c->d_strategy)
return (c);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)conf.h 8.5 (Berkeley) 1/9/95
* $Id: conf.h,v 1.50 1999/02/25 05:22:28 dillon Exp $
* $Id: conf.h,v 1.51 1999/05/07 10:11:23 phk Exp $
*/
#ifndef _SYS_CONF_H_
@ -133,9 +133,16 @@ extern int bmaj2cmaj[];
static __inline
struct cdevsw *
bdevsw(int maj)
devsw(dev_t dev)
{
struct cdevsw *c = cdevsw[bmaj2cmaj[maj]];
return(cdevsw[major(dev)]);
}
static __inline
struct cdevsw *
bdevsw(dev_t dev)
{
struct cdevsw *c = cdevsw[bmaj2cmaj[major(dev)]];
/* CMAJ zero is the console, which has no strategy so this works */
if (c->d_strategy)
return (c);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95
* $Id: ffs_vfsops.c,v 1.96 1999/01/28 00:57:54 dillon Exp $
* $Id: ffs_vfsops.c,v 1.97 1999/05/07 10:11:33 phk Exp $
*/
#include "opt_quota.h"
@ -158,9 +158,9 @@ ffs_mount( mp, path, data, ndp, p)
return (err);
}
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(rootdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(rootdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if( ( err = ffs_mountfs(rootvp, mp, p, M_FFSNODE)) != 0) {
/* fs specific cleanup (if any)*/
@ -194,9 +194,9 @@ ffs_mount( mp, path, data, ndp, p)
devvp = ump->um_devvp;
err = 0;
ronly = fs->fs_ronly; /* MNT_RELOAD might change this */
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERR)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(ump->um_dev))->d_flags & D_NOCLUSTERW)
if (bdevsw(ump->um_dev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
if (ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
flags = WRITECLOSE;
@ -291,7 +291,7 @@ ffs_mount( mp, path, data, ndp, p)
goto error_2;
}
if (major(devvp->v_rdev) >= nblkdev ||
bdevsw(major(devvp->v_rdev)) == NULL) {
bdevsw(devvp->v_rdev) == NULL) {
err = ENXIO;
goto error_2;
}
@ -347,9 +347,9 @@ ffs_mount( mp, path, data, ndp, p)
********************
*/
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERR)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERR)
mp->mnt_flag |= MNT_NOCLUSTERR;
if (bdevsw(major(devvp->v_rdev))->d_flags & D_NOCLUSTERW)
if (bdevsw(devvp->v_rdev)->d_flags & D_NOCLUSTERW)
mp->mnt_flag |= MNT_NOCLUSTERW;
/*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95
* $Id: ufs_bmap.c,v 1.26 1999/05/02 23:57:04 alc Exp $
* $Id: ufs_bmap.c,v 1.27 1999/05/07 10:11:36 phk Exp $
*/
#include <sys/param.h>
@ -151,12 +151,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
if (devvp != NULL && devvp->v_tag != VT_MFS &&
devvp->v_type == VBLK) {
if (bdevsw(major(devvp->v_rdev))->d_maxio > MAXPHYS) {
if (bdevsw(devvp->v_rdev)->d_maxio > MAXPHYS) {
maxrun = MAXPHYS;
vp->v_maxio = MAXPHYS;
} else {
maxrun = bdevsw(major(devvp->v_rdev))->d_maxio;
vp->v_maxio = bdevsw(major(devvp->v_rdev))->d_maxio;
maxrun = bdevsw(devvp->v_rdev)->d_maxio;
vp->v_maxio = bdevsw(devvp->v_rdev)->d_maxio;
}
maxrun = maxrun / blksize;
maxrun -= 1;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)device_pager.c 8.1 (Berkeley) 6/11/93
* $Id: device_pager.c,v 1.38 1999/01/21 08:29:09 dillon Exp $
* $Id: device_pager.c,v 1.39 1999/01/24 02:32:14 dillon Exp $
*/
#include <sys/param.h>
@ -104,7 +104,7 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo
* Make sure this device can be mapped.
*/
dev = (dev_t) (uintptr_t) handle;
mapfunc = cdevsw[major(dev)]->d_mmap;
mapfunc = devsw(dev)->d_mmap;
if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop) {
printf("obsolete map function %p\n", (void *)mapfunc);
return (NULL);
@ -202,7 +202,7 @@ dev_pager_getpages(object, m, count, reqpage)
dev = (dev_t) (uintptr_t) object->handle;
offset = m[reqpage]->pindex;
prot = PROT_READ; /* XXX should pass in? */
mapfunc = cdevsw[major(dev)]->d_mmap;
mapfunc = devsw(dev)->d_mmap;
if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop)
panic("dev_pager_getpage: no map function");

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
* $Id: vm_swap.c,v 1.64 1999/05/07 07:03:47 phk Exp $
* $Id: vm_swap.c,v 1.65 1999/05/07 10:11:40 phk Exp $
*/
#include "opt_devfs.h"
@ -209,7 +209,7 @@ swapon(p, uap)
switch (vp->v_type) {
case VBLK:
dev = vp->v_rdev;
if (major(dev) >= nblkdev || bdevsw(major(dev)) == NULL) {
if (major(dev) >= nblkdev || bdevsw(dev) == NULL) {
error = ENXIO;
break;
}
@ -281,8 +281,8 @@ swaponvp(p, vp, dev, nblks)
if (error)
return (error);
if (nblks == 0 && dev != NODEV && (bdevsw(major(dev))->d_psize == 0 ||
(nblks = (*bdevsw(major(dev))->d_psize) (dev)) == -1)) {
if (nblks == 0 && dev != NODEV && (bdevsw(dev)->d_psize == 0 ||
(nblks = (*bdevsw(dev)->d_psize) (dev)) == -1)) {
(void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p);
return (ENXIO);
}