'\"macro stdmacro
.if n .pH g2.statvfs @(#)statvfs	40.9 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} statvfs 2 "" "\&"
.if \nX=1 .ds x} statvfs 2 ""
.if \nX=2 .ds x} statvfs 2 "" "\&"
.if \nX=3 .ds x} statvfs "" "" "\&"
.TH \*(x}
.SH NAME
\f4statvfs\f1, \f4fstatvfs\f1 \- get file system information
.SH SYNOPSIS
\f4#include <sys/types.h>\f1
.br
\f4#include <sys/statvfs.h>\f1
.PP
\f4int statvfs (const char \(**path, struct statvfs \(**buf);\f1
.PP
\f4int fstatvfs (int fildes, struct statvfs \(**buf);\f1
.SH DESCRIPTION
\f4statvfs\fP
returns a ``generic superblock'' describing a file system;
it can be used to acquire information about mounted 
file systems.
.I buf\^
is a pointer to a structure (described below) that is filled by
the system call.
.PP
.I path\^
should name a file that resides on that file system.
The file system 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
path name
leading to the file must be searchable.
.PP
The
\f4statvfs\fP
structure pointed to by
.I buf\^
includes the following members:
.PP
.RS
.nf
.ft 4
.ta 8n 25n
ulong	f_bsize;	/\(** preferred file system block size \(**/
ulong	f_frsize;	/\(** fundamental filesystem block size
		(if supported) \(**/
ulong	f_blocks;	/\(** total # of blocks on file system
		in units of f_frsize \(**/
ulong	f_bfree;	/\(** total # of free blocks \(**/
ulong	f_bavail;	/\(** # of free blocks avail to
	         	     non-superuser \(**/
ulong	f_files;	/\(** total # of file nodes (inodes) \(**/
ulong	f_ffree;	/\(** total # of free file nodes \(**/
ulong	f_favail;	/\(** # of inodes avail to
	         	     non-superuser\(**/
fsid_t	f_fsid;		/\(** file system id (dev for now) \(**/
char	f_basetype[FSTYPSZ]; /\(**  target fs type name,
	         	     null-terminated \(**/
ulong	f_flag;	/\(** bit mask of flags \(**/
ulong	f_namemax;	/\(** maximum file name length \(**/
char	f_fstr[32];	/\(** file system specific string \(**/
ulong	f_filler[16];	/\(** reserved for future expansion \(**/
.ft 1
.fi
.RE
.P
\f4f_basetype\f1 contains a null-terminated FSType name of the
mounted target (e.g. \f4s5\f1 mounted over \f4rfs\f1 will contain
\f4s5\f1).
.PP
The following flags can be returned in the \f4f_flag\f1 field:
.P
.RS
.ft 4
.nf
.ta 14n 25n
ST_RDONLY	0x01	/\(** read-only file system \(**/
ST_NOSUID	0x02	/\(** does not support setuid/setgid
	         	     semantics \(**/
ST_NOTRUNC	0x04	/\(** does not truncate file names
	         	     longer than {NAME_MAX}\(**/
.ft 1
.fi
.RE
.PP
\f4fstatvfs\fP
is similar to \f4statvfs\f1, except that the file named by
.I path\^
in
\f4statvfs\fP
is instead identified by an open file descriptor
.I fildes\^
obtained from a successful
\f4open\fP,
\f4creat\fP,
\f4dup\fP,
\f4fcntl\fP,
or
\f4pipe\fP
system call.
.PP
\f4statvfs\fP
fails if one or more of the following are true:
.TP 15
\f4EACCES\fP
Search permission is denied on a component of the path prefix.
.TP 15
\f4EFAULT\fP
.I path
or
.I buf
points outside the process's allocated address space.
.TP 15
\f4EINTR\fP
A signal was caught during \f4statvfs\f1 execution.
.TP 15
\f4EIO\fP
An I/O error occurred while reading the file system.
.TP 15
\f4ELOOP\fP
Too many symbolic links were encountered in translating
.IR path .
.TP 15
\f4EMULTIHOP\fP
Components of
.I path\^
require hopping to multiple remote machines
and file system type does not allow it.
.TP 15
\f4ENAMETOOLONG\fP
The length of a \f2path\f1 component
exceeds {\f4NAME_MAX\f1} characters,
or the length of
.I path\^
exceeds {\f4PATH_MAX\f1} characters.
.TP 15
\f4ENOENT\fP
Either a component of the path prefix or the file referred to by
.I path\^
does not exist.
.TP 15
\f4ENOLINK\fP
.I path\^
points to a remote machine and the link to that machine is no longer
active.
.TP 15
\f4ENOTDIR\fP
A component of the path prefix of
.I path\^
is not a directory.
.PP
\f4fstatvfs\fP
fails if one or more of the following are true:
.TP 15
\f4EFAULT\fP
.I buf\^
points to an invalid address.
.TP 15
\f4EBADF\fP
.I fildes\^
is not an open file descriptor.
.TP 15
\f4EINTR\fP
A signal was caught during \f4fstatvfs\f1 execution.
.TP 15
\f4EIO\fP
An I/O error occurred while reading the file system.
.SH "DIAGNOSTICS"
Upon successful completion a value of 0 is returned.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.SH "SEE ALSO"
\f4chmod\fP(2), \f4chown\fP(2), \f4creat\fP(2), \f4link\fP(2), \f4mknod\fP(2), \f4pipe\fP(2), \f4read\fP(2),
\f4time\fP(2), \f4unlink\fP(2), \f4utime\fP(2), \f4write\fP(2).
.Ee
