.\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
-.\" %%%LICENSE_START(verbatim)
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
-.TH STATVFS 3 2003-08-22 "Linux" "Linux Programmer's Manual"
+.TH STATVFS 3 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
-statvfs, fstatvfs \- get file system statistics
+statvfs, fstatvfs \- get filesystem statistics
.SH SYNOPSIS
.B #include <sys/statvfs.h>
-.sp
+.PP
.BI "int statvfs(const char *" path ", struct statvfs *" buf );
.br
.BI "int fstatvfs(int " fd ", struct statvfs *" buf );
.SH DESCRIPTION
The function
.BR statvfs ()
-returns information about a mounted file system.
+returns information about a mounted filesystem.
.I path
-is the pathname of any file within the mounted file system.
+is the pathname of any file within the mounted filesystem.
.I buf
is a pointer to a
.I statvfs
structure defined approximately as follows:
-
+.PP
.in +4n
-.nf
+.EX
struct statvfs {
- unsigned long f_bsize; /* file system block size */
- unsigned long f_frsize; /* fragment size */
- fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
- fsblkcnt_t f_bfree; /* # free blocks */
- fsblkcnt_t f_bavail; /* # free blocks for unprivileged users */
- fsfilcnt_t f_files; /* # inodes */
- fsfilcnt_t f_ffree; /* # free inodes */
- fsfilcnt_t f_favail; /* # free inodes for unprivileged users */
- unsigned long f_fsid; /* file system ID */
- unsigned long f_flag; /* mount flags */
- unsigned long f_namemax; /* maximum filename length */
+ unsigned long f_bsize; /* Filesystem block size */
+ unsigned long f_frsize; /* Fragment size */
+ fsblkcnt_t f_blocks; /* Size of fs in f_frsize units */
+ fsblkcnt_t f_bfree; /* Number of free blocks */
+ fsblkcnt_t f_bavail; /* Number of free blocks for
+ unprivileged users */
+ fsfilcnt_t f_files; /* Number of inodes */
+ fsfilcnt_t f_ffree; /* Number of free inodes */
+ fsfilcnt_t f_favail; /* Number of free inodes for
+ unprivileged users */
+ unsigned long f_fsid; /* Filesystem ID */
+ unsigned long f_flag; /* Mount flags */
+ unsigned long f_namemax; /* Maximum filename length */
};
-.fi
+.EE
.in
-
+.PP
Here the types
.I fsblkcnt_t
and
.IR <sys/types.h> .
Both used to be
.IR "unsigned long" .
-
+.PP
The field
.I f_flag
-is a bit mask (of mount flags, see
-.BR mount (8)).
-Bits defined by POSIX are
+is a bit mask indicating various options that were employed
+when mounting this filesystem.
+It contains zero or more of the following flags:
+.\" XXX Keep this list in sync with statfs(2)
.TP
-.B ST_RDONLY
-Read-only file system.
+.B ST_MANDLOCK
+Mandatory locking is permitted on the filesystem (see
+.BR fcntl (2)).
+.TP
+.B ST_NOATIME
+Do not update access times; see
+.BR mount (2).
+.TP
+.B ST_NODEV
+Disallow access to device special files on this filesystem.
+.TP
+.B ST_NODIRATIME
+Do not update directory access times; see
+.BR mount (2).
+.TP
+.B ST_NOEXEC
+Execution of programs is disallowed on this filesystem.
.TP
.B ST_NOSUID
-Set-user-ID/set-group-ID bits are ignored by
-.BR exec (3).
-.LP
+The set-user-ID and set-group-ID bits are ignored by
+.BR exec (3)
+for executable files on this filesystem
+.TP
+.B ST_RDONLY
+This filesystem is mounted read-only.
+.TP
+.B ST_RELATIME
+Update atime relative to mtime/ctime; see
+.BR mount (2).
+.TP
+.B ST_SYNCHRONOUS
+Writes are synched to the filesystem immediately (see the description of
+.B O_SYNC
+in
+.BR open (2)).
+.PP
It is unspecified whether all members of the returned struct
-have meaningful values on all file systems.
-
+have meaningful values on all filesystems.
+.PP
.BR fstatvfs ()
returns the same information about an open file referenced by descriptor
.IR fd .
points to an invalid address.
.TP
.B EINTR
-This call was interrupted by a signal.
+This call was interrupted by a signal; see
+.BR signal (7).
.TP
.B EIO
-An I/O error occurred while reading from the file system.
+An I/O error occurred while reading from the filesystem.
.TP
.B ELOOP
.RB ( statvfs ())
Insufficient kernel memory was available.
.TP
.B ENOSYS
-The file system does not support this call.
+The filesystem does not support this call.
.TP
.B ENOTDIR
.RB ( statvfs ())
.TP
.B EOVERFLOW
Some values were too large to be represented in the returned struct.
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbw21 lb lb
+l l l.
+Interface Attribute Value
+T{
+.BR statvfs (),
+.BR fstatvfs ()
+T} Thread safety MT-Safe
+.TE
.SH CONFORMING TO
-POSIX.1-2001.
+POSIX.1-2001, POSIX.1-2008.
+.PP
+Only the
+.B ST_NOSUID
+and
+.B ST_RDONLY
+flags of the
+.I f_flag
+field are specified in POSIX.1.
+To obtain definitions of the remaining flags, one must define
+.BR _GNU_SOURCE .
.SH NOTES
The Linux kernel has system calls
.BR statfs (2)
and
.BR fstatfs (2)
to support this library call.
-
-The current glibc implementations of
-.sp
-.nf
- pathconf(path, _PC_REC_XFER_ALIGN);
- pathconf(path, _PC_ALLOC_SIZE_MIN);
- pathconf(path, _PC_REC_MIN_XFER_SIZE);
-.fi
-.sp
+.PP
+In glibc versions before 2.13,
+.\" glibc commit 3cdaa6adb113a088fdfb87aa6d7747557eccc58d
+.BR statvfs ()
+populated the bits of the
+.IR f_flag
+field by scanning the mount options shown in
+.IR /proc/mounts .
+However, starting with Linux 2.6.36, the underlying
+.BR statfs (2)
+system call provides the necessary information via the
+.IR f_flags
+field, and since glibc version 2.13, the
+.BR statvfs ()
+function will use information from that field rather than scanning
+.IR /proc/mounts .
+.PP
+The glibc implementations of
+.PP
+.in +4n
+.EX
+pathconf(path, _PC_REC_XFER_ALIGN);
+pathconf(path, _PC_ALLOC_SIZE_MIN);
+pathconf(path, _PC_REC_MIN_XFER_SIZE);
+.EE
+.in
+.PP
respectively use the
.IR f_frsize ,
.IR f_frsize ,
and
.I f_bsize
-fields of the return value of
-.IR "statvfs(path,buf)" .
+fields returned by a call to
+.BR statvfs ()
+with the argument
+.IR path .
.SH SEE ALSO
.BR statfs (2)