Merge branch 'vendor/BINUTILS221'
[dragonfly.git] / lib / libc / gen / getmntinfo.3
1 .\" Copyright (c) 1989, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)getmntinfo.3        8.1 (Berkeley) 6/9/93
33 .\" $FreeBSD: src/lib/libc/gen/getmntinfo.3,v 1.8.2.4 2003/03/13 18:05:37 trhodes Exp $
34 .\"
35 .Dd April 1, 2011
36 .Dt GETMNTINFO 3
37 .Os
38 .Sh NAME
39 .Nm getmntinfo ,
40 .Nm getmntvinfo
41 .Nd get information about mounted file systems
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In sys/param.h
46 .In sys/ucred.h
47 .In sys/mount.h
48 .Ft int
49 .Fn getmntinfo "struct statfs **mntbufp" "int flags"
50 .Ft int
51 .Fn getmntvinfo "struct statfs **mntbufp" "struct statvfs **mntvbufp" "int flags"
52 .Sh DESCRIPTION
53 The
54 .Fn getmntinfo
55 function
56 returns an array of
57 .Fn statfs
58 structures describing each currently mounted file system (see
59 .Xr statfs 2 ) .
60 .Pp
61 The
62 .Fn getmntinfo
63 function
64 passes its
65 .Fa flags
66 argument transparently to
67 .Xr getfsstat 2 .
68 .Pp
69 The
70 .Fn getmntvinfo
71 function
72 returns an array of
73 .Vt statfs
74 and
75 .Vt statvfs
76 structures describing each currently mounted file system (see
77 .Xr statfs 2 ) ,
78 and otherwise works like
79 .Fn getmntinfo .
80 .Sh RETURN VALUES
81 On successful completion,
82 .Fn getmntinfo
83 returns a count of the number of elements in the array.
84 The pointer to the array is stored into
85 .Fa mntbufp .
86 .Pp
87 If an error occurs, zero is returned and the external variable
88 .Va errno
89 is set to indicate the error.
90 Although the pointer
91 .Fa mntbufp
92 will be unmodified, any information previously returned by
93 .Fn getmntinfo
94 will be lost.
95 .Pp
96 The
97 .Fn getmntvinfo
98 function
99 additionally stores the pointer to the
100 .Vt statvfs
101 array into
102 .Fa mntvbufp .
103 .Sh ERRORS
104 The
105 .Fn getmntinfo
106 and
107 .Fn getmntvinfo
108 functions may fail and set
109 .Va errno
110 for any of the errors specified for the library routines
111 .Xr getfsstat 2 ,
112 .Xr getvfsstat 2
113 or
114 .Xr malloc 3 .
115 .Sh SEE ALSO
116 .Xr getfsstat 2 ,
117 .Xr getvfsstat 2 ,
118 .Xr mount 2 ,
119 .Xr statfs 2 ,
120 .Xr mount 8
121 .Sh HISTORY
122 The
123 .Fn getmntinfo
124 function first appeared in
125 .Bx 4.4 .
126 .Pp
127 The
128 .Fn getmntvinfo
129 function first appeared in
130 .Dx 1.13 .
131 .Sh BUGS
132 The
133 .Fn getmntinfo
134 and
135 .Fn getmntvinfo
136 functions write the array of structures to an internal static object
137 and returns
138 a pointer to that object.
139 Subsequent calls to
140 .Fn getmntinfo
141 or
142 .Fn getmntvinfo
143 will modify the same object.
144 .Pp
145 The memory allocated by
146 .Fn getmntinfo
147 or
148 .Fn getmntvinfo
149 cannot be
150 .Xr free 3 Ns 'd
151 by the application.