3 .\" Copyright (c) 1996 Doug Rabson
5 .\" All rights reserved.
7 .\" This program is free software.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 .Nd lookup a component of a pathname
42 .Fn VOP_LOOKUP "struct vnode *dvp" "struct vnode **vpp" "struct componentname *cnp"
44 This entry point looks up a single pathname component in a given directory.
49 The locked vnode of the directory to search.
51 The address of a variable where the resulting locked vnode should be stored.
53 The pathname component to be searched for.
54 It is a pointer to a componentname structure defined as follows:
56 struct componentname {
58 * Arguments to lookup.
60 u_long cn_nameiop; /* namei operation */
61 u_long cn_flags; /* flags to namei */
62 struct thread *cn_thread; /* thread requesting lookup */
63 struct ucred *cn_cred; /* credentials */
64 int cn_lkflags; /* Lock flags LK_EXCLUSIVE or LK_SHARED */
66 * Shared between lookup and commit routines.
68 char *cn_pnbuf; /* pathname buffer */
69 char *cn_nameptr; /* pointer to looked up name */
70 long cn_namelen; /* length of looked up component */
74 Convert a component of a pathname into a pointer to a locked vnode.
75 This is a very central and rather complicated routine.
76 If the file system is not maintained in a strict tree hierarchy,
77 this can result in a deadlock situation.
87 depending on the intended use of the object.
93 is specified, information usable in
94 creating, renaming, or deleting a directory entry may be calculated.
96 Overall outline of VOP_LOOKUP:
97 .Bd -ragged -offset indent
98 Check accessibility of directory.
99 Look for name in cache, if found, then return name.
100 Search for name in directory, goto to found or notfound as appropriate.
104 .Bd -ragged -offset indent
105 If creating or renaming and at end of pathname,
108 leaving info on available slots else return
113 .Bd -ragged -offset indent
114 If at end of path and deleting, return information to allow delete.
115 If at end of path and renaming, lock target
116 inode and return info to allow rename.
117 If not at end, add name to cache; if at end and neither creating
118 nor deleting, add name to cache.
123 should be locked on entry and exit, regardless of error condition.
124 If an entry is found in the directory, it will be returned locked.
126 Zero is returned with
128 set to the locked vnode of the file if the component is found.
129 If the component being searched for is ".", then the vnode just has
130 an extra reference added to it with
132 The caller must take care to release the locks appropriately in this
135 If the component is not found and the operation is
141 is specified and the operation would succeed, the special return value
144 Otherwise, an appropriate error code is returned.
150 does not represent a directory.
154 was not found in this directory.
156 Access for the specified operation is denied.
157 .It Bq Er EJUSTRETURN
162 operation would be successful.
178 This manual page was written by
180 with some text from comments in