xref: /dragonfly/share/man/man9/vn_fullpath.9 (revision 5dfd06ac)
1.\"
2.\" Copyright (c) 2004 The DragonFly Project.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to The DragonFly Project
5.\" by Hiten Pandya <hmp@backplane.com>.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in
15.\"    the documentation and/or other materials provided with the
16.\"    distribution.
17.\" 3. Neither the name of The DragonFly Project nor the names of its
18.\"    contributors may be used to endorse or promote products derived
19.\"    from this software without specific, prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" Copyright (c) 2003 Robert N. M. Watson.
35.\" All rights reserved.
36.\"
37.\" Redistribution and use in source and binary forms, with or without
38.\" modification, are permitted provided that the following conditions
39.\" are met:
40.\" 1. Redistributions of source code must retain the above copyright
41.\"    notice(s), this list of conditions and the following disclaimer as
42.\"    the first lines of this file unmodified other than the possible
43.\"    addition of one or more copyright notices.
44.\" 2. Redistributions in binary form must reproduce the above copyright
45.\"    notice(s), this list of conditions and the following disclaimer in the
46.\"    documentation and/or other materials provided with the distribution.
47.\"
48.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
49.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
52.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
58.\" DAMAGE.
59.\"
60.\" $FreeBSD: src/share/man/man9/vn_fullpath.9,v 1.2 2004/01/11 19:57:42 rwatson Exp $
61.\" $DragonFly: src/share/man/man9/vn_fullpath.9,v 1.4 2006/10/30 13:47:59 swildner Exp $
62.\"
63.Dd June 03, 2004
64.Dt VN_FULLPATH 9
65.Os
66.Sh NAME
67.Nm vn_fullpath
68.Nd construct a pathname by inspecting a vnode's namecache topology
69.Sh SYNOPSIS
70.In sys/param.h
71.In sys/vnode.h
72.Ft int
73.Fn vn_fullpath "struct proc *p" "struct vnode *vp" "char **retbuf" "char **freebuf"
74.Sh DESCRIPTION
75The
76.Nm
77function makes an attempt to generate a string pathname with the
78passed-in vnode,
79.Fa vp .
80The returned path in
81.Fa retbuf
82will be relative to the root directory of the process associated with the
83.Fa p
84argument.
85.Pp
86Its arguments are:
87.Bl -tag -width freebuf
88.It Fa p
89The process performing the call; this pointer will be dereferenced to find
90the process and its file descriptor structure, in order to identify the
91root vnode to use.
92.It Fa vp
93The vnode for constructing the pathname; the vnode is used for enumerating
94its namecache topology.
95If
96.Dv NULL
97is supplied, then it is assumed that the client wants to use the
98vnode of the process image, i.e.,
99.Po
100.Va p->p_textvp
101.Pc .
102.It Fa retbuf [out]
103Pointer address to a
104.Va "char *"
105which
106.Nm
107uses for storing the address to a newly allocated buffer, containing the
108constructed pathname.
109.It Fa freebuf
110Auxiliary buffer that is used to by
111.Nm
112for temporary purposes.
113.El
114.Pp
115Typical consumers will declare two character pointers: fullpath and
116freepath; they will set freepath to
117.Dv NULL ,
118and fullpath to a name to use
119in the event that the call to
120.Nm
121fails.
122After done with the value of fullpath, the caller will check if freepath
123is non-NULL, and if so, invoke
124.Xr kfree 9
125with a malloc type of
126.Dv M_TEMP .
127.Sh RETURN VALUES
128If the vnode can be successfully used to construct a pathname,
129.Ql 0
130is returned, otherwise an
131.Li errno
132value is returned.
133.Sh CODE REFERENCES
134All file references in this section are relative to the
135.Dx
136base source directory.
137.Pp
138The
139.Ql "Resident Executables"
140code utilizes the
141.Nm
142function;
143.Pa sys/kern/imgact_resident.c .
144.Sh SEE ALSO
145.Xr kfree 9 ,
146.Xr vnode 9
147.Sh AUTHORS
148.An -nosplit
149This manual page was written by
150.An Robert Watson Aq rwatson@FreeBSD.org
151and adapted for
152.Dx
153by
154.An Hiten Pandya Aq hmp@backplane.com .
155