xref: /dragonfly/lib/libc/sys/getfsstat.2 (revision 31524921)
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.\"	@(#)getfsstat.2	8.3 (Berkeley) 5/25/95
29.\" $FreeBSD: src/lib/libc/sys/getfsstat.2,v 1.7.2.4 2001/12/14 18:34:00 ru Exp $
30.\"
31.Dd May 25, 1995
32.Dt GETFSSTAT 2
33.Os
34.Sh NAME
35.Nm getfsstat ,
36.Nm getvfsstat
37.Nd get list of all mounted filesystems
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In sys/param.h
42.In sys/ucred.h
43.In sys/mount.h
44.Ft int
45.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags"
46.In sys/statvfs.h
47.Ft int
48.Fn getvfsstat "struct statfs *buf" "struct statvfs *vbuf" "long vbufsize" "int flags"
49.Sh DESCRIPTION
50.Fn Getfsstat
51returns information about all mounted filesystems.
52.Fa Buf
53is a pointer to
54.Vt statfs
55structures defined as follows:
56.Bd -literal
57typedef struct fsid { int32_t val[2]; } fsid_t;	/* file system id type */
58
59/*
60 * file system statistics
61 */
62
63#define MFSNAMELEN 16	/* length of fs type name, including null */
64#define MNAMELEN   80	/* length of buffer for returned name */
65
66struct statfs {
67    long    f_spare2;		/* placeholder */
68    long    f_bsize;		/* fundamental file system block size */
69    long    f_iosize;		/* optimal transfer block size */
70    long    f_blocks;		/* total data blocks in file system */
71    long    f_bfree;		/* free blocks in fs */
72    long    f_bavail;		/* free blocks avail to non-superuser */
73    long    f_files;		/* total file nodes in file system */
74    long    f_ffree;		/* free file nodes in fs */
75    fsid_t  f_fsid;		/* file system id */
76    uid_t   f_owner;		/* user that mounted the filesystem */
77    int     f_type;		/* type of filesystem (see below) */
78    int     f_flags;		/* copy of mount flags */
79    long    f_syncwrites;	/* count of sync writes since mount */
80    long    f_asyncwrites;	/* count of async writes since mount */
81    char    f_fstypename[MFSNAMELEN];/* fs type name */
82    char    f_mntonname[MNAMELEN];/* directory on which mounted */
83    long    f_syncreads;	/* count of sync reads since mount */
84    long    f_asyncreads;	/* count of async reads since mount */
85    short   f_spares1;		/* unused spare */
86    char    f_mntfromname[MNAMELEN];/* mounted filesystem */
87    short   f_spares2;		/* unused spare */
88    long    f_spare[2];		/* unused spare */
89};
90.Ed
91.Pp
92The flags that may be returned include:
93.Bl -tag -width ".Dv MNT_SYNCHRONOUS"
94.It Dv MNT_RDONLY
95The filesystem is mounted read-only;
96Even the super-user may not write on it.
97.It Dv MNT_NOEXEC
98Files may not be executed from the filesystem.
99.It Dv MNT_NOSUID
100Setuid and setgid bits on files are not honored when they are executed.
101.It Dv MNT_NODEV
102Special files in the filesystem may not be opened.
103.It Dv MNT_SYNCHRONOUS
104All I/O to the filesystem is done synchronously.
105.It Dv MNT_ASYNC
106No filesystem I/O is done synchronously.
107.It Dv MNT_LOCAL
108The filesystem resides locally.
109.It Dv MNT_QUOTA
110The filesystem has quotas enabled on it.
111.It Dv MNT_ROOTFS
112Identifies the root filesystem.
113.It Dv MNT_EXRDONLY
114The filesystem is exported read-only.
115.It Dv MNT_EXPORTED
116The filesystem is exported for both reading and writing.
117.It Dv MNT_DEFEXPORTED
118The filesystem is exported for both reading and writing to any Internet host.
119.It Dv MNT_EXPORTANON
120The filesystem maps all remote accesses to the anonymous user.
121.It Dv MNT_EXKERB
122The filesystem is exported with Kerberos uid mapping.
123.El
124.Pp
125Fields that are undefined for a particular filesystem are set to -1.
126The buffer is filled with an array of
127.Fa fsstat
128structures, one for each mounted filesystem
129up to the size specified by
130.Fa bufsize .
131.Pp
132If
133.Fa buf
134is given as NULL,
135.Fn getfsstat
136returns just the number of mounted filesystems.
137.Pp
138Normally
139.Fa flags
140should be specified as
141.Dv MNT_WAIT .
142If
143.Fa flags
144is set to
145.Dv MNT_NOWAIT ,
146.Fn getfsstat
147will return the information it has available without requesting
148an update from each filesystem.
149Thus, some of the information will be out of date, but
150.Fn getfsstat
151will not block waiting for information from a filesystem that is
152unable to respond.
153.Fn Getvfsstat
154returns extended information about all mounted filesystems.
155Note that
156.Fa vbufsize
157represents the size of
158.Fa vbuf ,
159and
160.Fa buf
161is expected to be of contemporary size for its own structures.
162.Sh RETURN VALUES
163Upon successful completion, the number of
164.Fa fsstat
165structures is returned.
166Otherwise, -1 is returned and the global variable
167.Va errno
168is set to indicate the error.
169.Sh ERRORS
170.Fn Getfsstat
171and
172.Fn getvfsstat
173fail if one or more of the following are true:
174.Bl -tag -width Er
175.It Bq Er EFAULT
176.Fa Buf
177points to an invalid address.
178.It Bq Er EIO
179An
180.Tn I/O
181error occurred while reading from or writing to the filesystem.
182.El
183.Sh SEE ALSO
184.Xr statfs 2 ,
185.Xr fstab 5 ,
186.Xr mount 8
187.Sh HISTORY
188The
189.Fn getfsstat
190function first appeared in
191.Bx 4.4 .
192