xref: /freebsd/share/man/man9/namei.9 (revision 0640d357f29fb1c0daaaffadd0416c5981413afd)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 1998 Eivind Eklund
4.\"
5.\" All rights reserved.
6.\"
7.\" This program is free software.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
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.
17.\"
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.
28.\"
29.\"
30.\" If you integrate this manpage in another OS, I'd appreciate a note
31.\"	- eivind@freebsd.org
32.\"
33.\" $Id$
34.\"
35.Dd September 26th, 1998
36.Os
37.Dt namei 9
38.Sh NAME
39.Nm namei ,
40.Nm NDINIT
41.Nd convert pathname to a pointer to a locked vnode.
42.Sh SYNOPSIS
43.Ft int
44.Fn namei "struct nameidata *ndp"
45.Ft void
46.Fn NDINIT "struct nameidata *ndp" "int operation" "int operflags" "int segflag" "const char *path" "struct proc *proc"
47
48.Sh DESCRIPTION
49
50.Fn namei
51is used to get from a pathname to a vnode for the object.
52This is a necessity to start doing VFS operations.  The vnode
53returned will have its reference count increased; when you're through
54with it, you have to release it using either
55.Xr vrele 9
56or
57.Xr vput 9 ,
58depending on whether you specified the LOCKLEAF flag or not.
59.Pp
60To initialize the nameidata struct, you usually use
61.Fn NDINIT .
62It takes the following arguments:
63.Pp
64.Bl -tag -width nameidatap
65.It Ar nameidatap
66pointer to the struct nameidata to initialize
67.It Ar operation
68The operation to have
69.Fn namei
70do.  The relevant operations are
71.Dv LOOKUP ,
72.Dv CREATE ,
73.Dv DELETE ,
74and
75.Dv RENAME .
76The latter three are just setup for those
77effects; just calling
78.Fn namei
79will not result in
80.Fn VOP_RENAME
81being called.
82.It Ar operflags
83Operation flags.  Several of these can be effective at the same time.
84.It Ar segflag
85Segment indicator.  This tells if the name of the object is in
86userspace (UIO_USERSPACE) or in the kernel address space (UIO_SYSSPACE).
87.It Ar path
88Pointer to pathname buffer (the file or directory name that will be
89looked up)
90.It Ar proc
91Which process context to use for the
92.Fn namei
93locks.
94.El
95.Sh NAMEI OPERATION FLAGS
96.Fn namei
97takes the following set of 'operation flags' that influence
98how it operates:
99.Bl -tag -width WANTPARENT
100.It Dv LOCKLEAF
101Lock inode on return.  This is a full lock of the vnode; you'll have to use
102.Xr VOP_UNLOCK 9
103to release the lock (or use
104.Xr vput 9
105to release the lock and do a
106.Xr vrele 9 ,
107all in one).
108.It Dv LOCKPARENT
109Make
110.Fn namei
111also return the parent (directory) vnode (in ndp->dvp),
112in locked state.  Remember to release it (using
113.Xr vput 9
114or
115.Xr VOP_UNLOCK 9
116and
117.Xr vrele 9 .)
118.It Dv WANTPARENT
119Make
120.Fn namei
121also return the parent (directory) vnode, in unlocked
122state.  Remember to release it (using
123.Xr vrele 9 .)
124.It Dv NOCACHE
125Avoid
126.Fn namei
127creating this entry in the namecache if it is not
128already present.  Normally
129.Fn namei
130will add entries to the name cache
131if they're not already there.
132.It Dv FOLLOW
133With this flag,
134.Fn namei
135will follow the symbolic link if the last part
136of the path supplied is a symbolic link (i.e., it will return a vnode
137for whatever the link points at, instead for the link itself).
138.It Dv NOOBJ
139Do not call
140.Fn vfs_object_create
141for the returned vnode even if it is
142just a VREG and we're able to (ie, it is locked).
143.It Dv NOFOLLOW
144Do not follow symbolic links (pseudo).  This flag does not seem to be
145honoured by the actual code.
146.El
147.Sh BUGS
148.Fn namei
149calls
150.Fn lookup
151for each component in the pathname, instead of
152handing the actual names onwards to the stacking layers.  This hinders
153the implementation of stacking layers that do full namespace escapes.
154.Sh SEE ALSO
155.Xr vnode 9 ,
156.Xr VFS 9 ,
157src/sys/kern/vfs_lookup.c
158.Sh AUTHORS
159This man page was written by
160.An Eivind Eklund .
161