xref: /netbsd-src/share/man/man5/statvfs.5 (revision 6f8dc1509fa98d2f403ca646d8d47b18bead7044)
1.\"	$NetBSD: statvfs.5,v 1.16 2021/10/21 13:21:53 andvar 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.\"	@(#)statfs.2	8.5 (Berkeley) 5/24/95
31.\"
32.Dd September 22, 2019
33.Dt STATVFS 5
34.Os
35.Sh NAME
36.Nm statvfs
37.Nd file system statistics
38.Sh SYNOPSIS
39.In sys/types.h
40.In sys/statvfs.h
41.Sh DESCRIPTION
42The
43.In sys/statvfs.h
44header defines the structures and functions that
45return information about a mounted file system.
46The
47.Nm statvfs
48structure is defined as follows:
49.Bd -literal
50typedef struct { int32_t val[2]; } fsid_t;	/* file system id type */
51
52#define VFS_NAMELEN  32 	/* length of fs type name, including nul */
53#define VFS_MNAMELEN 1024	/* length of buffer for returned name */
54
55struct statvfs {
56    unsigned long f_flag;	/* copy of mount exported flags */
57    unsigned long f_bsize;	/* system block size */
58    unsigned long f_frsize;	/* system fragment size */
59    unsigned long f_iosize;	/* optimal file system block size */
60
61    /* The following are in units of f_frsize */
62    fsblkcnt_t	f_blocks;	/* number of blocks in file system */
63    fsblkcnt_t	f_bfree;	/* free blocks avail in file system */
64    fsblkcnt_t	f_bavail;	/* free blocks avail to non-root */
65    fsblkcnt_t	f_bresvd;	/* blocks reserved for root */
66
67    fsfilcnt_t	f_files;	/* total file nodes in file system */
68    fsfilcnt_t	f_ffree;	/* free file nodes in file system */
69    fsfilcnt_t	f_favail	/* free file nodes avail to non-root */
70    fsfilcnt_t	f_fresvd;	/* file nodes reserved for root */
71
72    uint64_t	f_syncreads;	/* count of sync reads since mount */
73    uint64_t	f_syncwrites;	/* count of sync writes since mount */
74
75    uint64_t	f_asyncreads;	/* count of async reads since mount */
76    uint64_t	f_asyncwrites;	/* count of async writes since mount */
77
78    unsigned long f_fsid;	/* POSIX compliant file system id */
79    fsid_t	f_fsidx;	/* NetBSD compatible file system id */
80
81    unsigned long f_namemax;	/* maximum filename length */
82    uid_t	f_owner;	/* user that mounted the file system */
83
84    uint64_t	f_spare[4];	/* spare space */
85
86    char f_fstypename[VFS_NAMELEN];	/* fs type name */
87    char f_mntonname[VFS_MNAMELEN];	/* directory on which mounted */
88    char f_mntfromname[VFS_MNAMELEN];	/* mounted file system */
89    char f_mntfromlabel[_VFS_MNAMELEN];	/* disk label name if avail */
90};
91.Ed
92.Pp
93The
94.Fa f_flag
95argument can have the following bits set:
96.Bl -tag -width ST_SYNCHRONOUS
97.It Dv ST_RDONLY
98The filesystem is mounted read-only;
99Even the super-user may not write on it.
100.It Dv ST_NOEXEC
101Files may not be executed from the filesystem.
102.It Dv ST_NOSUID
103Setuid and setgid bits on files are not honored when they are executed.
104.It Dv ST_NODEV
105Special files in the filesystem may not be opened.
106.It Dv ST_UNION
107Union with underlying filesystem instead of obscuring it.
108.It Dv ST_SYNCHRONOUS
109All I/O to the filesystem is done synchronously.
110.It Dv ST_ASYNC
111No filesystem I/O is done synchronously.
112.It Dv ST_NOCOREDUMP
113Don't write core dumps to this file system.
114.It Dv ST_NOATIME
115Never update access times.
116.It Dv ST_SYMPERM
117Recognize symbolic link permission.
118.It Dv ST_NODEVMTIME
119Never update modification times for device files.
120.It Dv ST_LOG
121Use logging (journaling).
122.It Dv ST_LOCAL
123The filesystem resides locally.
124.It Dv ST_QUOTA
125The filesystem has quotas enabled on it.
126.It Dv ST_ROOTFS
127Identifies the root filesystem.
128.It Dv ST_EXRDONLY
129The filesystem is exported read-only.
130.It Dv ST_EXPORTED
131The filesystem is exported for both reading and writing.
132.It Dv ST_DEFEXPORTED
133The filesystem is exported for both reading and writing to any Internet host.
134.It Dv ST_EXPORTANON
135The filesystem maps all remote accesses to the anonymous user.
136.It Dv ST_EXKERB
137The filesystem is exported with Kerberos uid mapping.
138.It Dv ST_EXNORESPORT
139Don't enforce reserved ports (NFS).
140.It Dv ST_EXPUBLIC
141Public export (WebNFS).
142.El
143.Pp
144Fields that are undefined for a particular file system are set to \-1.
145.Sh NOTES
146.Bl -tag -width f_bavail
147.It f_flag
148The
149.Fa f_flag
150field is the same as the
151.Fa f_flags
152field in the
153.Bx 4.3
154.Ic statfs
155system call.
156.It f_fsid
157Is defined to be
158.Ft unsigned long
159by the X/Open standard.
160Unfortunately this is not enough space to store our
161.Ft fsid_t ,
162so we define an additional
163.Fa f_fsidx
164field.
165.It f_bavail
166Could historically be negative (in the
167.Ic statfs
168system call) when the used space has exceeded
169the non-superuser free space.
170In order to comply with the X/Open standard, we have to define
171.Ft fsblkcnt_t
172as an unsigned type, so in all cases where
173.Fa f_bavail
174would have been negative, we set it to 0.
175In addition we provide
176.Fa f_bresvd
177which contains the amount of reserved blocks for the superuser, so
178the old value of
179.Fa f_bavail
180can be easily computed as:
181.Bd -literal
182	old_bavail = f_bfree - f_bresvd;
183.Ed
184.El
185.Sh SEE ALSO
186.Xr statvfs 2
187.Sh HISTORY
188The
189.In sys/statvfs.h
190header first appeared in
191.Nx 3.0 .
192