statvfs(2) statvfs(2)
NAME
statvfs, fstatvfs, statvfs64, fstatvfs64 - get file system information
SYNOPSIS
#include <sys/types.h>
#include <sys/statvfs.h>
int statvfs(const char *path, struct statvfs *buf);
int fstatvfs(int fildes, struct statvfs *buf);
int statvfs64(const char *path, struct statvfs64 *buf);
int fstatvfs64(int fildes, struct statvfs64 *buf);
DESCRIPTION
statvfs() returns a "generic superblock" describing a file system; it
can be used to acquire information about mounted file systems. buf is
a pointer to a structure (described below) that is filled by the sys-
tem call.
path should name a file that resides on that file system. The file
system type is known to the operating system. Read, write, or execute
permission for the named file is not required, but all directories
listed in the pathname leading to the file must be searchable.
There is no functional difference between statvfs()/fstatvfs() and
statvfs64()/fstatvfs64(), except for the interpretation of
statvfs/statvfs64 [see statvfs(5)].
The statvfs structure pointed to by buf includes the following
members:
ulongt fbsize; /* optimal I/O size for read and write */
ulongt ffrsize; /* fundamental file system block size */
fsblkcntt fblocks; /* total # of blocks on file system
in units of ffrsize */
fsblkcntt fbfree; /* total # of free blocks
in units of ffrsize */
fsblkcntt fbavail; /* # of free blocks avail to non-superuser
in units of ffrsize */
fsfilcntt ffiles; /* total # of file nodes (inodes) */
fsfilcntt fffree; /* total # of free file nodes */
fsfilcntt ffavail; /* # of inodes avail to non-superuser */
ulongt ffsid; /* file system id (dev for now) */
char fbasetype[FSTYPSZ]; /* target fs type name, null-terminated */
ulongt fflag; /* bit mask of flags */
ulongt fnamemax; /* maximum filename length */
char ffstr[32]; /* file system specific string */
ulongt ffiller[16]; /* reserved for future expansion */
Page 1 Reliant UNIX 5.44 Printed 11/98
statvfs(2) statvfs(2)
fbasetype contains a null-terminated FSType name of the mounted tar-
get (e.g. ufs mounted over nfs will contain ufs).
The following flags can be returned in the fflag field:
STRDONLY 0x01 /* read-only file system */
STNOSUID 0x02 /* does not support setuid/setgid semantics */
STNOTRUNC 0x04 /* does not truncate filenames longer than
NAMEMAX */
fstatvfs() is similar to statvfs(), except that the file named by path
in statvfs() is instead identified by an open file descriptor fildes
obtained from a successful open(), creat(), dup(), fcntl(), or pipe()
system call.
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
statvfs() and statvfs() fail if one or more of the following apply:
EINTR A signal was caught during execution of the function.
EIO An I/O error occurred while reading the file system.
EOVERFLOW One of the values to be returned cannot be represented
correctly in the structure pointed to by buf.
statvfs() fails if one or more of the following apply:
EACCES Search permission is denied on a component of the path
prefix.
EFAULT path or buf points outside the process' allocated
address space.
ELOOP Too many symbolic links were encountered in translating
path.
EMULTIHOP Components of path require hopping to multiple remote
machines and the file system does not allow it.
ENAMETOOLONG The length of a path component exceeds NAMEMAX charac-
ters, or the length of path exceeds PATHMAX characters.
ENOENT Either a component of the path prefix or the file
referred to by path does not exist.
ENOLINK path points to a remote machine and the link to that
machine is no longer active.
ENOTDIR A component of the path prefix of path is not a directory.
Page 2 Reliant UNIX 5.44 Printed 11/98
statvfs(2) statvfs(2)
fstatvfs() fails if one or more of the following apply:
EFAULT buf points to an invalid address.
EBADF fildes is not an open file descriptor.
statvfs() may fail if:
ENAMETOOLONG Pathname resolution of a symbolic link produced an
intermediate result whose length exceeds PATHMAX.
RESULT
Upon successful completion a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
NOTES
fstatvfs() and statvfs() functions will fail if the total, or free, or
available number of blocks or files cannot be represented correctly in
the structure to be returned (fblocks, fbfree, fbavail, ffiles,
fffree, ffavail).
SEE ALSO
chmod(2), chown(2), creat(2), link(2), mknod(2), pipe(2), read(2),
time(2), unlink(2), utime(2), write(2), lfs(5), statvfs(5), types(5).
Page 3 Reliant UNIX 5.44 Printed 11/98