statvfs, fstatvfs -- get filesystem information


cc . . . -lc
#include <sys/types.h>
#include <sys/statvfs.h>

int statvfs(const char *path, struct statvfs *buf);

int fstatvfs(int fildes, struct statvfs *buf);


statvfs- report on a filesystem

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), creat(S), dup(S), fcntl(S), or pipe(S) system call.

Return values

On success, statvfs and fstatvfs return 0. On failure, statvfs and fstatvfs return -1 and set errno to identify the error.


In the following conditions, statvfs fails and sets errno to:

Search permission is denied on a component of the path prefix.

path or buf points outside the process's allocated address space.

A signal was caught during statvfs execution.

An I/O error occurred while reading the filesystem.

Too many symbolic links were encountered in translating path.

Components of path require hopping to multiple remote machines and filesystem type does not allow it.

The length of a path component exceeds {NAME_MAX} characters, or the length of path exceeds {PATH_MAX} characters.

Either a component of the path prefix or the file referred to by path does not exist.

path points to a remote machine and the link to that machine is no longer active.

A component of the path prefix of path is not a directory.
In the following conditions, fstatvfs fails and sets errno to:

buf points to an invalid address.

fildes is not an open file descriptor.

A signal was caught during fstatvfs execution.

An I/O error occurred while reading the filesystem.


linking library

See also

chmod(S), chown(S), creat(S), link(S), mknod(S), pipe(S), read(S), time(S), unlink(S), utime(S), write(S)

Standards conformance

statvfs and fstatvfs are conformant with:

AT&T SVID Issue 3.

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003