fstatvfs (3) - Linux Manuals
fstatvfs: get filesystem statistics
NAME
statvfs, fstatvfs - get filesystem statistics
SYNOPSIS
#include <sys/statvfs.h>
int statvfs(const char *path, struct statvfs *buf);
int fstatvfs(int fd, struct statvfs *buf);
DESCRIPTION
The function statvfs() returns information about a mounted filesystem. path is the pathname of any file within the mounted filesystem. buf is a pointer to a statvfs structure defined approximately as follows:
struct statvfs {
Here the types
fsblkcnt_t
and
fsfilcnt_t
are defined in
<sys/types.h>.
Both used to be
unsigned long.
The field
f_flag
is a bit mask indicating various options that were employed
when mounting this filesystem.
It contains zero or more of the following flags:
It is unspecified whether all members of the returned struct
have meaningful values on all filesystems.
fstatvfs()
returns the same information about an open file referenced by descriptor
fd.
Only the
ST_NOSUID
and
ST_RDONLY
flags of the
f_flag
field are specified in POSIX.1.
To obtain definitions of the remaining flags, one must define
_GNU_SOURCE.
In glibc versions before 2.13,
statvfs()
populated the bits of the
f_flag
field by scanning the mount options shown in
/proc/mounts.
However, starting with Linux 2.6.36, the underlying
statfs(2)
system call provides the necessary information via the
f_flags
field, and since glibc version 2.13, the
statvfs()
function will use information from that field rather than scanning
/proc/mounts.
The glibc implementations of
pathconf(path, _PC_REC_XFER_ALIGN);
pathconf(path, _PC_ALLOC_SIZE_MIN);
pathconf(path, _PC_REC_MIN_XFER_SIZE);
respectively use the
f_frsize,
f_frsize,
and
f_bsize
fields returned by a call to
statvfs()
with the argument
path.
RETURN VALUE
On success, zero is returned.
On error, -1 is returned, and
errno
is set appropriately.
ERRORS
ATTRIBUTES
For an explanation of the terms used in this section, see
attributes(7).
Interface Attribute Value
statvfs(),
fstatvfs()
Thread safety MT-Safe CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
NOTES
The Linux kernel has system calls
statfs(2)
and
fstatfs(2)
to support this library call.
COLOPHON
This page is part of release 5.10 of the Linux
man-pages
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
https://www.kernel.org/doc/man-pages/.