STATVFSSection: Linux Programmer's Manual (2)Updated: 2003-08-22 |
STATVFSSection: Linux Programmer's Manual (2)Updated: 2003-08-22 |
int statvfs(const char *path, struct statvfs *buf);
int fstatvfs(int fd, struct statvfs *buf);
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 non-root */
fsfilcnt_t f_files; /* # inodes */
fsfilcnt_t f_ffree; /* # free inodes */
fsfilcnt_t f_favail; /* # free inodes for non-root */
unsigned long f_fsid; /* file system id */
unsigned long f_flag; /* mount flags */
unsigned long f_namemax; /* maximum filename length */
};
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 (of mount flags, see mount(8)). Bits defined by POSIX are
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.
The current glibc implementation of
pathconf(path, _PC_REC_XFER_ALIGN); pathconf(path, _PC_ALLOC_SIZE_MIN); pathconf(path, _PC_REC_MIN_XFER_SIZE);
uses the f_frsize, f_frsize, and f_bsize fields of the return value of statvfs(path,buf).