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
This commit is contained in:
Edward Tomasz Napierala 2009-10-01 17:22:03 +00:00
parent 7aee6ffee0
commit 2c29cfa083
5 changed files with 22 additions and 1 deletions

View File

@ -119,7 +119,6 @@ static struct filterops fifo_notsup_filtops = {
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,

View File

@ -61,6 +61,9 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
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

View File

@ -83,12 +83,17 @@ static int dirent_exists(struct vnode *vp, const char *dirname,
*
* 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,
@ -325,6 +330,16 @@ dirent_exists(struct vnode *vp, const char *dirname, struct thread *td)
return (found);
}
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)
{

View File

@ -3520,6 +3520,9 @@ vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, gid_t file_gid,
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.

View File

@ -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);