summaryrefslogtreecommitdiff
path: root/sys/miscfs
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-09-06 23:44:12 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-09-06 23:44:12 +0000
commit87f3d58d3064a78c9b29faa668f1d98225f01e71 (patch)
treebbc6c4fb3c1748ac72b8b1b8bab76b4e91896fd0 /sys/miscfs
parenta41bd31e53cce764c5bc6861ce6be4074cc59551 (diff)
End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can tell never been used in practice, atleast not in OpenBSD), remove all the gunk and favor a simple struct full of function pointers that get set directly by each of the filesystems. Removes gobs of ugly code and makes things simpler by a magnitude. The only downside of this is that we loose the vnoperate feature so the spec/fifo operations of the filesystems need to be kept in sync with specfs and fifofs, this is no big deal as the API it self is pretty static. Many thanks to armani@ who pulled an earlier version of this diff to current after c2k10 and Gabriel Kihlman on tech@ for testing. Liked by many. "come on, find your balls" deraadt@.
Diffstat (limited to 'sys/miscfs')
-rw-r--r--sys/miscfs/deadfs/dead_vnops.c81
-rw-r--r--sys/miscfs/fifofs/fifo.h6
-rw-r--r--sys/miscfs/fifofs/fifo_vnops.c89
-rw-r--r--sys/miscfs/procfs/procfs.h4
-rw-r--r--sys/miscfs/procfs/procfs_subr.c4
-rw-r--r--sys/miscfs/procfs/procfs_vnops.c74
-rw-r--r--sys/miscfs/specfs/spec_vnops.c88
-rw-r--r--sys/miscfs/specfs/specdev.h6
8 files changed, 156 insertions, 196 deletions
diff --git a/sys/miscfs/deadfs/dead_vnops.c b/sys/miscfs/deadfs/dead_vnops.c
index 1bb277609cb..141f9385f51 100644
--- a/sys/miscfs/deadfs/dead_vnops.c
+++ b/sys/miscfs/deadfs/dead_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dead_vnops.c,v 1.22 2009/08/13 15:00:13 jasper Exp $ */
+/* $OpenBSD: dead_vnops.c,v 1.23 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: dead_vnops.c,v 1.16 1996/02/13 13:12:48 mycroft Exp $ */
/*
@@ -60,47 +60,42 @@ int dead_print(void *);
int chkvnlock(struct vnode *);
-int (**dead_vnodeop_p)(void *);
-
-struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
- { &vop_default_desc, eopnotsupp },
- { &vop_lookup_desc, vop_generic_lookup },
- { &vop_create_desc, dead_badop },
- { &vop_mknod_desc, dead_badop },
- { &vop_open_desc, dead_open },
- { &vop_close_desc, nullop },
- { &vop_access_desc, dead_ebadf },
- { &vop_getattr_desc, dead_ebadf },
- { &vop_setattr_desc, dead_ebadf },
- { &vop_read_desc, dead_read },
- { &vop_write_desc, dead_write },
- { &vop_ioctl_desc, dead_ioctl },
- { &vop_poll_desc, dead_poll },
- { &vop_fsync_desc, nullop },
- { &vop_remove_desc, dead_badop },
- { &vop_link_desc, dead_badop },
- { &vop_rename_desc, dead_badop },
- { &vop_mkdir_desc, dead_badop },
- { &vop_rmdir_desc, dead_badop },
- { &vop_symlink_desc, dead_badop },
- { &vop_readdir_desc, dead_ebadf },
- { &vop_readlink_desc, dead_ebadf },
- { &vop_abortop_desc, dead_badop },
- { &vop_inactive_desc, nullop },
- { &vop_reclaim_desc, nullop },
- { &vop_lock_desc, dead_lock },
- { &vop_unlock_desc, vop_generic_unlock },
- { &vop_bmap_desc, dead_bmap },
- { &vop_strategy_desc, dead_strategy },
- { &vop_print_desc, dead_print },
- { &vop_islocked_desc, vop_generic_islocked },
- { &vop_pathconf_desc, dead_ebadf },
- { &vop_advlock_desc, dead_ebadf },
- { &vop_bwrite_desc, nullop },
- { (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
+struct vops dead_vops = {
+ .vop_default = eopnotsupp,
+ .vop_lookup = vop_generic_lookup,
+ .vop_create = dead_badop,
+ .vop_mknod = dead_badop,
+ .vop_open = dead_open,
+ .vop_close = nullop,
+ .vop_access = dead_ebadf,
+ .vop_getattr = dead_ebadf,
+ .vop_setattr = dead_ebadf,
+ .vop_read = dead_read,
+ .vop_write = dead_write,
+ .vop_ioctl = dead_ioctl,
+ .vop_poll = dead_poll,
+ .vop_fsync = nullop,
+ .vop_remove = dead_badop,
+ .vop_link = dead_badop,
+ .vop_rename = dead_badop,
+ .vop_mkdir = dead_badop,
+ .vop_rmdir = dead_badop,
+ .vop_symlink = dead_badop,
+ .vop_readdir = dead_ebadf,
+ .vop_readlink = dead_ebadf,
+ .vop_abortop = dead_badop,
+ .vop_inactive = nullop,
+ .vop_reclaim = nullop,
+ .vop_lock = dead_lock,
+ .vop_unlock = vop_generic_unlock,
+ .vop_bmap = dead_bmap,
+ .vop_strategy = dead_strategy,
+ .vop_print = dead_print,
+ .vop_islocked = vop_generic_islocked,
+ .vop_pathconf = dead_ebadf,
+ .vop_advlock = dead_ebadf,
+ .vop_bwrite = nullop,
};
-struct vnodeopv_desc dead_vnodeop_opv_desc =
- { &dead_vnodeop_p, dead_vnodeop_entries };
/*
* Open always fails as if device did not exist.
@@ -156,7 +151,7 @@ dead_ioctl(void *v)
if (!chkvnlock(ap->a_vp))
return (EBADF);
- return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
+ return ((ap->a_vp->v_op->vop_ioctl)(ap));
}
/* ARGSUSED */
@@ -204,7 +199,7 @@ dead_lock(void *v)
if (ap->a_flags & LK_DRAIN || !chkvnlock(vp))
return (0);
- return (VCALL(vp, VOFFSET(vop_lock), ap));
+ return ((vp->v_op->vop_lock)(ap));
}
/*
diff --git a/sys/miscfs/fifofs/fifo.h b/sys/miscfs/fifofs/fifo.h
index 77a8a4c52c9..e0172ce1dfe 100644
--- a/sys/miscfs/fifofs/fifo.h
+++ b/sys/miscfs/fifofs/fifo.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fifo.h,v 1.19 2008/05/03 14:41:29 thib Exp $ */
+/* $OpenBSD: fifo.h,v 1.20 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: fifo.h,v 1.10 1996/02/09 22:40:15 christos Exp $ */
/*
@@ -53,8 +53,4 @@ int fifo_pathconf(void *);
int fifo_advlock(void *);
void fifo_printinfo(struct vnode *);
-int fifo_vnoperate(void *);
-
-extern int (**fifo_vnodeop_p)(void *);
-
#endif /* FIFO */
diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c
index d5884f20bef..6a8c984fa8d 100644
--- a/sys/miscfs/fifofs/fifo_vnops.c
+++ b/sys/miscfs/fifofs/fifo_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fifo_vnops.c,v 1.31 2009/08/13 15:00:14 jasper Exp $ */
+/* $OpenBSD: fifo_vnops.c,v 1.32 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */
/*
@@ -61,58 +61,45 @@ struct fifoinfo {
long fi_writers;
};
-int (**fifo_vnodeop_p)(void *);
-struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
- { &vop_default_desc, eopnotsupp },
- { &vop_lookup_desc, vop_generic_lookup },
- { &vop_create_desc, fifo_badop },
- { &vop_mknod_desc, fifo_badop },
- { &vop_open_desc, fifo_open },
- { &vop_close_desc, fifo_close },
- { &vop_access_desc, fifo_ebadf },
- { &vop_getattr_desc, fifo_ebadf },
- { &vop_setattr_desc, fifo_ebadf },
- { &vop_read_desc, fifo_read },
- { &vop_write_desc, fifo_write },
- { &vop_ioctl_desc, fifo_ioctl },
- { &vop_poll_desc, fifo_poll },
- { &vop_kqfilter_desc, fifo_kqfilter },
- { &vop_revoke_desc, vop_generic_revoke },
- { &vop_fsync_desc, nullop },
- { &vop_remove_desc, fifo_badop },
- { &vop_link_desc, fifo_badop },
- { &vop_rename_desc, fifo_badop },
- { &vop_mkdir_desc, fifo_badop },
- { &vop_rmdir_desc, fifo_badop },
- { &vop_symlink_desc, fifo_badop },
- { &vop_readdir_desc, fifo_badop },
- { &vop_readlink_desc, fifo_badop },
- { &vop_abortop_desc, fifo_badop },
- { &vop_inactive_desc, fifo_inactive },
- { &vop_reclaim_desc, fifo_reclaim },
- { &vop_lock_desc, vop_generic_lock },
- { &vop_unlock_desc, vop_generic_unlock },
- { &vop_bmap_desc, vop_generic_bmap },
- { &vop_strategy_desc, fifo_badop },
- { &vop_print_desc, fifo_print },
- { &vop_islocked_desc, vop_generic_islocked },
- { &vop_pathconf_desc, fifo_pathconf },
- { &vop_advlock_desc, fifo_advlock },
- { &vop_bwrite_desc, nullop },
- { NULL, NULL }
+struct vops fifo_vops = {
+ .vop_default = eopnotsupp,
+ .vop_lookup = vop_generic_lookup,
+ .vop_create = fifo_badop,
+ .vop_mknod = fifo_badop,
+ .vop_open = fifo_open,
+ .vop_close = fifo_close,
+ .vop_access = fifo_ebadf,
+ .vop_getattr = fifo_ebadf,
+ .vop_setattr = fifo_ebadf,
+ .vop_read = fifo_read,
+ .vop_write = fifo_write,
+ .vop_ioctl = fifo_ioctl,
+ .vop_poll = fifo_poll,
+ .vop_kqfilter = fifo_kqfilter,
+ .vop_revoke = vop_generic_revoke,
+ .vop_fsync = nullop,
+ .vop_remove = fifo_badop,
+ .vop_link = fifo_badop,
+ .vop_rename = fifo_badop,
+ .vop_mkdir = fifo_badop,
+ .vop_rmdir = fifo_badop,
+ .vop_symlink = fifo_badop,
+ .vop_readdir = fifo_badop,
+ .vop_readlink = fifo_badop,
+ .vop_abortop = fifo_badop,
+ .vop_inactive = fifo_inactive,
+ .vop_reclaim = fifo_reclaim,
+ .vop_lock = vop_generic_lock,
+ .vop_unlock = vop_generic_unlock,
+ .vop_bmap = vop_generic_bmap,
+ .vop_strategy = fifo_badop,
+ .vop_print = fifo_print,
+ .vop_islocked = vop_generic_islocked,
+ .vop_pathconf = fifo_pathconf,
+ .vop_advlock = fifo_advlock,
+ .vop_bwrite = nullop
};
-struct vnodeopv_desc fifo_vnodeop_opv_desc =
- { &fifo_vnodeop_p, fifo_vnodeop_entries };
-
-int
-fifo_vnoperate(void *v)
-{
- struct vop_generic_args *ap = v;
-
- return (VOCALL(fifo_vnodeop_p, ap->a_desc->vdesc_offset, ap));
-}
-
void filt_fifordetach(struct knote *kn);
int filt_fiforead(struct knote *kn, long hint);
void filt_fifowdetach(struct knote *kn);
diff --git a/sys/miscfs/procfs/procfs.h b/sys/miscfs/procfs/procfs.h
index 361fe46d574..cfb4a18ecc0 100644
--- a/sys/miscfs/procfs/procfs.h
+++ b/sys/miscfs/procfs/procfs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs.h,v 1.24 2007/06/22 09:38:53 jasper Exp $ */
+/* $OpenBSD: procfs.h,v 1.25 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: procfs.h,v 1.17 1996/02/12 15:01:41 christos Exp $ */
/*
@@ -135,7 +135,7 @@ int procfs_rw(void *);
#define PROCFS_LOCKED 0x01
#define PROCFS_WANT 0x02
-extern int (**procfs_vnodeop_p)(void *);
+extern struct vops procfs_vops;
extern const struct vfsops procfs_vfsops;
struct vfsconf;
diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c
index 9bbe103393b..e57ed21d404 100644
--- a/sys/miscfs/procfs/procfs_subr.c
+++ b/sys/miscfs/procfs/procfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_subr.c,v 1.31 2009/08/10 14:55:11 oga Exp $ */
+/* $OpenBSD: procfs_subr.c,v 1.32 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */
/*
@@ -111,7 +111,7 @@ loop:
}
}
- if ((error = getnewvnode(VT_PROCFS, mp, procfs_vnodeop_p, vpp)) != 0)
+ if ((error = getnewvnode(VT_PROCFS, mp, &procfs_vops, vpp)) != 0)
goto out;
vp = *vpp;
diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c
index e9056953ec7..848f0e85214 100644
--- a/sys/miscfs/procfs/procfs_vnops.c
+++ b/sys/miscfs/procfs/procfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_vnops.c,v 1.47 2009/08/13 15:00:14 jasper Exp $ */
+/* $OpenBSD: procfs_vnops.c,v 1.48 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */
/*
@@ -138,45 +138,41 @@ static pid_t atopid(const char *, u_int);
/*
* procfs vnode operations.
*/
-int (**procfs_vnodeop_p)(void *);
-struct vnodeopv_entry_desc procfs_vnodeop_entries[] = {
- { &vop_default_desc, eopnotsupp },
- { &vop_lookup_desc, procfs_lookup },
- { &vop_create_desc, procfs_badop },
- { &vop_mknod_desc, procfs_badop },
- { &vop_open_desc, procfs_open },
- { &vop_close_desc, procfs_close },
- { &vop_access_desc, procfs_access },
- { &vop_getattr_desc, procfs_getattr },
- { &vop_setattr_desc, procfs_setattr },
- { &vop_read_desc, procfs_rw },
- { &vop_write_desc, procfs_rw },
- { &vop_ioctl_desc, procfs_ioctl },
- { &vop_poll_desc, procfs_poll },
- { &vop_fsync_desc, procfs_badop},
- { &vop_remove_desc, procfs_badop },
- { &vop_link_desc, procfs_link },
- { &vop_rename_desc, procfs_badop },
- { &vop_mkdir_desc, procfs_badop },
- { &vop_rmdir_desc, procfs_badop },
- { &vop_symlink_desc, procfs_symlink },
- { &vop_readdir_desc, procfs_readdir },
- { &vop_readlink_desc, procfs_readlink },
- { &vop_abortop_desc, vop_generic_abortop },
- { &vop_inactive_desc, procfs_inactive },
- { &vop_reclaim_desc, procfs_reclaim },
- { &vop_lock_desc, nullop },
- { &vop_unlock_desc, nullop },
- { &vop_bmap_desc, vop_generic_bmap },
- { &vop_strategy_desc, procfs_badop },
- { &vop_print_desc, procfs_print },
- { &vop_islocked_desc, nullop },
- { &vop_pathconf_desc, procfs_pathconf },
- { &vop_advlock_desc, procfs_badop },
- { NULL, NULL }
+struct vops procfs_vops = {
+ .vop_default = eopnotsupp,
+ .vop_lookup = procfs_lookup,
+ .vop_create = procfs_badop,
+ .vop_mknod = procfs_badop,
+ .vop_open = procfs_open,
+ .vop_close = procfs_close,
+ .vop_access = procfs_access,
+ .vop_getattr = procfs_getattr,
+ .vop_setattr = procfs_setattr,
+ .vop_read = procfs_rw,
+ .vop_write = procfs_rw,
+ .vop_ioctl = procfs_ioctl,
+ .vop_poll = procfs_poll,
+ .vop_fsync = procfs_badop,
+ .vop_remove = procfs_badop,
+ .vop_link = procfs_link,
+ .vop_rename = procfs_badop,
+ .vop_mkdir = procfs_badop,
+ .vop_rmdir = procfs_badop,
+ .vop_symlink = procfs_symlink,
+ .vop_readdir = procfs_readdir,
+ .vop_readlink = procfs_readlink,
+ .vop_abortop = vop_generic_abortop,
+ .vop_inactive = procfs_inactive,
+ .vop_reclaim = procfs_reclaim,
+ .vop_lock = nullop,
+ .vop_unlock = nullop,
+ .vop_bmap = vop_generic_bmap,
+ .vop_strategy = procfs_badop,
+ .vop_print = procfs_print,
+ .vop_islocked = nullop,
+ .vop_pathconf = procfs_pathconf,
+ .vop_advlock = procfs_badop,
};
-struct vnodeopv_desc procfs_vnodeop_opv_desc =
- { &procfs_vnodeop_p, procfs_vnodeop_entries };
/*
* set things up for doing i/o on
* the pfsnode (vp). (vp) is locked
diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c
index 11fde4c819b..2b613924840 100644
--- a/sys/miscfs/specfs/spec_vnops.c
+++ b/sys/miscfs/specfs/spec_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spec_vnops.c,v 1.58 2010/07/26 01:56:27 guenther Exp $ */
+/* $OpenBSD: spec_vnops.c,v 1.59 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */
/*
@@ -56,56 +56,44 @@
struct vnode *speclisth[SPECHSZ];
-int (**spec_vnodeop_p)(void *);
-struct vnodeopv_entry_desc spec_vnodeop_entries[] = {
- { &vop_default_desc, eopnotsupp },
- { &vop_lookup_desc, vop_generic_lookup },
- { &vop_create_desc, spec_badop },
- { &vop_mknod_desc, spec_badop },
- { &vop_open_desc, spec_open },
- { &vop_close_desc, spec_close },
- { &vop_access_desc, spec_access },
- { &vop_getattr_desc, spec_getattr },
- { &vop_setattr_desc, spec_setattr },
- { &vop_read_desc, spec_read },
- { &vop_write_desc, spec_write },
- { &vop_ioctl_desc, spec_ioctl },
- { &vop_poll_desc, spec_poll },
- { &vop_kqfilter_desc, spec_kqfilter },
- { &vop_revoke_desc, vop_generic_revoke },
- { &vop_fsync_desc, spec_fsync },
- { &vop_remove_desc, spec_badop },
- { &vop_link_desc, spec_badop },
- { &vop_rename_desc, spec_badop },
- { &vop_mkdir_desc, spec_badop },
- { &vop_rmdir_desc, spec_badop },
- { &vop_symlink_desc, spec_badop },
- { &vop_readdir_desc, spec_badop },
- { &vop_readlink_desc, spec_badop },
- { &vop_abortop_desc, spec_badop },
- { &vop_inactive_desc, spec_inactive },
- { &vop_reclaim_desc, nullop },
- { &vop_lock_desc, vop_generic_lock },
- { &vop_unlock_desc, vop_generic_unlock },
- { &vop_bmap_desc, vop_generic_bmap },
- { &vop_strategy_desc, spec_strategy },
- { &vop_print_desc, spec_print },
- { &vop_islocked_desc, vop_generic_islocked },
- { &vop_pathconf_desc, spec_pathconf },
- { &vop_advlock_desc, spec_advlock },
- { &vop_bwrite_desc, vop_generic_bwrite },
- { NULL, NULL }
+struct vops spec_vops = {
+ .vop_default = eopnotsupp,
+ .vop_lookup = vop_generic_lookup,
+ .vop_create = spec_badop,
+ .vop_mknod = spec_badop,
+ .vop_open = spec_open,
+ .vop_close = spec_close,
+ .vop_access = spec_access,
+ .vop_getattr = spec_getattr,
+ .vop_setattr = spec_setattr,
+ .vop_read = spec_read,
+ .vop_write = spec_write,
+ .vop_ioctl = spec_ioctl,
+ .vop_poll = spec_poll,
+ .vop_kqfilter = spec_kqfilter,
+ .vop_revoke = vop_generic_revoke,
+ .vop_fsync = spec_fsync,
+ .vop_remove = spec_badop,
+ .vop_link = spec_badop,
+ .vop_rename = spec_badop,
+ .vop_mkdir = spec_badop,
+ .vop_rmdir = spec_badop,
+ .vop_symlink = spec_badop,
+ .vop_readdir = spec_badop,
+ .vop_readlink = spec_badop,
+ .vop_abortop = spec_badop,
+ .vop_inactive = spec_inactive,
+ .vop_reclaim = nullop,
+ .vop_lock = vop_generic_lock,
+ .vop_unlock = vop_generic_unlock,
+ .vop_islocked = vop_generic_islocked,
+ .vop_bmap = vop_generic_bmap,
+ .vop_strategy = spec_strategy,
+ .vop_print = spec_print,
+ .vop_pathconf = spec_pathconf,
+ .vop_advlock = spec_advlock,
+ .vop_bwrite = vop_generic_bwrite,
};
-struct vnodeopv_desc spec_vnodeop_opv_desc =
- { &spec_vnodeop_p, spec_vnodeop_entries };
-
-int
-spec_vnoperate(void *v)
-{
- struct vop_generic_args *ap = v;
-
- return (VOCALL(spec_vnodeop_p, ap->a_desc->vdesc_offset, ap));
-}
/*
* Open a special file.
diff --git a/sys/miscfs/specfs/specdev.h b/sys/miscfs/specfs/specdev.h
index 7e1a83a7648..98f917b6a09 100644
--- a/sys/miscfs/specfs/specdev.h
+++ b/sys/miscfs/specfs/specdev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: specdev.h,v 1.26 2010/07/17 19:24:58 guenther Exp $ */
+/* $OpenBSD: specdev.h,v 1.27 2010/09/06 23:44:10 thib Exp $ */
/* $NetBSD: specdev.h,v 1.12 1996/02/13 13:13:01 mycroft Exp $ */
/*
@@ -82,7 +82,7 @@ extern struct vnode *speclisth[SPECHSZ];
/*
* Prototypes for special file operations on vnodes.
*/
-extern int (**spec_vnodeop_p)(void *);
+extern struct vops spec_vops;
struct nameidata;
struct componentname;
struct ucred;
@@ -108,8 +108,6 @@ int spec_print(void *);
int spec_pathconf(void *);
int spec_advlock(void *);
-int spec_vnoperate(void *);
-
/* spec_subr.c */
int spec_open_clone(struct vop_open_args *);
int spec_close_clone(struct vop_close_args *);