cache_lookup
Check for a filename in a directory using the VFS name cache.
Declaration
int cache_lookup(vnode_t dvp, vnode_t *vpp, struct componentname *cnp);Parameters
- dvp:
Directory in which lookup is occurring.
- vpp:
Destination for vnode pointer.
- cnp:
Various data about lookup, e.g. filename and intended operation.
Return Value
ENOENT: the filesystem has previously added a negative entry with cache_enter() to indicate that there is no file of the given name in "dp." -1: successfully found a cached vnode (vpp is set). 0: No data in the cache, or operation is CRETE/RENAME.
Discussion
cache_lookup() will flush negative cache entries and return 0 if the operation of the cn_nameiop is CREATE or RENAME. Often used from the filesystem during a lookup vnop. The filesystem will be called to if there is a negative cache entry for a file, so it can make sense to initially check for negative entries (and possibly lush them).
See Also
Support
nop_accessnop_advlocknop_allocatenop_blktooffnop_blockmapnop_bwritenop_closenop_copyfilenop_createnop_exchangenop_fsyncnop_getattrnop_inactivenop_ioctlnop_linknop_mkdirnop_mknodnop_mmapnop_offtoblknop_opennop_pageinnop_pageoutnop_pathconfnop_readnop_readdirnop_readdirattrnop_readlinknop_reclaimnop_removenop_renamenop_revokenop_rmdirnop_searchfsnop_selectnop_setattrnop_strategynop_symlinknop_whiteoutnop_writeerr_accesserr_advlockerr_allocateerr_blktoofferr_blockmaperr_bwriteerr_closeerr_copyfileerr_createerr_exchangeerr_fsyncerr_getattrerr_inactiveerr_ioctlerr_linkerr_mkdirerr_mknoderr_mmaperr_offtoblkerr_openerr_pageinerr_pageouterr_pathconferr_readerr_readdirerr_readdirattrerr_readlinkerr_reclaimerr_removeerr_renameerr_revokeerr_rmdirerr_searchfserr_selecterr_setattrerr_strategyerr_symlinkerr_whiteouterr_writeadvisory_readadvisory_read_extVNOP_BWRITEVNOP_FSYNCVNOP_GETXATTRVNOP_IOCTLVNOP_READVNOP_SETXATTRVNOP_STRATEGYVNOP_WRITEcache_entercache_purgecache_purge_negatives