1c78f3f0dSEivind Eklund.\" -*- nroff -*- 2c78f3f0dSEivind Eklund.\" 3c78f3f0dSEivind Eklund.\" Copyright (c) 1998 Eivind Eklund 4c78f3f0dSEivind Eklund.\" 5c78f3f0dSEivind Eklund.\" All rights reserved. 6c78f3f0dSEivind Eklund.\" 7c78f3f0dSEivind Eklund.\" This program is free software. 8c78f3f0dSEivind Eklund.\" 9c78f3f0dSEivind Eklund.\" Redistribution and use in source and binary forms, with or without 10c78f3f0dSEivind Eklund.\" modification, are permitted provided that the following conditions 11c78f3f0dSEivind Eklund.\" are met: 12c78f3f0dSEivind Eklund.\" 1. Redistributions of source code must retain the above copyright 13c78f3f0dSEivind Eklund.\" notice, this list of conditions and the following disclaimer. 14c78f3f0dSEivind Eklund.\" 2. Redistributions in binary form must reproduce the above copyright 15c78f3f0dSEivind Eklund.\" notice, this list of conditions and the following disclaimer in the 16c78f3f0dSEivind Eklund.\" documentation and/or other materials provided with the distribution. 17c78f3f0dSEivind Eklund.\" 18c78f3f0dSEivind Eklund.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 19c78f3f0dSEivind Eklund.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20c78f3f0dSEivind Eklund.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21c78f3f0dSEivind Eklund.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 22c78f3f0dSEivind Eklund.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23c78f3f0dSEivind Eklund.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24c78f3f0dSEivind Eklund.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25c78f3f0dSEivind Eklund.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26c78f3f0dSEivind Eklund.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27c78f3f0dSEivind Eklund.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28c78f3f0dSEivind Eklund.\" 29c78f3f0dSEivind Eklund.\" 30c78f3f0dSEivind Eklund.\" If you integrate this manpage in another OS, I'd appreciate a note 31c78f3f0dSEivind Eklund.\" - eivind@freebsd.org 32c78f3f0dSEivind Eklund.\" 337f3dea24SPeter Wemm.\" $FreeBSD$ 34c78f3f0dSEivind Eklund.\" 35c78f3f0dSEivind Eklund.Dd September 26th, 1998 36c78f3f0dSEivind Eklund.Os 37def37e7cSMike Pritchard.Dt NAMEI 9 38c78f3f0dSEivind Eklund.Sh NAME 39c78f3f0dSEivind Eklund.Nm namei , 40c78f3f0dSEivind Eklund.Nm NDINIT 41c78f3f0dSEivind Eklund.Nd convert pathname to a pointer to a locked vnode. 42c78f3f0dSEivind Eklund.Sh SYNOPSIS 436232b00eSBruce Evans.Fd #include <sys/types.h> 446232b00eSBruce Evans.Fd #include <sys/namei.h> 45c78f3f0dSEivind Eklund.Ft int 46c78f3f0dSEivind Eklund.Fn namei "struct nameidata *ndp" 47c78f3f0dSEivind Eklund.Ft void 48c78f3f0dSEivind Eklund.Fn NDINIT "struct nameidata *ndp" "int operation" "int operflags" "int segflag" "const char *path" "struct proc *proc" 49c78f3f0dSEivind Eklund 50c78f3f0dSEivind Eklund.Sh DESCRIPTION 51c78f3f0dSEivind Eklund 52c78f3f0dSEivind Eklund.Fn namei 53c78f3f0dSEivind Eklundis used to get from a pathname to a vnode for the object. 54c78f3f0dSEivind EklundThis is a necessity to start doing VFS operations. The vnode 55c78f3f0dSEivind Eklundreturned will have its reference count increased; when you're through 56c78f3f0dSEivind Eklundwith it, you have to release it using either 57c78f3f0dSEivind Eklund.Xr vrele 9 58c78f3f0dSEivind Eklundor 59c78f3f0dSEivind Eklund.Xr vput 9 , 60c78f3f0dSEivind Eklunddepending on whether you specified the LOCKLEAF flag or not. 61c78f3f0dSEivind Eklund.Pp 62c78f3f0dSEivind EklundTo initialize the nameidata struct, you usually use 63c78f3f0dSEivind Eklund.Fn NDINIT . 64c78f3f0dSEivind EklundIt takes the following arguments: 65c78f3f0dSEivind Eklund.Pp 66c78f3f0dSEivind Eklund.Bl -tag -width nameidatap 67c78f3f0dSEivind Eklund.It Ar nameidatap 68c78f3f0dSEivind Eklundpointer to the struct nameidata to initialize 69c78f3f0dSEivind Eklund.It Ar operation 70c78f3f0dSEivind EklundThe operation to have 71c78f3f0dSEivind Eklund.Fn namei 72c78f3f0dSEivind Eklunddo. The relevant operations are 73c78f3f0dSEivind Eklund.Dv LOOKUP , 74c78f3f0dSEivind Eklund.Dv CREATE , 75c78f3f0dSEivind Eklund.Dv DELETE , 76c78f3f0dSEivind Eklundand 77c78f3f0dSEivind Eklund.Dv RENAME . 78c78f3f0dSEivind EklundThe latter three are just setup for those 79c78f3f0dSEivind Eklundeffects; just calling 80c78f3f0dSEivind Eklund.Fn namei 81c78f3f0dSEivind Eklundwill not result in 82c78f3f0dSEivind Eklund.Fn VOP_RENAME 83c78f3f0dSEivind Eklundbeing called. 84c78f3f0dSEivind Eklund.It Ar operflags 85c78f3f0dSEivind EklundOperation flags. Several of these can be effective at the same time. 86c78f3f0dSEivind Eklund.It Ar segflag 87c78f3f0dSEivind EklundSegment indicator. This tells if the name of the object is in 88c78f3f0dSEivind Eklunduserspace (UIO_USERSPACE) or in the kernel address space (UIO_SYSSPACE). 89c78f3f0dSEivind Eklund.It Ar path 90c78f3f0dSEivind EklundPointer to pathname buffer (the file or directory name that will be 91c78f3f0dSEivind Eklundlooked up) 92c78f3f0dSEivind Eklund.It Ar proc 93c78f3f0dSEivind EklundWhich process context to use for the 94c78f3f0dSEivind Eklund.Fn namei 95c78f3f0dSEivind Eklundlocks. 96c78f3f0dSEivind Eklund.El 97c78f3f0dSEivind Eklund.Sh NAMEI OPERATION FLAGS 98c78f3f0dSEivind Eklund.Fn namei 99c78f3f0dSEivind Eklundtakes the following set of 'operation flags' that influence 100c78f3f0dSEivind Eklundhow it operates: 101c78f3f0dSEivind Eklund.Bl -tag -width WANTPARENT 102c78f3f0dSEivind Eklund.It Dv LOCKLEAF 1030bf3e334SNik ClaytonLock vnode on return. This is a full lock of the vnode; you'll have to use 104c78f3f0dSEivind Eklund.Xr VOP_UNLOCK 9 105c78f3f0dSEivind Eklundto release the lock (or use 106c78f3f0dSEivind Eklund.Xr vput 9 107c78f3f0dSEivind Eklundto release the lock and do a 108c78f3f0dSEivind Eklund.Xr vrele 9 , 109c78f3f0dSEivind Eklundall in one). 110c78f3f0dSEivind Eklund.It Dv LOCKPARENT 111c78f3f0dSEivind EklundMake 112c78f3f0dSEivind Eklund.Fn namei 113c78f3f0dSEivind Eklundalso return the parent (directory) vnode (in ndp->dvp), 114c78f3f0dSEivind Eklundin locked state. Remember to release it (using 115c78f3f0dSEivind Eklund.Xr vput 9 116c78f3f0dSEivind Eklundor 117c78f3f0dSEivind Eklund.Xr VOP_UNLOCK 9 118c78f3f0dSEivind Eklundand 119c78f3f0dSEivind Eklund.Xr vrele 9 .) 120c78f3f0dSEivind Eklund.It Dv WANTPARENT 121c78f3f0dSEivind EklundMake 122c78f3f0dSEivind Eklund.Fn namei 123c78f3f0dSEivind Eklundalso return the parent (directory) vnode, in unlocked 124c78f3f0dSEivind Eklundstate. Remember to release it (using 125c78f3f0dSEivind Eklund.Xr vrele 9 .) 126c78f3f0dSEivind Eklund.It Dv NOCACHE 127c78f3f0dSEivind EklundAvoid 128c78f3f0dSEivind Eklund.Fn namei 129c78f3f0dSEivind Eklundcreating this entry in the namecache if it is not 130c78f3f0dSEivind Eklundalready present. Normally 131c78f3f0dSEivind Eklund.Fn namei 132c78f3f0dSEivind Eklundwill add entries to the name cache 133c78f3f0dSEivind Eklundif they're not already there. 134c78f3f0dSEivind Eklund.It Dv FOLLOW 135c78f3f0dSEivind EklundWith this flag, 136c78f3f0dSEivind Eklund.Fn namei 137c78f3f0dSEivind Eklundwill follow the symbolic link if the last part 138c78f3f0dSEivind Eklundof the path supplied is a symbolic link (i.e., it will return a vnode 139c78f3f0dSEivind Eklundfor whatever the link points at, instead for the link itself). 140c78f3f0dSEivind Eklund.It Dv NOOBJ 141c78f3f0dSEivind EklundDo not call 142c78f3f0dSEivind Eklund.Fn vfs_object_create 143c78f3f0dSEivind Eklundfor the returned vnode even if it is 144c78f3f0dSEivind Eklundjust a VREG and we're able to (ie, it is locked). 145c78f3f0dSEivind Eklund.It Dv NOFOLLOW 146c78f3f0dSEivind EklundDo not follow symbolic links (pseudo). This flag does not seem to be 147c78f3f0dSEivind Eklundhonoured by the actual code. 148c78f3f0dSEivind Eklund.El 149c78f3f0dSEivind Eklund.Sh BUGS 150c78f3f0dSEivind Eklund.Fn namei 151c78f3f0dSEivind Eklundcalls 152c78f3f0dSEivind Eklund.Fn lookup 153c78f3f0dSEivind Eklundfor each component in the pathname, instead of 154c78f3f0dSEivind Eklundhanding the actual names onwards to the stacking layers. This hinders 155c78f3f0dSEivind Eklundthe implementation of stacking layers that do full namespace escapes. 156c78f3f0dSEivind Eklund.Sh SEE ALSO 157c78f3f0dSEivind Eklund.Xr VFS 9 , 158def37e7cSMike Pritchard.Xr vnode 9 , 159c78f3f0dSEivind Eklundsrc/sys/kern/vfs_lookup.c 160c78f3f0dSEivind Eklund.Sh AUTHORS 161c78f3f0dSEivind EklundThis man page was written by 162c78f3f0dSEivind Eklund.An Eivind Eklund . 163