|
|
#include <sys/types.h> #include <sys/statvfs.h>int statvfs(const char *path, struct statvfs *buf);
int fstatvfs(int fildes, struct statvfs *buf);
fstatvfs- report on a filesystem using a file descriptor
statvfs returns a ``generic superblock'' describing a filesystem; it can be used to acquire information about mounted filesystems. buf is a pointer to a structure (described below) that is filled by the system call.
path should name a file that resides on that filesystem. The filesystem 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.
The statvfs structure pointed to by buf includes the following members:
unsigned long f_bsize; /* preferred filesystem block size */ unsigned long f_frsize; /* fundamental filesystem block size */ /* (if supported) */ unsigned long f_blocks; /* total # of blocks on filesystem in */ /* units of f_frsize */ unsigned long f_bfree; /* total # of free blocks */ unsigned long f_bavail; /* # of free blocks avail to */ /* non-superuser */ unsigned long f_files; /* total # of file nodes (inodes) */ unsigned long f_ffree; /* total # of free file nodes */ unsigned long f_favail; /* # of inodes avail to non-superuser */ unsigned long f_fsid; /* filesystem id (dev for now) */ char f_basetype[FSTYPSZ]; /* target fs type name, null-terminated */ unsigned long f_flag; /* bit mask of flags */ unsigned long f_namemax; /* maximum file name length */ char f_fstr[32]; /* filesystem specific string */ unsigned long f_filler[16]; /* reserved for future expansion */
f_basetype
contains a null-terminated file system type
name of the mounted target (for example, an HTFS
filesystem mounted over NFS will contain NFS).
The following flags can be returned in the f_flag
field:
ST_RDONLY /* read-only filesystem */ ST_NOSUID /* does not support setuid/setgid semantics */ ST_NOTRUNC /* does not truncate filenames longer than {NAME_MAX} */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(S-osr5), creat(S-osr5), dup(S-osr5), fcntl(S-osr5), or pipe(S-osr5) system call.
AT&T SVID Issue 3.