#include <sys/types.h> #include <sys/statfs.h>
int statfs (path, buf, len, fstyp) char *path; struct statfs *buf; int len, fstyp;
int fstatfs (fildes, buf, len, fstyp) int fildes; struct statfs *buf; int len, fstyp;
fstatfs- get file system information
The statfs system call returns a ``generic superblock'' describing a file system. It can be used to acquire information about mounted as well as unmounted file systems, and usage is slightly different in the two cases. In all cases, buf is a pointer to a structure (described below) which is filled by the system call, and len is the number of bytes of information which the system should return in the structure. len must be no greater than sizeof (struct statfs) and ordinarily it contains exactly that value; if it holds a smaller value, the system fills the structure with that number of bytes. (This allows future versions of the system to grow the structure without invalidating older binary programs.)
If the file system of interest is currently mounted, path should name a file which resides on that file system. In this case the file system type is known to the operating system and the fstyp argument must be zero. For an unmounted file system path must name the block special file containing it and fstyp must contain the (non-zero) file system type. In both cases read, write, or execute permission of the named file is not required, but all directories listed in the path name leading to the file must be searchable.
The statfs structure pointed to by buf includes the following members:
short f_fstyp; /* File system type */ long f_bsize; /* Block size */ long f_frsize; /* Fragment size */ long f_blocks; /* Total number of 512-byte blocks */ long f_bfree; /* Count of free blocks */ long f_files; /* Total number of file nodes */ long f_ffree; /* Count of free file nodes */ char f_fname; /* Volume name */ char f_fpack; /* Pack name */The fstatfs system call is similar, except that the file named by path in statfs is instead identified by an open file descriptor fildes obtained from a successful open(S), creat(S), dup(S), fcntl(S), or pipe(S) system call.
The statfs system call obsoletes ustat(S) and should be used in preference to it in new programs.