1.\" $OpenBSD: statvfs.3,v 1.5 2008/03/26 09:37:59 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 $Mdocdate: March 26 2008 $ 34.Dt STATVFS 3 35.Os 36.Sh NAME 37.Nm statvfs , 38.Nm fstatvfs 39.Nd get file system statistics 40.Sh SYNOPSIS 41.Fd #include <sys/statvfs.h> 42.Ft int 43.Fn statvfs "const char *path" "struct statvfs *buf" 44.Ft int 45.Fn fstatvfs "int fd" "struct statvfs *buf" 46.Sh DESCRIPTION 47.Fn statvfs 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 statvfs 54structure defined as follows: 55.Bd -literal 56struct statvfs { 57 unsigned long f_bsize; /* file system block size */ 58 unsigned long f_frsize; /* fundamental file system block size */ 59 fsblkcnt_t f_blocks; /* number of blocks (unit f_frsize) */ 60 fsblkcnt_t f_bfree; /* free blocks in file system */ 61 fsblkcnt_t f_bavail; /* free blocks for non-root */ 62 fsfilcnt_t f_files; /* total file inodes */ 63 fsfilcnt_t f_ffree; /* free file inodes */ 64 fsfilcnt_t f_favail; /* free file inodes for to non-root */ 65 unsigned long f_fsid; /* file system id */ 66 unsigned long f_flag; /* bit mask of f_flag values */ 67 unsigned long f_namemax; /* maximum filename length */ 68}; 69 70#define ST_RDONLY 0x0001UL /* read-only filesystem */ 71#define ST_NOSUID 0x0002UL /* nosuid flag set */ 72.Ed 73.Pp 74The fields of type 75.Va fsblkcnt_t 76are reported in units of 77.Va f_frsize . 78.Pp 79.Fn fstatvfs 80returns the same information about an open file referenced by descriptor 81.Fa fd . 82.Sh RETURN VALUES 83Upon successful completion, a value of 0 is returned. 84Otherwise, \-1 is returned and the global variable 85.Va errno 86is set to indicate the error. 87.Sh ERRORS 88.Fn statvfs 89fails if one or more of the following are true: 90.Bl -tag -width Er 91.It Bq Er ENOTDIR 92A component of the path prefix of 93.Fa path 94is not a directory. 95.It Bq Er ENAMETOOLONG 96The length of a component of 97.Fa path 98exceeds 99.Dv {NAME_MAX} 100characters, or the length of 101.Fa path 102exceeds 103.Dv {PATH_MAX} 104characters. 105.It Bq Er ENOENT 106The file referred to by 107.Fa path 108does not exist. 109.It Bq Er EACCES 110Search permission is denied for a component of the path prefix of 111.Fa path . 112.It Bq Er ELOOP 113Too many symbolic links were encountered in translating 114.Fa path . 115.It Bq Er EFAULT 116.Fa buf 117or 118.Fa path 119points to an invalid address. 120.It Bq Er EIO 121An 122.Tn I/O 123error occurred while reading from or writing to the file system. 124.El 125.Pp 126.Fn fstatvfs 127fails if one or more of the following are true: 128.Bl -tag -width Er 129.It Bq Er EBADF 130.Fa fd 131is not a valid open file descriptor. 132.It Bq Er EFAULT 133.Fa buf 134points to an invalid address. 135.It Bq Er EIO 136An 137.Tn I/O 138error occurred while reading from or writing to the file system. 139.El 140.Sh SEE ALSO 141.Xr df 1 , 142.Xr mount 2 , 143.Xr stat 2 , 144.Xr statfs 2 145.Sh STANDARDS 146The 147.Fn statvfs 148and 149.Fn fstatvfs 150functions conform to 151.St -p1003.1-2001 . 152.Sh HISTORY 153The 154.Fn statvfs 155and 156.Fn fstatvfs 157functions first appeared in 158.Ox 4.4 . 159