Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/tmpfs/tmpfs_vnops.c
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) | tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) | ||||
{ | { | ||||
struct tmpfs_dirent *de; | struct tmpfs_dirent *de; | ||||
struct tmpfs_node *dnode, *pnode; | struct tmpfs_node *dnode, *pnode; | ||||
struct tmpfs_mount *tm; | struct tmpfs_mount *tm; | ||||
int error; | int error; | ||||
/* Caller assumes responsibility for ensuring access (VEXEC). */ | |||||
dnode = VP_TO_TMPFS_DIR(dvp); | dnode = VP_TO_TMPFS_DIR(dvp); | ||||
*vpp = NULLVP; | *vpp = NULLVP; | ||||
/* Check accessibility of requested node as a first step. */ | |||||
error = vn_dir_check_exec(dvp, cnp); | |||||
if (error != 0) | |||||
goto out; | |||||
/* We cannot be requesting the parent directory of the root node. */ | /* We cannot be requesting the parent directory of the root node. */ | ||||
MPASS(IMPLIES(dnode->tn_type == VDIR && | MPASS(IMPLIES(dnode->tn_type == VDIR && | ||||
dnode->tn_dir.tn_parent == dnode, | dnode->tn_dir.tn_parent == dnode, | ||||
!(cnp->cn_flags & ISDOTDOT))); | !(cnp->cn_flags & ISDOTDOT))); | ||||
kib: Instead of adding cached param, you can move vn_dir_check_exec() into tmpfs_lookup(). | |||||
TMPFS_ASSERT_LOCKED(dnode); | TMPFS_ASSERT_LOCKED(dnode); | ||||
if (dnode->tn_dir.tn_parent == NULL) { | if (dnode->tn_dir.tn_parent == NULL) { | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
if (cnp->cn_flags & ISDOTDOT) { | if (cnp->cn_flags & ISDOTDOT) { | ||||
tm = VFS_TO_TMPFS(dvp->v_mount); | tm = VFS_TO_TMPFS(dvp->v_mount); | ||||
pnode = dnode->tn_dir.tn_parent; | pnode = dnode->tn_dir.tn_parent; | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp)); | return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp)); | ||||
} | } | ||||
static int | static int | ||||
tmpfs_lookup(struct vop_lookup_args *v) | tmpfs_lookup(struct vop_lookup_args *v) | ||||
{ | { | ||||
struct vnode *dvp = v->a_dvp; | |||||
struct vnode **vpp = v->a_vpp; | |||||
struct componentname *cnp = v->a_cnp; | |||||
int error; | |||||
return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp)); | /* Check accessibility of requested node as a first step. */ | ||||
error = vn_dir_check_exec(dvp, cnp); | |||||
if (error != 0) | |||||
return (error); | |||||
return (tmpfs_lookup1(dvp, vpp, cnp)); | |||||
} | } | ||||
static int | static int | ||||
tmpfs_create(struct vop_create_args *v) | tmpfs_create(struct vop_create_args *v) | ||||
{ | { | ||||
struct vnode *dvp = v->a_dvp; | struct vnode *dvp = v->a_dvp; | ||||
struct vnode **vpp = v->a_vpp; | struct vnode **vpp = v->a_vpp; | ||||
struct componentname *cnp = v->a_cnp; | struct componentname *cnp = v->a_cnp; | ||||
▲ Show 20 Lines • Show All 1,622 Lines • Show Last 20 Lines |
Instead of adding cached param, you can move vn_dir_check_exec() into tmpfs_lookup().