1 .\" Copyright (c) 1996 Doug Rabson
3 .\" All rights reserved.
5 .\" This program is free software.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\" $FreeBSD: src/share/man/man9/VOP_LOOKUP.9,v 1.8.2.5 2001/12/17 11:30:18 ru Exp $
34 .Nd lookup a component of a pathname
40 .Fn VOP_OLD_LOOKUP "struct vnode *dvp" "struct vnode **vpp" "struct componentname *cnp"
42 This entry point looks up a single pathname component in a given directory.
47 the locked vnode of the directory to search
49 the address of a variable where the resulting locked vnode should be stored
51 the pathname component to be searched for
55 is a pointer to a componentname structure defined as follows:
57 struct componentname {
59 * Arguments to lookup.
61 u_long cn_nameiop; /* namei operation */
62 u_long cn_flags; /* flags to namei */
63 struct thread *cn_td; /* process requesting lookup */
64 struct ucred *cn_cred; /* credentials */
66 * Shared between lookup and commit routines.
68 char *cn_nameptr; /* pointer to looked up name */
69 long cn_namelen; /* length of looked up component */
70 long cn_consume; /* chars to consume in lookup() */
71 int cn_timeout; /* if CNP_CACHETIMEOUT is set, in ticks */
72 struct vnode *cn_notvp; /* used by NFS to check for collision */
76 Convert a component of a pathname into a pointer to a locked vnode.
77 This is a very central and rather complicated routine.
78 If the file system is not maintained in a strict tree hierarchy,
79 this can result in a deadlock situation.
89 depending on the intended use of the object.
95 is specified, information usable in
96 creating, renaming, or deleting a directory entry may be calculated.
98 Overall outline of VOP_LOOKUP:
99 .Bd -ragged -offset indent
100 Check accessibility of directory.
101 Look for name in cache, if found, then return name.
102 Search for name in directory, goto to found or notfound as appropriate.
106 .Bd -ragged -offset indent
107 If creating or renaming and at end of pathname,
110 leaving info on available slots else return
115 .Bd -ragged -offset indent
116 If at end of path and deleting, return information to allow delete.
117 If at end of path and renaming, lock target
118 inode and return info to allow rename.
119 If not at end, add name to cache; if at end and neither creating
120 nor deleting, add name to cache.
125 should be locked on entry.
126 If an error (note: the return value
128 is not considered an error)
129 is detected, it will be returned locked.
130 Otherwise, it will be unlocked unless
134 If an entry is found in the directory, it will be returned locked.
136 Zero is returned with
138 set to the locked vnode of the file if the component is found.
139 If the component being searched for is ".", then the vnode just has
140 an extra reference added to it with
142 The caller must take care to release the locks appropriately in this
145 If the component is not found and the operation is
149 the special return value
152 Otherwise, an appropriate error code is returned.
158 does not represent a directory.
162 was not found in this directory.
164 access for the specified operation is denied.
165 .It Bq Er EJUSTRETURN
170 operation would be successful
175 .Xr VOP_OLD_CREATE 9 ,
176 .Xr VOP_OLD_MKDIR 9 ,
177 .Xr VOP_OLD_MKNOD 9 ,
178 .Xr VOP_OLD_RENAME 9 ,
179 .Xr VOP_OLD_SYMLINK 9
186 This man page was written by
188 with some text from comments in
189 .Pa sys/vfs/ufs/ufs_lookup.c .