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