1.\" $OpenBSD: statvfs.3,v 1.9 2022/02/11 15:11:35 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. 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: February 11 2022 $ 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.In 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 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.Vt fsblkcnt_t 76are reported in units of 77.Fa 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 83.Rv -std 84.Sh ERRORS 85.Fn statvfs 86fails if one or more of the following are true: 87.Bl -tag -width Er 88.It Bq Er ENOTDIR 89A component of the path prefix of 90.Fa path 91is not a directory. 92.It Bq Er ENAMETOOLONG 93A component of a pathname exceeded 94.Dv NAME_MAX 95characters, or an entire pathname (including the terminating NUL) 96exceeded 97.Dv PATH_MAX 98bytes. 99.It Bq Er ENOENT 100The file referred to by 101.Fa path 102does not exist. 103.It Bq Er EACCES 104Search permission is denied for a component of the path prefix of 105.Fa path . 106.It Bq Er ELOOP 107Too many symbolic links were encountered in translating 108.Fa path . 109.It Bq Er EFAULT 110.Fa buf 111or 112.Fa path 113points to an invalid address. 114.It Bq Er EIO 115An I/O error occurred while reading from or writing to the file system. 116.El 117.Pp 118.Fn fstatvfs 119fails if one or more of the following are true: 120.Bl -tag -width Er 121.It Bq Er EBADF 122.Fa fd 123is not a valid open file descriptor. 124.It Bq Er EFAULT 125.Fa buf 126points to an invalid address. 127.It Bq Er EIO 128An I/O error occurred while reading from or writing to the file system. 129.El 130.Sh SEE ALSO 131.Xr df 1 , 132.Xr mount 2 , 133.Xr stat 2 , 134.Xr statfs 2 135.Sh STANDARDS 136The 137.Fn statvfs 138and 139.Fn fstatvfs 140functions conform to 141.St -p1003.1-2001 . 142.Sh HISTORY 143The 144.Fn statvfs 145and 146.Fn fstatvfs 147functions first appeared in 148.Ox 4.4 . 149