xref: /dflybsd-src/share/man/man9/vn_fullpath.9 (revision c616d3786462c4bbb32602d276dfb62c4d97ef77)
1d488fe22SHiten Pandya.\"
29cca02b8SHiten Pandya.\" Copyright (c) 2004 The DragonFly Project.  All rights reserved.
39cca02b8SHiten Pandya.\"
49cca02b8SHiten Pandya.\" This code is derived from software contributed to The DragonFly Project
59cca02b8SHiten Pandya.\" by Hiten Pandya <hmp@backplane.com>.
69cca02b8SHiten Pandya.\"
79cca02b8SHiten Pandya.\" Redistribution and use in source and binary forms, with or without
89cca02b8SHiten Pandya.\" modification, are permitted provided that the following conditions
99cca02b8SHiten Pandya.\" are met:
109cca02b8SHiten Pandya.\"
119cca02b8SHiten Pandya.\" 1. Redistributions of source code must retain the above copyright
129cca02b8SHiten Pandya.\"    notice, this list of conditions and the following disclaimer.
139cca02b8SHiten Pandya.\" 2. Redistributions in binary form must reproduce the above copyright
149cca02b8SHiten Pandya.\"    notice, this list of conditions and the following disclaimer in
159cca02b8SHiten Pandya.\"    the documentation and/or other materials provided with the
169cca02b8SHiten Pandya.\"    distribution.
179cca02b8SHiten Pandya.\" 3. Neither the name of The DragonFly Project nor the names of its
189cca02b8SHiten Pandya.\"    contributors may be used to endorse or promote products derived
199cca02b8SHiten Pandya.\"    from this software without specific, prior written permission.
209cca02b8SHiten Pandya.\"
219cca02b8SHiten Pandya.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
229cca02b8SHiten Pandya.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
239cca02b8SHiten Pandya.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
249cca02b8SHiten Pandya.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
259cca02b8SHiten Pandya.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
269cca02b8SHiten Pandya.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
279cca02b8SHiten Pandya.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
289cca02b8SHiten Pandya.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
299cca02b8SHiten Pandya.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
309cca02b8SHiten Pandya.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
319cca02b8SHiten Pandya.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
329cca02b8SHiten Pandya.\" SUCH DAMAGE.
339cca02b8SHiten Pandya.\"
34d488fe22SHiten Pandya.\" Copyright (c) 2003 Robert N. M. Watson.
35d488fe22SHiten Pandya.\" All rights reserved.
36d488fe22SHiten Pandya.\"
37d488fe22SHiten Pandya.\" Redistribution and use in source and binary forms, with or without
38d488fe22SHiten Pandya.\" modification, are permitted provided that the following conditions
39d488fe22SHiten Pandya.\" are met:
40d488fe22SHiten Pandya.\" 1. Redistributions of source code must retain the above copyright
41d488fe22SHiten Pandya.\"    notice(s), this list of conditions and the following disclaimer as
42d488fe22SHiten Pandya.\"    the first lines of this file unmodified other than the possible
43d488fe22SHiten Pandya.\"    addition of one or more copyright notices.
44d488fe22SHiten Pandya.\" 2. Redistributions in binary form must reproduce the above copyright
45d488fe22SHiten Pandya.\"    notice(s), this list of conditions and the following disclaimer in the
46d488fe22SHiten Pandya.\"    documentation and/or other materials provided with the distribution.
47d488fe22SHiten Pandya.\"
48d488fe22SHiten Pandya.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
49d488fe22SHiten Pandya.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50d488fe22SHiten Pandya.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51d488fe22SHiten Pandya.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
52d488fe22SHiten Pandya.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53d488fe22SHiten Pandya.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54d488fe22SHiten Pandya.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55d488fe22SHiten Pandya.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56d488fe22SHiten Pandya.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57d488fe22SHiten Pandya.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
58d488fe22SHiten Pandya.\" DAMAGE.
59d488fe22SHiten Pandya.\"
60d488fe22SHiten Pandya.\" $FreeBSD: src/share/man/man9/vn_fullpath.9,v 1.2 2004/01/11 19:57:42 rwatson Exp $
61d488fe22SHiten Pandya.\"
622ef98635SSascha Wildner.Dd June 3, 2004
63d488fe22SHiten Pandya.Dt VN_FULLPATH 9
64d488fe22SHiten Pandya.Os
65d488fe22SHiten Pandya.Sh NAME
66d488fe22SHiten Pandya.Nm vn_fullpath
67d488fe22SHiten Pandya.Nd construct a pathname by inspecting a vnode's namecache topology
68d488fe22SHiten Pandya.Sh SYNOPSIS
69d488fe22SHiten Pandya.In sys/param.h
70d488fe22SHiten Pandya.In sys/vnode.h
71d488fe22SHiten Pandya.Ft int
724cff892bSAlex Hornung.Fn vn_fullpath "struct proc *p" "struct vnode *vp" "char **retbuf" "char **freebuf" "int guess"
73d488fe22SHiten Pandya.Sh DESCRIPTION
74d488fe22SHiten PandyaThe
75d488fe22SHiten Pandya.Nm
76d488fe22SHiten Pandyafunction makes an attempt to generate a string pathname with the
77d488fe22SHiten Pandyapassed-in vnode,
78d488fe22SHiten Pandya.Fa vp .
79d488fe22SHiten PandyaThe returned path in
80d488fe22SHiten Pandya.Fa retbuf
81d488fe22SHiten Pandyawill be relative to the root directory of the process associated with the
82d488fe22SHiten Pandya.Fa p
83d488fe22SHiten Pandyaargument.
84d488fe22SHiten Pandya.Pp
85d488fe22SHiten PandyaIts arguments are:
86d488fe22SHiten Pandya.Bl -tag -width freebuf
87d488fe22SHiten Pandya.It Fa p
88d488fe22SHiten PandyaThe process performing the call; this pointer will be dereferenced to find
89d488fe22SHiten Pandyathe process and its file descriptor structure, in order to identify the
90d488fe22SHiten Pandyaroot vnode to use.
91d488fe22SHiten Pandya.It Fa vp
92d488fe22SHiten PandyaThe vnode for constructing the pathname; the vnode is used for enumerating
93d488fe22SHiten Pandyaits namecache topology.
94d488fe22SHiten PandyaIf
95d488fe22SHiten Pandya.Dv NULL
96d488fe22SHiten Pandyais supplied, then it is assumed that the client wants to use the
97d488fe22SHiten Pandyavnode of the process image, i.e.,
98d488fe22SHiten Pandya.Po
99d488fe22SHiten Pandya.Va p->p_textvp
100d488fe22SHiten Pandya.Pc .
101d488fe22SHiten Pandya.It Fa retbuf [out]
102d488fe22SHiten PandyaPointer address to a
103d488fe22SHiten Pandya.Va "char *"
104d488fe22SHiten Pandyawhich
105d488fe22SHiten Pandya.Nm
106d488fe22SHiten Pandyauses for storing the address to a newly allocated buffer, containing the
107d488fe22SHiten Pandyaconstructed pathname.
108d488fe22SHiten Pandya.It Fa freebuf
109d488fe22SHiten PandyaAuxiliary buffer that is used to by
110d488fe22SHiten Pandya.Nm
111d488fe22SHiten Pandyafor temporary purposes.
1124cff892bSAlex Hornung.It Fa guess
1134cff892bSAlex HornungIf guess is not 0, the mountpoint will be guessed if it can't be determined when
1144cff892bSAlex Hornungtraversing the namecache entries upwards.
115d488fe22SHiten Pandya.El
116d488fe22SHiten Pandya.Pp
117d488fe22SHiten PandyaTypical consumers will declare two character pointers: fullpath and
118d488fe22SHiten Pandyafreepath; they will set freepath to
119d488fe22SHiten Pandya.Dv NULL ,
120d488fe22SHiten Pandyaand fullpath to a name to use
121d488fe22SHiten Pandyain the event that the call to
122d488fe22SHiten Pandya.Nm
123d488fe22SHiten Pandyafails.
124d488fe22SHiten PandyaAfter done with the value of fullpath, the caller will check if freepath
125d488fe22SHiten Pandyais non-NULL, and if so, invoke
12696c4a449SSascha Wildner.Xr kfree 9
127d488fe22SHiten Pandyawith a malloc type of
128d488fe22SHiten Pandya.Dv M_TEMP .
129d488fe22SHiten Pandya.Sh RETURN VALUES
130d488fe22SHiten PandyaIf the vnode can be successfully used to construct a pathname,
131d488fe22SHiten Pandya.Ql 0
132d488fe22SHiten Pandyais returned, otherwise an
1330f09e575SSascha Wildner.Va errno
134d488fe22SHiten Pandyavalue is returned.
135d488fe22SHiten Pandya.Sh CODE REFERENCES
136d488fe22SHiten PandyaAll file references in this section are relative to the
137d488fe22SHiten Pandya.Dx
138d488fe22SHiten Pandyabase source directory.
139d488fe22SHiten Pandya.Pp
140d488fe22SHiten PandyaThe
141d488fe22SHiten Pandya.Ql "Resident Executables"
142d488fe22SHiten Pandyacode utilizes the
143d488fe22SHiten Pandya.Nm
144d488fe22SHiten Pandyafunction;
145d488fe22SHiten Pandya.Pa sys/kern/imgact_resident.c .
146d488fe22SHiten Pandya.Sh SEE ALSO
14796c4a449SSascha Wildner.Xr kfree 9 ,
148d488fe22SHiten Pandya.Xr vnode 9
149d488fe22SHiten Pandya.Sh AUTHORS
150d488fe22SHiten Pandya.An -nosplit
151d488fe22SHiten PandyaThis manual page was written by
152*c616d378SFranco Fichtner.An Robert Watson Aq Mt rwatson@FreeBSD.org
153d488fe22SHiten Pandyaand adapted for
154d488fe22SHiten Pandya.Dx
155d488fe22SHiten Pandyaby
156*c616d378SFranco Fichtner.An Hiten Pandya Aq Mt hmp@backplane.com .
157