xref: /dragonfly/lib/libc/gen/getmntinfo.3 (revision 77b0c609)
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
53The
54.Fn getmntinfo
55function
56returns an array of
57.Fn statfs
58structures describing each currently mounted file system (see
59.Xr statfs 2 ) .
60.Pp
61The
62.Fn getmntinfo
63function
64passes its
65.Fa flags
66argument transparently to
67.Xr getfsstat 2 .
68.Pp
69The
70.Fn getmntvinfo
71function
72returns an array of
73.Vt statfs
74and
75.Vt statvfs
76structures describing each currently mounted file system (see
77.Xr statfs 2 ) ,
78and otherwise works like
79.Fn getmntinfo .
80.Sh RETURN VALUES
81On successful completion,
82.Fn getmntinfo
83returns a count of the number of elements in the array.
84The pointer to the array is stored into
85.Fa mntbufp .
86.Pp
87If an error occurs, zero is returned and the external variable
88.Va errno
89is set to indicate the error.
90Although the pointer
91.Fa mntbufp
92will be unmodified, any information previously returned by
93.Fn getmntinfo
94will be lost.
95.Pp
96The
97.Fn getmntvinfo
98function
99additionally stores the pointer to the
100.Vt statvfs
101array into
102.Fa mntvbufp .
103.Sh ERRORS
104The
105.Fn getmntinfo
106and
107.Fn getmntvinfo
108functions may fail and set
109.Va errno
110for any of the errors specified for the library routines
111.Xr getfsstat 2 ,
112.Xr getvfsstat 2
113or
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
122The
123.Fn getmntinfo
124function first appeared in
125.Bx 4.4 .
126.Pp
127The
128.Fn getmntvinfo
129function first appeared in
130.Dx 1.13 .
131.Sh BUGS
132The
133.Fn getmntinfo
134and
135.Fn getmntvinfo
136functions write the array of structures to an internal static object
137and returns
138a pointer to that object.
139Subsequent calls to
140.Fn getmntinfo
141or
142.Fn getmntvinfo
143will modify the same object.
144.Pp
145The memory allocated by
146.Fn getmntinfo
147or
148.Fn getmntvinfo
149cannot be
150.Xr free 3 Ns 'd
151by the application.
152