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