xref: /netbsd/lib/libc/sys/getvfsstat.2 (revision 398f7984)
1.\"	$NetBSD: getvfsstat.2,v 1.4 2021/03/27 23:35:37 dholland Exp $
2.\"
3.\" Copyright (c) 1989, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)getvfsstat.2	8.3 (Berkeley) 5/25/95
31.\"
32.Dd March 27, 2021
33.Dt GETVFSSTAT 2
34.Os
35.Sh NAME
36.Nm getvfsstat
37.Nd get list of all mounted file systems
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In sys/types.h
42.In sys/statvfs.h
43.Ft int
44.Fn getvfsstat "struct statvfs *buf" "size_t bufsize" "int flags"
45.Sh DESCRIPTION
46.Fn getvfsstat
47returns information about all mounted file systems.
48.Fa buf
49is a pointer to an array of
50.Nm statvfs
51structures defined in
52.Xr statvfs 5 .
53.Pp
54The buffer is filled with an array of
55.Fa statvfs
56structures, one for each mounted file system
57up to the size specified by
58.Fa bufsize .
59.Pp
60If
61.Fa buf
62is given as
63.Dv NULL ,
64.Fn getvfsstat
65returns just the number of mounted file systems.
66.Pp
67Normally
68.Fa flags
69should be specified as
70.Dv ST_WAIT .
71If
72.Fa flags
73is set to
74.Dv ST_NOWAIT ,
75.Fn getvfsstat
76will return the information it has available without requesting
77an update from each file system.
78Thus, some of the information will be out of date, but
79.Fn getvfsstat
80will not block waiting for information from a file system that is
81unable to respond.
82.Pp
83Note that
84.Fa bufsize
85is the size of the buffer in bytes, not the count of structures that
86will fit in it, and the return value is the count of structures, not
87the size.
88.Sh RETURN VALUES
89Upon successful completion, the number of
90.Fa statvfs
91structures is returned.
92Otherwise, \-1 is returned and the global variable
93.Va errno
94is set to indicate the error.
95.Sh ERRORS
96.Fn getvfsstat
97fails if one or more of the following are true:
98.Bl -tag -width Er
99.It Bq Er EFAULT
100.Fa buf
101points to an invalid address.
102.It Bq Er EIO
103An
104.Tn I/O
105error occurred while reading from or writing to the file system.
106.El
107.Sh SEE ALSO
108.Xr statvfs 2 ,
109.Xr getmntinfo 3 ,
110.Xr fstab 5 ,
111.Xr mount 8
112.Sh HISTORY
113The
114.Fn getvfsstat
115function first appeared in
116.Nx 3.0
117to replace
118.Fn getfsstat
119which appeared in
120.Bx 4.4 .
121