xref: /netbsd-src/share/man/man5/statvfs.5 (revision d48f14661dda8638fee055ba15d35bdfb29b9fa8)
1.\"	$NetBSD: statvfs.5,v 1.9 2005/11/12 18:55:19 christos 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 November 12, 2005
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.Aq Pa 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	fsblkcnt_t	f_blocks; /* number of blocks in file system */
62	fsblkcnt_t	f_bfree;  /* free blocks avail in file system */
63	fsblkcnt_t	f_bavail; /* free blocks avail to non-root */
64	fsblkcnt_t	f_bresvd; /* blocks reserved for root */
65
66	fsfilcnt_t	f_files;  /* total file nodes in file system */
67	fsfilcnt_t	f_ffree;  /* free file nodes in file system */
68	fsfilcnt_t	f_favail; /* free file nodes avail to non-root */
69	fsfilcnt_t	f_fresvd; /* file nodes reserved for root */
70
71	uint64_t  f_syncreads;	  /* count of sync reads since mount */
72	uint64_t  f_syncwrites;	  /* count of sync writes since mount */
73
74	uint64_t  f_asyncreads;	  /* count of async reads since mount */
75	uint64_t  f_asyncwrites;  /* count of async writes since mount */
76
77	unsigned long	f_fsid;   /* POSIX compliant file system id */
78	fsid_t          f_fsidx;  /* NetBSD compatible file system id */
79
80	unsigned long	f_namemax;/* maximum filename length */
81	uid_t		f_owner; /* user that mounted the file system */
82
83	uint32_t	f_spare[4]; /* spare space */
84
85	char	f_fstypename[VFS_NAMELEN]; /* fs type name */
86	char	f_mntonname[VFS_MNAMELEN]; /* directory on which mounted */
87	char	f_mntfromname[VFS_MNAMELEN]; /* mounted file system */
88};
89.Ed
90.Pp
91The
92.Fa f_flag
93argument can have the following bits set:
94.Bl -tag -width ST_SYNCHRONOUS
95.It Dv ST_MAGICLINKS
96Expand special strings
97.Po
98beginning with
99.Dq @
100.Pc
101when traversing symbolic links.
102See
103.Xr symlink 7
104for a list of supported strings.
105.It Dv ST_RDONLY
106The filesystem is mounted read-only;
107Even the super-user may not write on it.
108.It Dv ST_NOEXEC
109Files may not be executed from the filesystem.
110.It Dv ST_NOSUID
111Setuid and setgid bits on files are not honored when they are executed.
112.It Dv ST_NODEV
113Special files in the filesystem may not be opened.
114.It Dv ST_UNION
115Union with underlying filesystem instead of obscuring it.
116.It Dv ST_SYNCHRONOUS
117All I/O to the filesystem is done synchronously.
118.It Dv ST_ASYNC
119No filesystem I/O is done synchronously.
120.It Dv ST_NOCOREDUMP
121Don't write core dumps to this file system.
122.It Dv ST_NOATIME
123Never update access times.
124.It Dv ST_SYMPERM
125Recognize symbolic link permission.
126.It Dv ST_NODEVMTIME
127Never update modification times for device files.
128.It Dv ST_SOFTDEP
129Use soft dependencies.
130.It Dv ST_LOCAL
131The filesystem resides locally.
132.It Dv ST_QUOTA
133The filesystem has quotas enabled on it.
134.It Dv ST_ROOTFS
135Identifies the root filesystem.
136.It Dv ST_EXRDONLY
137The filesystem is exported read-only.
138.It Dv ST_EXPORTED
139The filesystem is exported for both reading and writing.
140.It Dv ST_DEFEXPORTED
141The filesystem is exported for both reading and writing to any Internet host.
142.It Dv ST_EXPORTANON
143The filesystem maps all remote accesses to the anonymous user.
144.It Dv ST_EXKERB
145The filesystem is exported with Kerberos uid mapping.
146.It Dv ST_EXNORESPORT
147Don't enforce reserved ports (NFS).
148.It Dv ST_EXPUBLIC
149Public export (WebNFS).
150.El
151.Pp
152Fields that are undefined for a particular file system are set to \-1.
153.Sh NOTES
154.Bl -tag -width f_bavail
155.It f_flag
156The
157.Fa f_flag
158field is the same as the
159.Fa f_flags
160field in the
161.Bx 4.3
162.Xr statfs 2
163system call.
164.It f_fsid
165Is defined to be
166.Ft unsigned long
167by the X/Open standard.
168Unfortunately this is not enough space to store our
169.Ft fsid_t ,
170so we define an additional
171.Fa f_fsidx
172field.
173.It f_bavail
174Could historically be negative (in the
175.Xr statfs 2
176system call) when the used space has exceeded
177the non-superuser free space.
178In order to comply with the X/Open standard, we have to define
179.Ft fsblkcnt_t
180as an unsigned type, so in all cases where
181.Fa f_bavail
182would have been negative, we set it to 0.
183In addition we provide
184.Fa f_bresvd
185which contains the amount of reserved blocks for the superuser, so
186the old value of
187.Fa f_bavail
188can be easily computed as:
189.Bd -literal
190	old_bavail = f_bfree - f_bresvd;
191.Ed
192.El
193.Sh SEE ALSO
194.Xr statvfs 2
195.Sh HISTORY
196The
197.Aq Pa sys/statvfs.h
198header first appeared in
199.Nx 3.0 .
200