xref: /freebsd/lib/libsys/getfsstat.2 (revision 397e83df75e0fcd0d3fcb95ae4d794cb7600fc89)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER 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
26.\" SUCH DAMAGE.
27.\"
28.Dd March 30, 2020
29.Dt GETFSSTAT 2
30.Os
31.Sh NAME
32.Nm getfsstat
33.Nd get list of all mounted file systems
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/param.h
38.In sys/ucred.h
39.In sys/mount.h
40.Ft int
41.Fn getfsstat "struct statfs *buf" "long bufsize" "int mode"
42.Sh DESCRIPTION
43The
44.Fn getfsstat
45system call
46returns information about all mounted file systems.
47The
48.Fa buf
49argument
50is a pointer to
51.Vt statfs
52structures, as described in
53.Xr statfs 2 .
54.Pp
55Fields that are undefined for a particular file system are set to -1.
56The buffer is filled with an array of
57.Fa statfs
58structures, one for each mounted file system
59up to the byte count specified by
60.Fa bufsize .
61Note, the
62.Fa bufsize
63argument is the number of bytes that
64.Fa buf
65can hold, not the count of statfs structures it will hold.
66.Pp
67If
68.Fa buf
69is given as NULL,
70.Fn getfsstat
71returns just the number of mounted file systems.
72.Pp
73Normally
74.Fa mode
75should be specified as
76.Dv MNT_WAIT .
77If
78.Fa mode
79is set to
80.Dv MNT_NOWAIT ,
81.Fn getfsstat
82will return the information it has available without requesting
83an update from each file system.
84Thus, some of the information will be out of date, but
85.Fn getfsstat
86will not block waiting for information from a file system that is
87unable to respond.
88It will also skip any file system that is in the process of being
89unmounted, even if the unmount would eventually fail.
90.Sh RETURN VALUES
91Upon successful completion, the number of
92.Fa statfs
93structures is returned.
94Otherwise, -1 is returned and the global variable
95.Va errno
96is set to indicate the error.
97.Sh ERRORS
98The
99.Fn getfsstat
100system call
101fails if one or more of the following are true:
102.Bl -tag -width Er
103.It Bq Er EFAULT
104The
105.Fa buf
106argument
107points to an invalid address.
108.It Bq Er EINVAL
109.Fa mode
110is set to a value other than
111.Dv MNT_WAIT
112or
113.Dv MNT_NOWAIT .
114.It Bq Er EIO
115An
116.Tn I/O
117error occurred while reading from or writing to the file system.
118.It Bq Er EINTEGRITY
119Corrupted data was detected while reading from the file system.
120.El
121.Sh SEE ALSO
122.Xr statfs 2 ,
123.Xr fstab 5 ,
124.Xr mount 8
125.Sh HISTORY
126The
127.Fn getfsstat
128system call first appeared in
129.Bx 4.4 .
130