1.\" $OpenBSD: statfs.2,v 1.13 2000/03/24 19:07:49 millert Exp $ 2.\" $NetBSD: statfs.2,v 1.10 1995/06/29 11:40:48 cgd Exp $ 3.\" 4.\" Copyright (c) 1989, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)statfs.2 8.3 (Berkeley) 2/11/94 36.\" 37.Dd February 11, 1994 38.Dt STATFS 2 39.Os 40.Sh NAME 41.Nm statfs 42.Nd get file system statistics 43.Sh SYNOPSIS 44.Fd #include <sys/param.h> 45.Fd #include <sys/mount.h> 46.Ft int 47.Fn statfs "const char *path" "struct statfs *buf" 48.Ft int 49.Fn fstatfs "int fd" "struct statfs *buf" 50.Sh DESCRIPTION 51.Fn statfs 52returns information about a mounted file system. 53.Fa path 54is the path name of any file within the mounted file system. 55.Fa buf 56is a pointer to a 57.Nm statfs 58structure defined as follows: 59.Bd -literal 60typedef struct { int32_t val[2]; } fsid_t; 61 62#define MFSNAMELEN 16 /* length of fs type name, including NUL */ 63#define MNAMELEN 32 /* length of buffer for returned name */ 64 65struct statfs { 66 u_int32_t f_flags; /* copy of mount flags */ 67 int32_t f_bsize; /* fundamental file system block size */ 68 u_int32_t f_iosize; /* optimal transfer block size */ 69 u_int32_t f_blocks; /* total data blocks in file system */ 70 u_int32_t f_bfree; /* free blocks in fs */ 71 int32_t f_bavail; /* free blocks avail to non-superuser */ 72 u_int32_t f_files; /* total file nodes in file system */ 73 u_int32_t f_ffree; /* free file nodes in fs */ 74 fsid_t f_fsid; /* file system id */ 75 uid_t f_owner; /* user that mounted the file system */ 76 u_int32_t f_syncwrites; /* count of sync writes since mount */ 77 u_int32_t f_asyncwrites; /* count of async writes since mount */ 78 u_int32_t f_spare[4]; /* spare for later */ 79 char f_fstypename[MFSNAMELEN]; /* fs type name */ 80 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 81 char f_mntfromname[MNAMELEN]; /* mounted file system */ 82 union mount_info mount_info; /* per-filesystem mount options */ 83}; 84.Ed 85.Pp 86.Fn fstatfs 87returns the same information about an open file referenced by descriptor 88.Fa fd . 89.Sh RETURN VALUES 90Upon successful completion, a value of 0 is returned. 91Otherwise, \-1 is returned and the global variable 92.Va errno 93is set to indicate the error. 94.Sh ERRORS 95.Fn statfs 96fails if one or more of the following are true: 97.Bl -tag -width Er 98.It Bq Er ENOTDIR 99A component of the path prefix of 100.Fa path 101is not a directory. 102.It Bq Er ENAMETOOLONG 103The length of a component of 104.Fa path 105exceeds 106.Dv {NAME_MAX} 107characters, or the length of 108.Fa path 109exceeds 110.Dv {PATH_MAX} 111characters. 112.It Bq Er ENOENT 113The file referred to by 114.Fa path 115does not exist. 116.It Bq Er EACCES 117Search permission is denied for a component of the path prefix of 118.Fa path . 119.It Bq Er ELOOP 120Too many symbolic links were encountered in translating 121.Fa path . 122.It Bq Er EFAULT 123.Fa buf 124or 125.Fa path 126points to an invalid address. 127.It Bq Er EIO 128An 129.Tn I/O 130error occurred while reading from or writing to the file system. 131.El 132.Pp 133.Fn fstatfs 134fails if one or more of the following are true: 135.Bl -tag -width Er 136.It Bq Er EBADF 137.Fa fd 138is not a valid open file descriptor. 139.It Bq Er EFAULT 140.Fa buf 141points to an invalid address. 142.It Bq Er EIO 143An 144.Tn I/O 145error occurred while reading from or writing to the file system. 146.El 147.Sh SEE ALSO 148.Xr df 1 , 149.Xr mount 2 , 150.Xr stat 2 151.Sh HISTORY 152The 153.Fn statfs 154function first appeared in 155.Bx 4.4 . 156