DragonFly On-Line Manual Pages
VOP_OLD_LOOKUP(9) DragonFly Kernel Developer's Manual VOP_OLD_LOOKUP(9)
NAME
VOP_OLD_LOOKUP -- lookup a component of a pathname
SYNOPSIS
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/namei.h>
int
VOP_OLD_LOOKUP(struct vnode *dvp, struct vnode **vpp,
struct componentname *cnp);
DESCRIPTION
This entry point looks up a single pathname component in a given
directory.
Its arguments are:
dvp the locked vnode of the directory to search
vpp the address of a variable where the resulting locked vnode should be
stored
cnp the pathname component to be searched for
Cnp is a pointer to a componentname structure defined as follows:
struct componentname {
/*
* Arguments to lookup.
*/
u_long cn_nameiop; /* namei operation */
u_long cn_flags; /* flags to namei */
struct thread *cn_td; /* process requesting lookup */
struct ucred *cn_cred; /* credentials */
/*
* Shared between lookup and commit routines.
*/
char *cn_nameptr; /* pointer to looked up name */
long cn_namelen; /* length of looked up component */
long cn_consume; /* chars to consume in lookup() */
int cn_timeout; /* if CNP_CACHETIMEOUT is set, in ticks */
struct vnode *cn_notvp; /* used by NFS to check for collision */
};
Convert a component of a pathname into a pointer to a locked vnode. This
is a very central and rather complicated routine. If the file system is
not maintained in a strict tree hierarchy, this can result in a deadlock
situation.
The cnp->cn_nameiop argument is NAMEI_LOOKUP, NAMEI_CREATE, NAMEI_RENAME,
or NAMEI_DELETE depending on the intended use of the object. When
NAMEI_CREATE, NAMEI_RENAME, or NAMEI_DELETE is specified, information
usable in creating, renaming, or deleting a directory entry may be
calculated.
Overall outline of VOP_LOOKUP:
Check accessibility of directory. Look for name in cache, if
found, then return name. Search for name in directory, goto to
found or notfound as appropriate.
notfound:
If creating or renaming and at end of pathname, return EJUSTRETURN,
leaving info on available slots else return ENOENT.
found:
If at end of path and deleting, return information to allow delete.
If at end of path and renaming, lock target inode and return info
to allow rename. If not at end, add name to cache; if at end and
neither creating nor deleting, add name to cache.
LOCKS
The directory, dvp should be locked on entry. If an error (note: the
return value EJUSTRETURN is not considered an error) is detected, it will
be returned locked. Otherwise, it will be unlocked unless CNP_LOCKPARENT
is specified in cnp->cn_flags. If an entry is found in the directory, it
will be returned locked.
RETURN VALUES
Zero is returned with *vpp set to the locked vnode of the file if the
component is found. If the component being searched for is ".", then the
vnode just has an extra reference added to it with vref(9). The caller
must take care to release the locks appropriately in this case.
If the component is not found and the operation is NAMEI_CREATE or
NAMEI_RENAME the special return value EJUSTRETURN is returned.
Otherwise, an appropriate error code is returned.
ERRORS
[ENOTDIR] The vnode dvp does not represent a directory.
[ENOENT] The component dvp was not found in this directory.
[EACCES] access for the specified operation is denied.
[EJUSTRETURN] a NAMEI_CREATE or NAMEI_RENAME operation would be
successful
SEE ALSO
vnode(9), VOP_ACCESS(9), VOP_OLD_CREATE(9), VOP_OLD_MKDIR(9),
VOP_OLD_MKNOD(9), VOP_OLD_RENAME(9), VOP_OLD_SYMLINK(9)
HISTORY
The function VOP_OLD_LOOKUP appeared in 4.3BSD.
AUTHORS
This man page was written by Doug Rabson, with some text from comments in
sys/vfs/ufs/ufs_lookup.c.
DragonFly 3.9 October 13, 2014 DragonFly 3.9