]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/vn_fullpath.9
disk(9): Fix a few mandoc related errors
[FreeBSD/FreeBSD.git] / share / man / man9 / vn_fullpath.9
1 .\"
2 .\" Copyright (c) 2003 Robert N. M. Watson.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice(s), this list of conditions and the following disclaimer as
10 .\"    the first lines of this file unmodified other than the possible
11 .\"    addition of one or more copyright notices.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice(s), this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 .\" DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd November 23, 2008
31 .Dt VN_FULLPATH 9
32 .Os
33 .Sh NAME
34 .Nm vn_fullpath
35 .Nd "convert a vnode reference to a full pathname, given a process context"
36 .Sh SYNOPSIS
37 .In sys/param.h
38 .In sys/vnode.h
39 .Ft int
40 .Fo vn_fullpath
41 .Fa "struct thread *td" "struct vnode *vp" "char **retbuf" "char **freebuf"
42 .Fc
43 .Sh DESCRIPTION
44 The
45 .Fn vn_fullpath
46 function makes a
47 .Dq "best effort"
48 attempt to generate a string pathname for
49 the passed vnode; the resulting path, if any, will be relative to
50 the root directory of the process associated with the passed thread pointer.
51 The
52 .Fn vn_fullpath
53 function
54 is implemented by inspecting the VFS name cache, and attempting to
55 reconstruct a path from the process root to the object.
56 .Pp
57 This process is necessarily unreliable for several reasons: intermediate
58 entries in the path may not be found in the cache; files may have more
59 than one name (hard links), not all file systems use the name cache
60 (specifically, most synthetic file systems do not); a single name may
61 be used for more than one file (in the context of file systems covering
62 other file systems); a file may have no name (if deleted but still
63 open or referenced).
64 However, the resulting string may still be more useable to a user than
65 a vnode pointer value, or a device number and inode number.
66 Code consuming the results of this function should anticipate (and
67 properly handle) failure.
68 .Pp
69 Its arguments are:
70 .Bl -tag -width ".Fa freebuf"
71 .It Fa td
72 The thread performing the call; this pointer will be dereferenced to find
73 the process and its file descriptor structure, in order to identify the
74 root vnode to use.
75 .It Fa vp
76 The vnode to search for.
77 No need to be locked by the caller.
78 .It Fa retbuf
79 Pointer to a
80 .Vt "char *"
81 that
82 .Fn vn_fullpath
83 may (on success) point at a newly
84 allocated buffer containing the resulting pathname.
85 .It Fa freebuf
86 Pointer to a
87 .Vt "char *"
88 that
89 .Fn vn_fullpath
90 may (on success) point at a buffer
91 to be freed, when the caller is done with
92 .Fa retbuf .
93 .El
94 .Pp
95 Typical consumers will declare two character pointers:
96 .Va fullpath
97 and
98 .Va freepath ;
99 they will set
100 .Va freepath
101 to
102 .Dv NULL ,
103 and
104 .Va fullpath
105 to a name to use
106 in the event that the call to
107 .Fn vn_fullpath
108 fails.
109 After done with the value of
110 .Va fullpath ,
111 the caller will check if
112 .Va freepath
113 is
114 .Pf non- Dv NULL ,
115 and if so, invoke
116 .Xr free 9
117 with a pool type of
118 .Dv M_TEMP .
119 .Sh RETURN VALUES
120 If the vnode is successfully converted to a pathname, 0 is returned;
121 otherwise, an error number is returned.
122 .Sh SEE ALSO
123 .Xr free 9
124 .Sh AUTHORS
125 This manual page was written by
126 .An Robert Watson Aq Mt rwatson@FreeBSD.org .