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