1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)statfs.2 8.4 (Berkeley) 04/03/95 7.\" 8.Dd 9.Dt STATFS 2 10.Os 11.Sh NAME 12.Nm statfs 13.Nd get file system statistics 14.Sh SYNOPSIS 15.Fd #include <sys/param.h> 16.Fd #include <sys/mount.h> 17.Ft int 18.Fn statfs "const char *path" "struct statfs *buf" 19.Ft int 20.Fn fstatfs "int fd" "struct statfs *buf" 21.Sh DESCRIPTION 22.Fn Statfs 23returns information about a mounted file system. 24.Fa Path 25is the path name of any file within the mounted filesystem. 26.Fa Buf 27is a pointer to a 28.Fn statfs 29structure defined as follows: 30.Bd -literal 31typedef quad fsid_t; 32 33#define MFSNAMELEN 16 /* length of fs type name, including null */ 34#define MNAMELEN 90 /* length of buffer for returned name */ 35 36struct statfs { 37 short f_type; /* filesystem type number */ 38 short f_flags; /* copy of mount flags */ 39 long f_bsize; /* fundamental file system block size */ 40 long f_iosize; /* optimal transfer block size */ 41 long f_blocks; /* total data blocks in file system */ 42 long f_bfree; /* free blocks in fs */ 43 long f_bavail; /* free blocks avail to non-superuser */ 44 long f_files; /* total file nodes in file system */ 45 long f_ffree; /* free file nodes in fs */ 46 fsid_t f_fsid; /* file system id */ 47 uid_t f_owner; /* user that mounted the filesystem */ 48 long f_spare[4]; /* spare for later */ 49 char f_fstypename[MFSNAMELEN]; /* fs type name */ 50 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 51 char f_mntfromname[MNAMELEN];/* mounted filesystem */ 52}; 53.Ed 54.Pp 55Fields that are undefined for a particular file system are set to -1. 56.Fn Fstatfs 57returns the same information about an open file referenced by descriptor 58.Fa fd . 59.Sh RETURN VALUES 60Upon successful completion, a value of 0 is returned. 61Otherwise, -1 is returned and the global variable 62.Va errno 63is set to indicate the error. 64.Sh ERRORS 65.Fn Statfs 66fails if one or more of the following are true: 67.Bl -tag -width ENAMETOOLONGA 68.It Bq Er ENOTDIR 69A component of the path prefix of 70.Fa Path 71is not a directory. 72.It Bq Er EINVAL 73.Fa path 74contains a character with the high-order bit set. 75.It Bq Er ENAMETOOLONG 76The length of a component of 77.Fa path 78exceeds 255 characters, 79or the length of 80.Fa path 81exceeds 1023 characters. 82.It Bq Er ENOENT 83The file referred to by 84.Fa path 85does not exist. 86.It Bq Er EACCES 87Search permission is denied for a component of the path prefix of 88.Fa path . 89.It Bq Er ELOOP 90Too many symbolic links were encountered in translating 91.Fa path . 92.It Bq Er EFAULT 93.Fa Buf 94or 95.Fa path 96points to an invalid address. 97.It Bq Er EIO 98An 99.Tn I/O 100error occurred while reading from or writing to the file system. 101.El 102.Pp 103.Fn Fstatfs 104fails if one or more of the following are true: 105.Bl -tag -width ENAMETOOLONGA 106.It Bq Er EBADF 107.Fa Fd 108is not a valid open file descriptor. 109.It Bq Er EFAULT 110.Fa Buf 111points to an invalid address. 112.It Bq Er EIO 113An 114.Tn I/O 115error occurred while reading from or writing to the file system. 116.El 117.Sh HISTORY 118The 119.Nm statfs 120function first appeared in 4.4BSD. 121