Check for a filename in a directory using the VFS name cache.
- macOS 10.4+
Directory in which lookup is occurring.
Destination for vnode pointer.
Various data about lookup, e.g. filename and intended operation.
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.
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).