Main index | Section 9 | 日本語 | Options |
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/namei.h>
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.
It 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_thread; /* thread requesting lookup */ struct ucred *cn_cred; /* credentials */ int cn_lkflags; /* Lock flags LK_EXCLUSIVE or LK_SHARED */ /* * Shared between lookup and commit routines. */ char *cn_pnbuf; /* pathname buffer */ char *cn_nameptr; /* pointer to looked up name */ long cn_namelen; /* length of looked up component */ }; 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 LOOKUP, CREATE, RENAME, or DELETE depending on the intended use of the object. When CREATE, RENAME, or 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. | |
If the component is not found and the operation is CREATE or RENAME, the flag ISLASTCN is specified and the operation would succeed, the special return value EJUSTRETURN is returned. Otherwise, an appropriate error code is returned.
[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 CREATE or RENAME operation would be successful. | |
VOP_LOOKUP (9) | August 8, 2018 |
Main index | Section 9 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | "I liken starting one's computing career with Unix, say as an undergraduate, to being born in East Africa. It is intolerably hot, your body is covered with lice and flies, you are malnourished and you suffer from numerous curable diseases. But, as far as young East Africans can tell, this is simply the natural condition and they live within it. By the time they find out differently, it is too late. They already think that the writing of shell scripts is a natural act." | ” |
— Ken Pier, Xerox PARC |