svn commit: r197680 - in head/sys: fs/fifofs kern sys
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Oct 1 17:22:04 UTC 2009
Author: trasz
Date: Thu Oct 1 17:22:03 2009
New Revision: 197680
URL: http://svn.freebsd.org/changeset/base/197680
Log:
Provide default implementation for VOP_ACCESS(9), so that filesystems which
want to provide VOP_ACCESSX(9) don't have to implement both. Note that
this commit makes implementation of either of these two mandatory.
Reviewed by: kib
Modified:
head/sys/fs/fifofs/fifo_vnops.c
head/sys/kern/subr_acl_posix1e.c
head/sys/kern/vfs_default.c
head/sys/kern/vfs_subr.c
head/sys/sys/vnode.h
Modified: head/sys/fs/fifofs/fifo_vnops.c
==============================================================================
--- head/sys/fs/fifofs/fifo_vnops.c Thu Oct 1 17:12:52 2009 (r197679)
+++ head/sys/fs/fifofs/fifo_vnops.c Thu Oct 1 17:22:03 2009 (r197680)
@@ -119,7 +119,6 @@ static struct filterops fifo_notsup_filt
struct vop_vector fifo_specops = {
.vop_default = &default_vnodeops,
- .vop_access = VOP_EBADF,
.vop_advlock = fifo_advlock,
.vop_close = fifo_close,
.vop_create = VOP_PANIC,
Modified: head/sys/kern/subr_acl_posix1e.c
==============================================================================
--- head/sys/kern/subr_acl_posix1e.c Thu Oct 1 17:12:52 2009 (r197679)
+++ head/sys/kern/subr_acl_posix1e.c Thu Oct 1 17:22:03 2009 (r197680)
@@ -61,6 +61,9 @@ vaccess_acl_posix1e(enum vtype type, uid
accmode_t acl_mask_granted;
int group_matched, i;
+ KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0,
+ ("invalid bit in accmode"));
+
/*
* Look for a normal, non-privileged way to access the file/directory
* as requested. If it exists, go with that. Otherwise, attempt to
Modified: head/sys/kern/vfs_default.c
==============================================================================
--- head/sys/kern/vfs_default.c Thu Oct 1 17:12:52 2009 (r197679)
+++ head/sys/kern/vfs_default.c Thu Oct 1 17:22:03 2009 (r197680)
@@ -83,12 +83,17 @@ static int dirent_exists(struct vnode *v
*
* If there is no specific entry here, we will return EOPNOTSUPP.
*
+ * Note that every filesystem has to implement either vop_access
+ * or vop_accessx; failing to do so will result in immediate crash
+ * due to stack overflow, as vop_stdaccess() calls vop_stdaccessx(),
+ * which calls vop_stdaccess() etc.
*/
struct vop_vector default_vnodeops = {
.vop_default = NULL,
.vop_bypass = VOP_EOPNOTSUPP,
+ .vop_access = vop_stdaccess,
.vop_accessx = vop_stdaccessx,
.vop_advlock = vop_stdadvlock,
.vop_advlockasync = vop_stdadvlockasync,
@@ -326,6 +331,16 @@ out:
}
int
+vop_stdaccess(struct vop_access_args *ap)
+{
+
+ KASSERT((ap->a_accmode & ~(VEXEC | VWRITE | VREAD | VADMIN |
+ VAPPEND)) == 0, ("invalid bit in accmode"));
+
+ return (VOP_ACCESSX(ap->a_vp, ap->a_accmode, ap->a_cred, ap->a_td));
+}
+
+int
vop_stdaccessx(struct vop_accessx_args *ap)
{
int error;
Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c Thu Oct 1 17:12:52 2009 (r197679)
+++ head/sys/kern/vfs_subr.c Thu Oct 1 17:22:03 2009 (r197680)
@@ -3520,6 +3520,9 @@ vaccess(enum vtype type, mode_t file_mod
accmode_t dac_granted;
accmode_t priv_granted;
+ KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0,
+ ("invalid bit in accmode"));
+
/*
* Look for a normal, non-privileged way to access the file/directory
* as requested. If it exists, go with that.
Modified: head/sys/sys/vnode.h
==============================================================================
--- head/sys/sys/vnode.h Thu Oct 1 17:12:52 2009 (r197679)
+++ head/sys/sys/vnode.h Thu Oct 1 17:22:03 2009 (r197680)
@@ -685,6 +685,7 @@ int vop_stdlock(struct vop_lock1_args *)
int vop_stdputpages(struct vop_putpages_args *);
int vop_stdunlock(struct vop_unlock_args *);
int vop_nopoll(struct vop_poll_args *);
+int vop_stdaccess(struct vop_access_args *ap);
int vop_stdaccessx(struct vop_accessx_args *ap);
int vop_stdadvlock(struct vop_advlock_args *ap);
int vop_stdadvlockasync(struct vop_advlockasync_args *ap);
More information about the svn-src-head
mailing list