diff options
author | phk <phk@FreeBSD.org> | 2004-12-01 23:16:38 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-12-01 23:16:38 +0000 |
commit | 59f305606cbc120b44978581149ef1a3e62bf3b4 (patch) | |
tree | f548d86b8998e8d581602fc54079bbb1534e7c18 /sys/gnu | |
parent | 350be3accf1712e54ae2732ca42ad409bbf20df7 (diff) | |
download | FreeBSD-src-59f305606cbc120b44978581149ef1a3e62bf3b4.zip FreeBSD-src-59f305606cbc120b44978581149ef1a3e62bf3b4.tar.gz |
Back when VOP_* was introduced, we did not have new-style struct
initializations but we did have lofty goals and big ideals.
Adjust to more contemporary circumstances and gain type checking.
Replace the entire vop_t frobbing thing with properly typed
structures. The only casualty is that we can not add a new
VOP_ method with a loadable module. History has not given
us reason to belive this would ever be feasible in the the
first place.
Eliminate in toto VOCALL(), vop_t, VNODEOP_SET() etc.
Give coda correct prototypes and function definitions for
all vop_()s.
Generate a bit more data from the vnode_if.src file: a
struct vop_vector and protype typedefs for all vop methods.
Add a new vop_bypass() and make vop_default be a pointer
to another struct vop_vector.
Remove a lot of vfs_init since vop_vector is ready to use
from the compiler.
Cast various vop_mumble() to void * with uppercase name,
for instance VOP_PANIC, VOP_NULL etc.
Implement VCALL() by making vdesc_offset the offsetof() the
relevant function pointer in vop_vector. This is disgusting
but since the code is generated by a script comparatively
safe. The alternative for nullfs etc. would be much worse.
Fix up all vnode method vectors to remove casts so they
become typesafe. (The bulk of this is generated by scripts)
Diffstat (limited to 'sys/gnu')
-rw-r--r-- | sys/gnu/ext2fs/ext2_extern.h | 6 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 4 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vnops.c | 113 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_extern.h | 6 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 4 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vnops.c | 113 |
6 files changed, 112 insertions, 134 deletions
diff --git a/sys/gnu/ext2fs/ext2_extern.h b/sys/gnu/ext2fs/ext2_extern.h index 8e73723..57c62b1 100644 --- a/sys/gnu/ext2fs/ext2_extern.h +++ b/sys/gnu/ext2fs/ext2_extern.h @@ -74,7 +74,7 @@ int ext2_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *); int ext2_update(struct vnode *, int); int ext2_valloc(struct vnode *, int, struct ucred *, struct vnode **); int ext2_vfree(struct vnode *, ino_t, int); -int ext2_vinit(struct mount *, vop_t **, struct vnode **vpp); +int ext2_vinit(struct mount *, struct vop_vector *, struct vnode **vpp); int ext2_lookup(struct vop_cachedlookup_args *); int ext2_readdir(struct vop_readdir_args *); void ext2_print_inode(struct inode *); @@ -105,7 +105,7 @@ void mark_buffer_dirty(struct buf *bh); #define B_METAONLY 0x04 /* Return indirect block buffer. */ #define B_NOWAIT 0x08 /* do not sleep to await lock */ -extern vop_t **ext2_vnodeop_p; -extern vop_t **ext2_fifoop_p; +extern struct vop_vector ext2_vnodeops; +extern struct vop_vector ext2_fifoops; #endif /* !_SYS_GNU_EXT2FS_EXT2_EXTERN_H_ */ diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 905e7f7..0519c59 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -1026,7 +1026,7 @@ restart: MALLOC(ip, struct inode *, sizeof(struct inode), M_EXT2NODE, M_WAITOK); /* Allocate a new vnode/inode. */ - if ((error = getnewvnode("ext2fs", mp, ext2_vnodeop_p, &vp)) != 0) { + if ((error = getnewvnode("ext2fs", mp, &ext2_vnodeops, &vp)) != 0) { if (ext2fs_inode_hash_lock < 0) wakeup(&ext2fs_inode_hash_lock); ext2fs_inode_hash_lock = 0; @@ -1095,7 +1095,7 @@ printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino))); * Initialize the vnode from the inode, check for aliases. * Note that the underlying vnode may have changed. */ - if ((error = ext2_vinit(mp, ext2_fifoop_p, &vp)) != 0) { + if ((error = ext2_vinit(mp, &ext2_fifoops, &vp)) != 0) { vput(vp); *vpp = NULL; return (error); diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c index b644ab8..ebc39d0 100644 --- a/sys/gnu/ext2fs/ext2_vnops.c +++ b/sys/gnu/ext2fs/ext2_vnops.c @@ -116,65 +116,54 @@ static int filt_ext2vnode(struct knote *kn, long hint); static void filt_ext2detach(struct knote *kn); /* Global vfs data structures for ext2. */ -vop_t **ext2_vnodeop_p; -static struct vnodeopv_entry_desc ext2_vnodeop_entries[] = { - { &vop_default_desc, (vop_t *) vop_defaultop }, - { &vop_access_desc, (vop_t *) ext2_access }, - { &vop_advlock_desc, (vop_t *) ext2_advlock }, - { &vop_bmap_desc, (vop_t *) ext2_bmap }, - { &vop_cachedlookup_desc, (vop_t *) ext2_lookup }, - { &vop_close_desc, (vop_t *) ext2_close }, - { &vop_create_desc, (vop_t *) ext2_create }, - { &vop_fsync_desc, (vop_t *) ext2_fsync }, - { &vop_getattr_desc, (vop_t *) ext2_getattr }, - { &vop_inactive_desc, (vop_t *) ext2_inactive }, - { &vop_link_desc, (vop_t *) ext2_link }, - { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, - { &vop_mkdir_desc, (vop_t *) ext2_mkdir }, - { &vop_mknod_desc, (vop_t *) ext2_mknod }, - { &vop_open_desc, (vop_t *) ext2_open }, - { &vop_pathconf_desc, (vop_t *) ext2_pathconf }, - { &vop_poll_desc, (vop_t *) vop_stdpoll }, - { &vop_kqfilter_desc, (vop_t *) ext2_kqfilter }, - { &vop_print_desc, (vop_t *) ext2_print }, - { &vop_read_desc, (vop_t *) ext2_read }, - { &vop_readdir_desc, (vop_t *) ext2_readdir }, - { &vop_readlink_desc, (vop_t *) ext2_readlink }, - { &vop_reallocblks_desc, (vop_t *) ext2_reallocblks }, - { &vop_reclaim_desc, (vop_t *) ext2_reclaim }, - { &vop_remove_desc, (vop_t *) ext2_remove }, - { &vop_rename_desc, (vop_t *) ext2_rename }, - { &vop_rmdir_desc, (vop_t *) ext2_rmdir }, - { &vop_setattr_desc, (vop_t *) ext2_setattr }, - { &vop_strategy_desc, (vop_t *) ext2_strategy }, - { &vop_symlink_desc, (vop_t *) ext2_symlink }, - { &vop_write_desc, (vop_t *) ext2_write }, - { NULL, NULL } +struct vop_vector ext2_vnodeops = { + .vop_default = &default_vnodeops, + .vop_access = ext2_access, + .vop_advlock = ext2_advlock, + .vop_bmap = ext2_bmap, + .vop_cachedlookup = ext2_lookup, + .vop_close = ext2_close, + .vop_create = ext2_create, + .vop_fsync = ext2_fsync, + .vop_getattr = ext2_getattr, + .vop_inactive = ext2_inactive, + .vop_link = ext2_link, + .vop_lookup = vfs_cache_lookup, + .vop_mkdir = ext2_mkdir, + .vop_mknod = ext2_mknod, + .vop_open = ext2_open, + .vop_pathconf = ext2_pathconf, + .vop_poll = vop_stdpoll, + .vop_kqfilter = ext2_kqfilter, + .vop_print = ext2_print, + .vop_read = ext2_read, + .vop_readdir = ext2_readdir, + .vop_readlink = ext2_readlink, + .vop_reallocblks = ext2_reallocblks, + .vop_reclaim = ext2_reclaim, + .vop_remove = ext2_remove, + .vop_rename = ext2_rename, + .vop_rmdir = ext2_rmdir, + .vop_setattr = ext2_setattr, + .vop_strategy = ext2_strategy, + .vop_symlink = ext2_symlink, + .vop_write = ext2_write, }; -static struct vnodeopv_desc ext2fs_vnodeop_opv_desc = - { &ext2_vnodeop_p, ext2_vnodeop_entries }; - -vop_t **ext2_fifoop_p; -static struct vnodeopv_entry_desc ext2_fifoop_entries[] = { - { &vop_default_desc, (vop_t *) fifo_vnoperate }, - { &vop_access_desc, (vop_t *) ext2_access }, - { &vop_close_desc, (vop_t *) ext2fifo_close }, - { &vop_fsync_desc, (vop_t *) ext2_fsync }, - { &vop_getattr_desc, (vop_t *) ext2_getattr }, - { &vop_inactive_desc, (vop_t *) ext2_inactive }, - { &vop_kqfilter_desc, (vop_t *) ext2fifo_kqfilter }, - { &vop_print_desc, (vop_t *) ext2_print }, - { &vop_read_desc, (vop_t *) ext2fifo_read }, - { &vop_reclaim_desc, (vop_t *) ext2_reclaim }, - { &vop_setattr_desc, (vop_t *) ext2_setattr }, - { &vop_write_desc, (vop_t *) ext2fifo_write }, - { NULL, NULL } -}; -static struct vnodeopv_desc ext2fs_fifoop_opv_desc = - { &ext2_fifoop_p, ext2_fifoop_entries }; - VNODEOP_SET(ext2fs_vnodeop_opv_desc); - VNODEOP_SET(ext2fs_fifoop_opv_desc); +struct vop_vector ext2_fifoops = { + .vop_default = &fifo_specops, + .vop_access = ext2_access, + .vop_close = ext2fifo_close, + .vop_fsync = ext2_fsync, + .vop_getattr = ext2_getattr, + .vop_inactive = ext2_inactive, + .vop_kqfilter = ext2fifo_kqfilter, + .vop_print = ext2_print, + .vop_read = ext2fifo_read, + .vop_reclaim = ext2_reclaim, + .vop_setattr = ext2_setattr, + .vop_write = ext2fifo_write, +}; #include <gnu/ext2fs/ext2_readwrite.c> @@ -1487,7 +1476,7 @@ ext2fifo_read(ap) uio = ap->a_uio; resid = uio->uio_resid; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_read), ap); + error = fifo_specops.vop_read(ap); ip = VTOI(ap->a_vp); if ((ap->a_vp->v_mount->mnt_flag & MNT_NOATIME) == 0 && ip != NULL && (uio->uio_resid != resid || (error == 0 && resid != 0))) @@ -1513,7 +1502,7 @@ ext2fifo_write(ap) uio = ap->a_uio; resid = uio->uio_resid; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_write), ap); + error = fifo_specops.vop_write(ap); ip = VTOI(ap->a_vp); if (ip != NULL && (uio->uio_resid != resid || (error == 0 && resid != 0))) VTOI(ap->a_vp)->i_flag |= IN_CHANGE | IN_UPDATE; @@ -1540,7 +1529,7 @@ ext2fifo_close(ap) if (vp->v_usecount > 1) ext2_itimes(vp); VI_UNLOCK(vp); - return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap)); + return (fifo_specops.vop_close(ap)); } /* @@ -1554,7 +1543,7 @@ ext2fifo_kqfilter(ap) { int error; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_kqfilter), ap); + error = fifo_specops.vop_kqfilter(ap); if (error) error = ext2_kqfilter(ap); return (error); @@ -1622,7 +1611,7 @@ ext2_advlock(ap) int ext2_vinit(mntp, fifoops, vpp) struct mount *mntp; - vop_t **fifoops; + struct vop_vector *fifoops; struct vnode **vpp; { struct inode *ip; diff --git a/sys/gnu/fs/ext2fs/ext2_extern.h b/sys/gnu/fs/ext2fs/ext2_extern.h index 8e73723..57c62b1 100644 --- a/sys/gnu/fs/ext2fs/ext2_extern.h +++ b/sys/gnu/fs/ext2fs/ext2_extern.h @@ -74,7 +74,7 @@ int ext2_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *); int ext2_update(struct vnode *, int); int ext2_valloc(struct vnode *, int, struct ucred *, struct vnode **); int ext2_vfree(struct vnode *, ino_t, int); -int ext2_vinit(struct mount *, vop_t **, struct vnode **vpp); +int ext2_vinit(struct mount *, struct vop_vector *, struct vnode **vpp); int ext2_lookup(struct vop_cachedlookup_args *); int ext2_readdir(struct vop_readdir_args *); void ext2_print_inode(struct inode *); @@ -105,7 +105,7 @@ void mark_buffer_dirty(struct buf *bh); #define B_METAONLY 0x04 /* Return indirect block buffer. */ #define B_NOWAIT 0x08 /* do not sleep to await lock */ -extern vop_t **ext2_vnodeop_p; -extern vop_t **ext2_fifoop_p; +extern struct vop_vector ext2_vnodeops; +extern struct vop_vector ext2_fifoops; #endif /* !_SYS_GNU_EXT2FS_EXT2_EXTERN_H_ */ diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 905e7f7..0519c59 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -1026,7 +1026,7 @@ restart: MALLOC(ip, struct inode *, sizeof(struct inode), M_EXT2NODE, M_WAITOK); /* Allocate a new vnode/inode. */ - if ((error = getnewvnode("ext2fs", mp, ext2_vnodeop_p, &vp)) != 0) { + if ((error = getnewvnode("ext2fs", mp, &ext2_vnodeops, &vp)) != 0) { if (ext2fs_inode_hash_lock < 0) wakeup(&ext2fs_inode_hash_lock); ext2fs_inode_hash_lock = 0; @@ -1095,7 +1095,7 @@ printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino))); * Initialize the vnode from the inode, check for aliases. * Note that the underlying vnode may have changed. */ - if ((error = ext2_vinit(mp, ext2_fifoop_p, &vp)) != 0) { + if ((error = ext2_vinit(mp, &ext2_fifoops, &vp)) != 0) { vput(vp); *vpp = NULL; return (error); diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c index b644ab8..ebc39d0 100644 --- a/sys/gnu/fs/ext2fs/ext2_vnops.c +++ b/sys/gnu/fs/ext2fs/ext2_vnops.c @@ -116,65 +116,54 @@ static int filt_ext2vnode(struct knote *kn, long hint); static void filt_ext2detach(struct knote *kn); /* Global vfs data structures for ext2. */ -vop_t **ext2_vnodeop_p; -static struct vnodeopv_entry_desc ext2_vnodeop_entries[] = { - { &vop_default_desc, (vop_t *) vop_defaultop }, - { &vop_access_desc, (vop_t *) ext2_access }, - { &vop_advlock_desc, (vop_t *) ext2_advlock }, - { &vop_bmap_desc, (vop_t *) ext2_bmap }, - { &vop_cachedlookup_desc, (vop_t *) ext2_lookup }, - { &vop_close_desc, (vop_t *) ext2_close }, - { &vop_create_desc, (vop_t *) ext2_create }, - { &vop_fsync_desc, (vop_t *) ext2_fsync }, - { &vop_getattr_desc, (vop_t *) ext2_getattr }, - { &vop_inactive_desc, (vop_t *) ext2_inactive }, - { &vop_link_desc, (vop_t *) ext2_link }, - { &vop_lookup_desc, (vop_t *) vfs_cache_lookup }, - { &vop_mkdir_desc, (vop_t *) ext2_mkdir }, - { &vop_mknod_desc, (vop_t *) ext2_mknod }, - { &vop_open_desc, (vop_t *) ext2_open }, - { &vop_pathconf_desc, (vop_t *) ext2_pathconf }, - { &vop_poll_desc, (vop_t *) vop_stdpoll }, - { &vop_kqfilter_desc, (vop_t *) ext2_kqfilter }, - { &vop_print_desc, (vop_t *) ext2_print }, - { &vop_read_desc, (vop_t *) ext2_read }, - { &vop_readdir_desc, (vop_t *) ext2_readdir }, - { &vop_readlink_desc, (vop_t *) ext2_readlink }, - { &vop_reallocblks_desc, (vop_t *) ext2_reallocblks }, - { &vop_reclaim_desc, (vop_t *) ext2_reclaim }, - { &vop_remove_desc, (vop_t *) ext2_remove }, - { &vop_rename_desc, (vop_t *) ext2_rename }, - { &vop_rmdir_desc, (vop_t *) ext2_rmdir }, - { &vop_setattr_desc, (vop_t *) ext2_setattr }, - { &vop_strategy_desc, (vop_t *) ext2_strategy }, - { &vop_symlink_desc, (vop_t *) ext2_symlink }, - { &vop_write_desc, (vop_t *) ext2_write }, - { NULL, NULL } +struct vop_vector ext2_vnodeops = { + .vop_default = &default_vnodeops, + .vop_access = ext2_access, + .vop_advlock = ext2_advlock, + .vop_bmap = ext2_bmap, + .vop_cachedlookup = ext2_lookup, + .vop_close = ext2_close, + .vop_create = ext2_create, + .vop_fsync = ext2_fsync, + .vop_getattr = ext2_getattr, + .vop_inactive = ext2_inactive, + .vop_link = ext2_link, + .vop_lookup = vfs_cache_lookup, + .vop_mkdir = ext2_mkdir, + .vop_mknod = ext2_mknod, + .vop_open = ext2_open, + .vop_pathconf = ext2_pathconf, + .vop_poll = vop_stdpoll, + .vop_kqfilter = ext2_kqfilter, + .vop_print = ext2_print, + .vop_read = ext2_read, + .vop_readdir = ext2_readdir, + .vop_readlink = ext2_readlink, + .vop_reallocblks = ext2_reallocblks, + .vop_reclaim = ext2_reclaim, + .vop_remove = ext2_remove, + .vop_rename = ext2_rename, + .vop_rmdir = ext2_rmdir, + .vop_setattr = ext2_setattr, + .vop_strategy = ext2_strategy, + .vop_symlink = ext2_symlink, + .vop_write = ext2_write, }; -static struct vnodeopv_desc ext2fs_vnodeop_opv_desc = - { &ext2_vnodeop_p, ext2_vnodeop_entries }; - -vop_t **ext2_fifoop_p; -static struct vnodeopv_entry_desc ext2_fifoop_entries[] = { - { &vop_default_desc, (vop_t *) fifo_vnoperate }, - { &vop_access_desc, (vop_t *) ext2_access }, - { &vop_close_desc, (vop_t *) ext2fifo_close }, - { &vop_fsync_desc, (vop_t *) ext2_fsync }, - { &vop_getattr_desc, (vop_t *) ext2_getattr }, - { &vop_inactive_desc, (vop_t *) ext2_inactive }, - { &vop_kqfilter_desc, (vop_t *) ext2fifo_kqfilter }, - { &vop_print_desc, (vop_t *) ext2_print }, - { &vop_read_desc, (vop_t *) ext2fifo_read }, - { &vop_reclaim_desc, (vop_t *) ext2_reclaim }, - { &vop_setattr_desc, (vop_t *) ext2_setattr }, - { &vop_write_desc, (vop_t *) ext2fifo_write }, - { NULL, NULL } -}; -static struct vnodeopv_desc ext2fs_fifoop_opv_desc = - { &ext2_fifoop_p, ext2_fifoop_entries }; - VNODEOP_SET(ext2fs_vnodeop_opv_desc); - VNODEOP_SET(ext2fs_fifoop_opv_desc); +struct vop_vector ext2_fifoops = { + .vop_default = &fifo_specops, + .vop_access = ext2_access, + .vop_close = ext2fifo_close, + .vop_fsync = ext2_fsync, + .vop_getattr = ext2_getattr, + .vop_inactive = ext2_inactive, + .vop_kqfilter = ext2fifo_kqfilter, + .vop_print = ext2_print, + .vop_read = ext2fifo_read, + .vop_reclaim = ext2_reclaim, + .vop_setattr = ext2_setattr, + .vop_write = ext2fifo_write, +}; #include <gnu/ext2fs/ext2_readwrite.c> @@ -1487,7 +1476,7 @@ ext2fifo_read(ap) uio = ap->a_uio; resid = uio->uio_resid; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_read), ap); + error = fifo_specops.vop_read(ap); ip = VTOI(ap->a_vp); if ((ap->a_vp->v_mount->mnt_flag & MNT_NOATIME) == 0 && ip != NULL && (uio->uio_resid != resid || (error == 0 && resid != 0))) @@ -1513,7 +1502,7 @@ ext2fifo_write(ap) uio = ap->a_uio; resid = uio->uio_resid; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_write), ap); + error = fifo_specops.vop_write(ap); ip = VTOI(ap->a_vp); if (ip != NULL && (uio->uio_resid != resid || (error == 0 && resid != 0))) VTOI(ap->a_vp)->i_flag |= IN_CHANGE | IN_UPDATE; @@ -1540,7 +1529,7 @@ ext2fifo_close(ap) if (vp->v_usecount > 1) ext2_itimes(vp); VI_UNLOCK(vp); - return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap)); + return (fifo_specops.vop_close(ap)); } /* @@ -1554,7 +1543,7 @@ ext2fifo_kqfilter(ap) { int error; - error = VOCALL(fifo_vnodeop_p, VOFFSET(vop_kqfilter), ap); + error = fifo_specops.vop_kqfilter(ap); if (error) error = ext2_kqfilter(ap); return (error); @@ -1622,7 +1611,7 @@ ext2_advlock(ap) int ext2_vinit(mntp, fifoops, vpp) struct mount *mntp; - vop_t **fifoops; + struct vop_vector *fifoops; struct vnode **vpp; { struct inode *ip; |