xref: /netbsd-src/share/man/man5/statvfs.5 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1.\"	$NetBSD: statvfs.5,v 1.13 2013/04/05 17:33:06 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 April 5, 2013
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	uint32_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};
90.Ed
91.Pp
92The
93.Fa f_flag
94argument can have the following bits set:
95.Bl -tag -width ST_SYNCHRONOUS
96.It Dv ST_RDONLY
97The filesystem is mounted read-only;
98Even the super-user may not write on it.
99.It Dv ST_NOEXEC
100Files may not be executed from the filesystem.
101.It Dv ST_NOSUID
102Setuid and setgid bits on files are not honored when they are executed.
103.It Dv ST_NODEV
104Special files in the filesystem may not be opened.
105.It Dv ST_UNION
106Union with underlying filesystem instead of obscuring it.
107.It Dv ST_SYNCHRONOUS
108All I/O to the filesystem is done synchronously.
109.It Dv ST_ASYNC
110No filesystem I/O is done synchronously.
111.It Dv ST_NOCOREDUMP
112Don't write core dumps to this file system.
113.It Dv ST_NOATIME
114Never update access times.
115.It Dv ST_SYMPERM
116Recognize symbolic link permission.
117.It Dv ST_NODEVMTIME
118Never update modification times for device files.
119.It Dv ST_LOG
120Use logging (journalling).
121.It Dv ST_LOCAL
122The filesystem resides locally.
123.It Dv ST_QUOTA
124The filesystem has quotas enabled on it.
125.It Dv ST_ROOTFS
126Identifies the root filesystem.
127.It Dv ST_EXRDONLY
128The filesystem is exported read-only.
129.It Dv ST_EXPORTED
130The filesystem is exported for both reading and writing.
131.It Dv ST_DEFEXPORTED
132The filesystem is exported for both reading and writing to any Internet host.
133.It Dv ST_EXPORTANON
134The filesystem maps all remote accesses to the anonymous user.
135.It Dv ST_EXKERB
136The filesystem is exported with Kerberos uid mapping.
137.It Dv ST_EXNORESPORT
138Don't enforce reserved ports (NFS).
139.It Dv ST_EXPUBLIC
140Public export (WebNFS).
141.El
142.Pp
143Fields that are undefined for a particular file system are set to \-1.
144.Sh NOTES
145.Bl -tag -width f_bavail
146.It f_flag
147The
148.Fa f_flag
149field is the same as the
150.Fa f_flags
151field in the
152.Bx 4.3
153.Xr statfs 2
154system call.
155.It f_fsid
156Is defined to be
157.Ft unsigned long
158by the X/Open standard.
159Unfortunately this is not enough space to store our
160.Ft fsid_t ,
161so we define an additional
162.Fa f_fsidx
163field.
164.It f_bavail
165Could historically be negative (in the
166.Xr statfs 2
167system call) when the used space has exceeded
168the non-superuser free space.
169In order to comply with the X/Open standard, we have to define
170.Ft fsblkcnt_t
171as an unsigned type, so in all cases where
172.Fa f_bavail
173would have been negative, we set it to 0.
174In addition we provide
175.Fa f_bresvd
176which contains the amount of reserved blocks for the superuser, so
177the old value of
178.Fa f_bavail
179can be easily computed as:
180.Bd -literal
181	old_bavail = f_bfree - f_bresvd;
182.Ed
183.El
184.Sh SEE ALSO
185.Xr statvfs 2
186.Sh HISTORY
187The
188.In sys/statvfs.h
189header first appeared in
190.Nx 3.0 .
191