statvfs(2)statvfs(2)NAME
statvfs, fstatvfs - get file system information
SYNOPSISDESCRIPTION
returns information about a mounted file system.
returns similar information about an open file.
The parameters for the and functions are as follows:
path is a pointer to a path name of any file within the
mounted file system.
buf is a pointer to a structure, which is where the file
system status information is stored.
fildes is a file descriptor for an open file, which is cre‐
ated with the successful completion of an or system
call (see open(2), creat(2), dup(2), fcntl(2), or
pipe(2)).
The structure contains the following members:
fsblkcnt_t f_blocks; /* total blocks of f_frsize on file system */
fsblkcnt_t f_bfree; /* free blocks */
fsblkcnt_t f_bavail; /* blocks available to non-superusers or
users without the LIMIT privilege */
fsfilcnt_t f_files; /* total file nodes in file system */
fsfilcnt_t f_ffree; /* free file nodes in file system */
fsfilcnt_t f_favail; /* file nodes available to non-superusers
or users without the LIMIT privilege */
ulong f_bsize; /* preferred file system block size */
ulong f_frsize; /* fundamental file system block size */
ulong f_size; /* see note below */
ulong f_fsid; /* file system ID for file system */
/* type; see sysfs(2) */
char f_basetype[FSTYPSZ]; /* file system type name is */
/* null-terminated */
ulong f_flag; /* bit mask of flags */
ulong f_namemax /* maximum file name length */
char f_fstr[32]; /* file system specific string */
time_t f_time; /* Last time file system was written */
The field f_size contains the size of file system in units. Note that
this field is not part of the standard POSIX definition of When a
32-bit application uses with a large file system, f_size will top out
at rather than return an error. Use f_blocks instead.
The field f_basetype contains a null-terminated file-system-type name.
The constant is defined in the header file
The following flags can be returned in the f_flag field:
File system is enabled for large files.
File system is read-only.
File system does not support
and semantics.
File system is exported (NFS).
User quotas enabled on this file system.
Group quotas enabled on this file system.
Security Restrictions
The field is the number of blocks available to non-supe‐
rusers or users without the privilege. The field is the
number of file nodes available to non-superusers or users
without the privilege. See privileges(5) for more infor‐
mation about privileged access on systems that support
fine-grained privileges.
RETURN VALUE
and return 0 upon successful completion; otherwise, they
return −1 and set to indicate the error.
ERRORS
If fails, is set to one of the following values:
Search permission is denied for a component of the
path prefix.
Too many symbolic links are encountered during
path-name translation.
The length of the specified path name exceeds
bytes, or the length of a com‐
ponent of the path name
exceeds bytes while is in
effect.
The named file does not exist (for example,
path is null or a component of
path does not exist).
A component of the path prefix is not a directory.
If fails, is set to the following value:
fildes is not a valid open file
descriptor.
When both and fail, is set to one of the following val‐
ues:
buf points to an invalid address.
An I/O error occurred while reading from or writ‐
ing to the file system.
Result would overflow one or more fields of the
struct.
SEE ALSOdf(1M), fstatfs(2), fstatvfs64(2), quotactl(2), stat(2),
statfs(2), statvfs64(2), sysfs(2), ustat(2), privi‐
leges(5).
statvfs(2)