162893Sbostic.\" Copyright (c) 1989, 1991, 1993 262893Sbostic.\" The Regents of the University of California. All rights reserved. 338241Smckusick.\" 450487Scael.\" %sccs.include.redist.roff% 538241Smckusick.\" 6*68724Smckusick.\" @(#)statfs.2 8.4 (Berkeley) 04/03/95 738241Smckusick.\" 847208Scael.Dd 947208Scael.Dt STATFS 2 1050487Scael.Os 1147208Scael.Sh NAME 1247208Scael.Nm statfs 1347208Scael.Nd get file system statistics 1447208Scael.Sh SYNOPSIS 1551744Smckusick.Fd #include <sys/param.h> 1647208Scael.Fd #include <sys/mount.h> 1747208Scael.Ft int 1847208Scael.Fn statfs "const char *path" "struct statfs *buf" 1947208Scael.Ft int 2047208Scael.Fn fstatfs "int fd" "struct statfs *buf" 2147208Scael.Sh DESCRIPTION 2247208Scael.Fn Statfs 2338241Smckusickreturns information about a mounted file system. 2447208Scael.Fa Path 2538241Smckusickis the path name of any file within the mounted filesystem. 2647208Scael.Fa Buf 2738241Smckusickis a pointer to a 2847208Scael.Fn statfs 2938241Smckusickstructure defined as follows: 3047208Scael.Bd -literal 3138241Smckusicktypedef quad fsid_t; 3247208Scael 33*68724Smckusick#define MFSNAMELEN 16 /* length of fs type name, including null */ 34*68724Smckusick#define MNAMELEN 90 /* length of buffer for returned name */ 3547208Scael 3638241Smckusickstruct statfs { 37*68724Smckusick short f_type; /* filesystem type number */ 38*68724Smckusick short f_flags; /* copy of mount flags */ 39*68724Smckusick long f_bsize; /* fundamental file system block size */ 40*68724Smckusick long f_iosize; /* optimal transfer block size */ 41*68724Smckusick long f_blocks; /* total data blocks in file system */ 42*68724Smckusick long f_bfree; /* free blocks in fs */ 43*68724Smckusick long f_bavail; /* free blocks avail to non-superuser */ 44*68724Smckusick long f_files; /* total file nodes in file system */ 45*68724Smckusick long f_ffree; /* free file nodes in fs */ 46*68724Smckusick fsid_t f_fsid; /* file system id */ 47*68724Smckusick uid_t f_owner; /* user that mounted the filesystem */ 48*68724Smckusick long f_spare[4]; /* spare for later */ 49*68724Smckusick char f_fstypename[MFSNAMELEN]; /* fs type name */ 50*68724Smckusick char f_mntonname[MNAMELEN]; /* directory on which mounted */ 51*68724Smckusick char f_mntfromname[MNAMELEN];/* mounted filesystem */ 5238241Smckusick}; 5347208Scael.Ed 5447208Scael.Pp 5547208ScaelFields that are undefined for a particular file system are set to -1. 5647208Scael.Fn Fstatfs 5738241Smckusickreturns the same information about an open file referenced by descriptor 5847208Scael.Fa fd . 5947208Scael.Sh RETURN VALUES 6038241SmckusickUpon successful completion, a value of 0 is returned. 6147208ScaelOtherwise, -1 is returned and the global variable 6247208Scael.Va errno 6338241Smckusickis set to indicate the error. 6447208Scael.Sh ERRORS 6547208Scael.Fn Statfs 6638241Smckusickfails if one or more of the following are true: 6747208Scael.Bl -tag -width ENAMETOOLONGA 6847208Scael.It Bq Er ENOTDIR 6938241SmckusickA component of the path prefix of 7047208Scael.Fa Path 7138241Smckusickis not a directory. 7247208Scael.It Bq Er EINVAL 7347208Scael.Fa path 7438241Smckusickcontains a character with the high-order bit set. 7547208Scael.It Bq Er ENAMETOOLONG 7638241SmckusickThe length of a component of 7747208Scael.Fa path 7838241Smckusickexceeds 255 characters, 7938241Smckusickor the length of 8047208Scael.Fa path 8138241Smckusickexceeds 1023 characters. 8247208Scael.It Bq Er ENOENT 8338241SmckusickThe file referred to by 8447208Scael.Fa path 8538241Smckusickdoes not exist. 8647208Scael.It Bq Er EACCES 8738241SmckusickSearch permission is denied for a component of the path prefix of 8847208Scael.Fa path . 8947208Scael.It Bq Er ELOOP 9038241SmckusickToo many symbolic links were encountered in translating 9147208Scael.Fa path . 9247208Scael.It Bq Er EFAULT 9347208Scael.Fa Buf 9438241Smckusickor 9547208Scael.Fa path 9638241Smckusickpoints to an invalid address. 9747208Scael.It Bq Er EIO 9850487ScaelAn 9950487Scael.Tn I/O 10050487Scaelerror occurred while reading from or writing to the file system. 10147208Scael.El 10247208Scael.Pp 10347208Scael.Fn Fstatfs 10465100Smckusickfails if one or more of the following are true: 10547208Scael.Bl -tag -width ENAMETOOLONGA 10647208Scael.It Bq Er EBADF 10747208Scael.Fa Fd 10838241Smckusickis not a valid open file descriptor. 10947208Scael.It Bq Er EFAULT 11047208Scael.Fa Buf 11138241Smckusickpoints to an invalid address. 11247208Scael.It Bq Er EIO 11350487ScaelAn 11450487Scael.Tn I/O 11550487Scaelerror occurred while reading from or writing to the file system. 11647208Scael.El 11747208Scael.Sh HISTORY 11847208ScaelThe 11950487Scael.Nm statfs 12062892Sbosticfunction first appeared in 4.4BSD. 121