STATFS(2-SysV) RISC/os Reference Manual STATFS(2-SysV)
NAME
statfs, fstatfs - get file system information
SYNOPSIS
#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;
DESCRIPTION
statfs 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 will be 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
will contain exactly that value; if it holds a smaller value
the system will fill 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
can 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. Read, write, or exe-
cute permission of the named file is not required, but all
directories listed in the path name leading to the file must
be searchable.
For either mounted or unmounted file systems, path can name
the block special file for the partition containing the file
system. In this case, the fstype argument must be set to the
correct file system type.
The statfs structure pointed to by buf includes the follow-
ing members:
short f_fstyp; /* File system type */
long f_bsize; /* Block size */
long f_frsize; /* Fragment size */
long f_blocks; /* Total number of blocks */
long f_bfree; /* Count of free blocks*/
Printed 1/15/91 Page 1
STATFS(2-SysV) RISC/os Reference Manual STATFS(2-SysV)
long f_files; /* Total number of file nodes */
long f_ffree; /* Count of free file nodes */
char f_fname[6]; /* Volume name */
char f_fpack[6]; /* Pack name */
fstatfs is similar, except that the file named by path in
statfs is instead identified by an open file descriptor
filedes obtained from a successful open(2), creat(2),
dup(2), fcntl(2), or pipe(2) system call.
statfs obsoletes ustat(2) and should be used in preference
to it in new programs.
ERRORS
statfs and fstatfs will fail if one or more of the following
are true:
[ENOTDIR] A component of the path prefix is not a direc-
tory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of
the path prefix.
[EFAULT] buf or path points to an invalid address.
[EBADF] fildes is not a valid open file descriptor.
[EINVAL] fstyp is an invalid file system type; path is
not a block special file and fstyp is nonzero;
len is negative or is greater than sizeof
(struct statfs).
[ENOLINK] path points to a remote machine, and the link to
that machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple
remote machines.
ANOMALIES
The f_bfree field of the returned data structure returns a
number which is consistent with a BSD filesystem. In other
words, zero free blocks really means 90% of the filesystem
is filled. If any more space is used, the number of free
blocks will actually go negative. We chose these semantics
because reporting free blocks as a function of the total
disk space would result in an inability for users to write
to a 90% full filesystem.
DIAGNOSTICS
Upon successful completion a value of 0 is returned.
Page 2 Printed 1/15/91
STATFS(2-SysV) RISC/os Reference Manual STATFS(2-SysV)
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
SEE ALSO
chmod(2), chown(2), creat(2), link(2), mknod(2), pipe(2),
read(2), time(2), unlink(2), utime(2), write(2), fs.ffs(4).
Printed 1/15/91 Page 3