1.\" Copyright (c) 1989, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)statfs.2 6.8 (Berkeley) 01/06/93 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 MNAMELEN 32 /* length of buffer for returned name */ 34 35struct statfs { 36short f_type; /* type of filesystem (see below) */ 37short f_flags; /* copy of mount flags */ 38long f_bsize; /* fundamental file system block size */ 39long f_iosize; /* optimal transfer block size */ 40long f_blocks; /* total data blocks in file system */ 41long f_bfree; /* free blocks in fs */ 42long f_bavail; /* free blocks avail to non-superuser */ 43long f_files; /* total file nodes in file system */ 44long f_ffree; /* free file nodes in fs */ 45fsid_t f_fsid; /* file system id */ 46long f_spare[6]; /* spare for later */ 47char f_mntonname[MNAMELEN]; /* mount point */ 48char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 49}; 50/* 51* File system types. 52*/ 53#define MOUNT_UFS 1 54#define MOUNT_NFS 2 55#define MOUNT_MFS 3 56#define MOUNT_PC 4 57.Ed 58.Pp 59Fields that are undefined for a particular file system are set to -1. 60.Fn Fstatfs 61returns the same information about an open file referenced by descriptor 62.Fa fd . 63.Sh RETURN VALUES 64Upon successful completion, a value of 0 is returned. 65Otherwise, -1 is returned and the global variable 66.Va errno 67is set to indicate the error. 68.Sh ERRORS 69.Fn Statfs 70fails if one or more of the following are true: 71.Bl -tag -width ENAMETOOLONGA 72.It Bq Er ENOTDIR 73A component of the path prefix of 74.Fa Path 75is not a directory. 76.It Bq Er EINVAL 77.Fa path 78contains a character with the high-order bit set. 79.It Bq Er ENAMETOOLONG 80The length of a component of 81.Fa path 82exceeds 255 characters, 83or the length of 84.Fa path 85exceeds 1023 characters. 86.It Bq Er ENOENT 87The file referred to by 88.Fa path 89does not exist. 90.It Bq Er EACCES 91Search permission is denied for a component of the path prefix of 92.Fa path . 93.It Bq Er ELOOP 94Too many symbolic links were encountered in translating 95.Fa path . 96.It Bq Er EFAULT 97.Fa Buf 98or 99.Fa path 100points to an invalid address. 101.It Bq Er EIO 102An 103.Tn I/O 104error occurred while reading from or writing to the file system. 105.El 106.Pp 107.Fn Fstatfs 108fails if one or both of the following are true: 109.Bl -tag -width ENAMETOOLONGA 110.It Bq Er EBADF 111.Fa Fd 112is not a valid open file descriptor. 113.It Bq Er EFAULT 114.Fa Buf 115points to an invalid address. 116.It Bq Er EIO 117An 118.Tn I/O 119error occurred while reading from or writing to the file system. 120.El 121.Sh HISTORY 122The 123.Nm statfs 124function call is 125.Ud . 126