2 .\" Copyright (c) 1998, 1999 Eivind Eklund
3 .\" Copyright (c) 2003 Hiten M. Pandya
4 .\" Copyright (c) 2005 Robert N. M. Watson
6 .\" All rights reserved.
8 .\" This program is free software.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
19 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
20 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .\" If you integrate this manpage in another OS, I'd appreciate a note
32 .\" - eivind@FreeBSD.org
43 .Nd pathname translation and lookup operations
49 .Fn namei "struct nameidata *ndp"
52 .Fa "struct nameidata *ndp" "u_long op" "u_long flags"
53 .Fa "enum uio_seg segflg" "const char *namep" "struct thread *td"
56 .Fn NDFREE "struct nameidata *ndp" "const uint flags"
60 facility allows the client to perform pathname translation and lookup
64 functions will increment the reference count for the vnode in question.
65 The reference count has to be decremented after use of the vnode, by
70 depending on whether the
72 flag was specified or not.
76 function is used to initialize
79 It takes the following arguments:
80 .Bl -tag -width ".Fa segflg"
83 .Vt "struct nameidata"
89 The following operations are valid:
90 .Dv LOOKUP , CREATE , DELETE ,
93 The latter three are just setup for those
101 Several of these can be effective at the same time.
103 UIO segment indicator.
104 This indicates if the name of the object is in userspace
106 or in the kernel address space
107 .Pq Dv UIO_SYSSPACE .
109 Pointer to the component's pathname buffer
110 (the file or directory name that will be looked up).
112 The thread context to use for
114 operations and locks.
116 .Sh NAMEI OPERATION FLAGS
119 function takes the following set of
120 .Dq "operation flags"
121 that influence its operation:
122 .Bl -tag -width ".Dv WANTPARENT"
124 Lock vnode on return with
132 to release the lock (or
134 which is equivalent to calling
142 function return the parent (directory) vnode,
144 in locked state, unless it is identical to
148 is not locked per se (but may be locked due to
150 If a lock is enforced, it should be released using
157 Lock vnode on return with
162 to release the lock (or
164 which is equivalent to calling
172 function to return the parent (directory) vnode in an unlocked state.
173 The parent vnode must be released separately by using
178 creating this entry in the namecache if it is not
182 will add entries to the name cache
183 if they are not already there.
187 will follow the symbolic link if the last part
188 of the path supplied is a symbolic link (i.e., it will return a vnode
189 for whatever the link points at, instead for the link itself).
191 Do not follow symbolic links (pseudo).
192 This flag is not looked for by the actual code, which looks for
195 is used to indicate to the source code reader that symlinks
196 are intentionally not followed.
198 Do not free the pathname buffer at the end of the
200 invocation; instead, free it later in
202 so that the caller may access the pathname buffer.
203 See below for details.
205 Retain an additional reference to the parent directory; do not free
207 See below for details.
209 .Sh ALLOCATED ELEMENTS
212 structure is composed of the following fields:
213 .Bl -tag -width ".Va ni_cnd.cn_pnbuf"
215 In the normal case, this is either the current directory or the root.
216 It is the current directory if the name passed in does not start with
218 and we have not gone through any symlinks with an absolute path, and
221 In this case, it is only used by
224 considered valid after a call to
228 is set, this is set to the same as
237 .Dv NDF_NO_STARTDIR_RELE
240 Vnode pointer to directory of the object on which lookup is performed.
241 This is available on successful return if
252 .Dv NDF_NO_DVP_RELE , NDF_NO_DVP_PUT ,
254 .Dv NDF_NO_DVP_UNLOCK
255 (with the obvious effects).
257 Vnode pointer to the resulting object,
262 field of this vnode is incremented.
265 is set, it is also locked.
270 .Dv NDF_NO_VP_RELE , NDF_NO_VP_PUT ,
273 (with the obvious effects).
274 .It Va ni_cnd.cn_pnbuf
275 The pathname buffer contains the location of the file or directory
276 that will be used by the
281 zone allocation interface.
286 flag is set, then the pathname buffer is available
291 To only deallocate resources used by the pathname buffer,
292 .Va ni_cnd.cn_pnbuf ,
295 flag can be passed to the
298 To keep the pathname buffer intact,
300 .Dv NDF_NO_FREE_PNBUF
301 flag can be passed to the
308 will return 0, otherwise it will return an error.
311 .It Pa src/sys/kern/vfs_lookup.c
319 A component of the specified pathname is not a directory when a directory is
321 .It Bq Er ENAMETOOLONG
322 A component of a pathname exceeded 255 characters,
323 or an entire pathname exceeded 1023 characters.
325 A component of the specified pathname does not exist,
326 or the pathname is an empty string.
328 An attempt is made to access a file in a way forbidden by its file access
331 Too many symbolic links were encountered in translating the pathname.
333 An attempt is made to open a directory with write mode specified.
335 The last component of the pathname specified for a
342 An attempt is made to modify a file or directory on a read-only file system.
353 This manual page was written by
354 .An Eivind Eklund Aq Mt eivind@FreeBSD.org
355 and later significantly revised by
356 .An Hiten M. Pandya Aq Mt hmp@FreeBSD.org .
360 flag does not always result in the parent vnode being locked.
361 This results in complications when the
364 In order to solve this for the cases where both
368 are used, it is necessary to resort to recursive locking.