statvfs()

NAME

fstatvfs(), statvfs() - get information about file system

SYNOPSIS

#include <sys/statvfs.h>

int fstatvfs(int fildes, struct statvfs *buf) int statvfs(const char *path, struct statvfs *buf)

DESCRIPTION

These two functions return information about the file system by filling the statvfs structure referenced by buf. The fstatvfs(2) function returns information about the file referenced by the file descriptor fildes; the statvfs(2) function returns information about the file named by path.

The calling process does not need read, write, or execute permission on the file. For statvfs(2), the calling process must be able to search all of the directories in the file's absolute path name, or an [EACCES] error will result.

The statvfs structure contains the following members:

Type Member
unsigned long f_bsize
unsigned long f_frsize
unsigned long f_blocks
unsigned long f_bfree
unsigned long f_bavail
unsigned long f_files
unsigned long f_ffree
unsigned long f_favail
unsigned long f_fsid
unsigned long f_flag
unsigned long f_namemax
unsigned long f_type
unsigned long f_iosize
char f_mntonname[MNAMELEN+1]
char f_mntfromname[MNAMELEN+1]

The members represent:

f_bsize
The block size on the file system.
f_frsize
Fundamental block size on the file system.
f_blocks
Total number of blocks on the file system in units of f_frsize.
f_bfree
Total number of free blocks.
f_bavail
Total number of free blocks available to a non-privileged process.
f_files
Total number of file serial numbers on the file system.
f_ffree
Total number of free file serial numbers on the file system.
f_favail
Total number of file serial numbers available to a non-privileged process.
f_fsid
ID of the file system.
f_flag
A bit mask of values describing the file system; defined values are:
ST_RDONLY
A read-only file system.
ST_NOSUID
The file system does not support setuid/setgid semantics.
f_namemax
The maximum length of a file name on the file system.
f_type
The type of the file system, which is one of the following:
ST_FSTYPE_CDFS
ISO 9660 CD-ROM drive.
ST_FSTYPE_CDROM
ISO 9660 CD-ROM drive.
ST_FSTYPE_FATFS
MS-DOS File Allocation Table (FAT) file system.
ST_FSTYPE_HPFS
IBM OS/2 High Performance File System.
ST_FSTYPE_ISO9660
ISO 9660 CD-ROM drive.
ST_FSTYPE_MSDOS
MS-DOS File Allocation Table (FAT) file system.
ST_FSTYPE_NTFS
NTFS file system.
ST_FSTYPE_OFS
OFS (Microsoft Windows Object File System).
ST_FSTYPE_SAMBA
Samba SMB file system.
ST_FSTYPE_NFS
Network File System (NFS)
ST_FSTYPE_UNKNOWN
Unknown file system type.
f_iosize
Optimal transfer block size.
f_mntonname
The mountpoint for the file system. This is normally a path name corresponding to a drive letter, such as /dev/fs/C or /dev/fs/F.
f_mntfromname
The mounted file system.

RETURN VALUE

On success, each function returns 0. Otherwise, it returns -1 and sets errno to indicate the error.

ERRORS

Both functions will fail if:

[EINVAL]
The device holding the file system does not support the operation.
[EIO]
An input/output (I/O) error occurred while reading from or writing to the file system.
[EINTR]
A signal was caught while the function was executing.

In addition, fstatvfs(2) will fail if:

[EBADF]
The descriptor fildes is invalid.

The statvfs(2) function will fail if:

[EACCES]
The calling process did not have search permission on a directory in the file's path name.
[ENAMETOOLONG]
A component of the file's path name exceeded {NAME_MAX} characters, or the entire path name exceeded {PATH_MAX} characters.
[ENOENT]
The file does not exist.
[ENOTDIR]
Some component of the path prefix is not a directory.

SEE ALSO

stat(2)