FreeBSD/sys/kern/vfs_cache.c
/*
 * Perform canonical checks and cache lookup and pass on to filesystem
 * through the vop_cachedlookup only if needed.
 */
Perform canonical checks and cache lookup and pass on to filesystem
through the vop_cachedlookup only if needed.
Perform canonical checks and cache lookup and pass on to filesystem through the vop_cachedlookup only if needed .
int
vfs_cache_lookup(struct vop_lookup_args *ap)
{
	struct vnode *dvp;
	int error;
	struct vnode **vpp = ap->a_vpp;
	struct componentname *cnp = ap->a_cnp;
	struct ucred *cred = cnp->cn_cred;
	int flags = cnp->cn_flags;
	struct thread *td = cnp->cn_thread;
	*vpp = NULL;
	dvp = ap->a_dvp;
	if (dvp->v_type != VDIR)
		return (ENOTDIR);
	if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
		return (EROFS);
	error = VOP_ACCESS(dvp, VEXEC, cred, td);
	if (error)
		return (error);
	error = cache_lookup(dvp, vpp, cnp, NULL, NULL);
	if (error == 0)
		return (VOP_CACHEDLOOKUP(dvp, vpp, cnp));
	if (error == -1)
		return (0);
	return (error);
}
int vfs_cache_lookup ( struct vop_lookup_args * ap ) { struct vnode * dvp ; int error ; struct vnode * * vpp = ap -> a_vpp ; struct componentname * cnp = ap -> a_cnp ; struct ucred * cred = cnp -> cn_cred ; int flags = cnp -> cn_flags ; struct thread * td = cnp -> cn_thread ; * vpp = NULL ; dvp = ap -> a_dvp ; if ( dvp -> v_type != VDIR ) return ( ENOTDIR ) ; if ( ( flags & ISLASTCN ) && ( dvp -> v_mount -> mnt_flag & MNT_RDONLY ) && ( cnp -> cn_nameiop == DELETE || cnp -> cn_nameiop == RENAME ) ) return ( EROFS ) ; error = VOP_ACCESS ( dvp , VEXEC , cred , td ) ; if ( error ) return ( error ) ; error = cache_lookup ( dvp , vpp , cnp , NULL , NULL ) ; if ( error == 0 ) return ( VOP_CACHEDLOOKUP ( dvp , vpp , cnp ) ) ; if ( error == -1 ) return ( 0 ) ; return ( error ) ; }
Perform canonical checks and cache lookup and pass on to filesystem
 through the vop_cachedlookup only if needed.
Perform canonical checks and cache lookup and pass on to filesystem through the vop_cachedlookup only if needed .