1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)statfs.2 8.5 (Berkeley) 5/24/95 33.\" $FreeBSD: src/lib/libc/sys/statfs.2,v 1.9.2.7 2001/12/14 18:34:01 ru Exp $ 34.\" $DragonFly: src/lib/libc/sys/statfs.2,v 1.2 2003/06/17 04:26:47 dillon Exp $ 35.\" 36.Dd May 24, 1995 37.Dt STATFS 2 38.Os 39.Sh NAME 40.Nm statfs 41.Nd get file system statistics 42.Sh LIBRARY 43.Lb libc 44.Sh SYNOPSIS 45.In sys/param.h 46.In sys/mount.h 47.Ft int 48.Fn statfs "const char *path" "struct statfs *buf" 49.Ft int 50.Fn fstatfs "int fd" "struct statfs *buf" 51.Sh DESCRIPTION 52.Fn Statfs 53returns information about a mounted file system. 54.Fa Path 55is the path name of any file within the mounted filesystem. 56.Fa Buf 57is a pointer to a 58.Fn statfs 59structure defined as follows: 60.Bd -literal 61typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ 62 63/* 64 * file system statistics 65 */ 66 67#define MFSNAMELEN 16 /* length of fs type name, including null */ 68#define MNAMELEN 90 /* length of buffer for returned name */ 69 70struct statfs { 71long f_bsize; /* fundamental file system block size */ 72long f_iosize; /* optimal transfer block size */ 73long f_blocks; /* total data blocks in file system */ 74long f_bfree; /* free blocks in fs */ 75long f_bavail; /* free blocks avail to non-superuser */ 76long f_files; /* total file nodes in file system */ 77long f_ffree; /* free file nodes in fs */ 78fsid_t f_fsid; /* file system id */ 79uid_t f_owner; /* user that mounted the filesystem */ 80int f_type; /* type of filesystem */ 81int f_flags; /* copy of mount flags */ 82long f_syncwrites; /* count of sync writes since mount */ 83long f_asyncwrites; /* count of async writes since mount */ 84char f_fstypename[MFSNAMELEN];/* fs type name */ 85char f_mntonname[MNAMELEN]; /* mount point */ 86long f_syncreads; /* count of sync reads since mount */ 87long f_asyncreads; /* count of async reads since mount */ 88char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 89}; 90.Ed 91The flags that may be returned include: 92.Bl -tag -width MNT_SYNCHRONOUS 93.It Dv MNT_RDONLY 94The filesystem is mounted read-only; 95Even the super-user may not write on it. 96.It Dv MNT_NOEXEC 97Files may not be executed from the filesystem. 98.It Dv MNT_NOSUID 99Setuid and setgid bits on files are not honored when they are executed. 100.It Dv MNT_NODEV 101Special files in the filesystem may not be opened. 102.It Dv MNT_SYNCHRONOUS 103All I/O to the filesystem is done synchronously. 104.It Dv MNT_ASYNC 105No filesystem I/O is done synchronously. 106.It Dv MNT_LOCAL 107The filesystem resides locally. 108.It Dv MNT_QUOTA 109The filesystem has quotas enabled on it. 110.It Dv MNT_ROOTFS 111Identifies the root filesystem. 112.It Dv MNT_EXRDONLY 113The filesystem is exported read-only. 114.It Dv MNT_EXPORTED 115The filesystem is exported for both reading and writing. 116.It Dv MNT_DEFEXPORTED 117The filesystem is exported for both reading and writing to any Internet host. 118.It Dv MNT_EXPORTANON 119The filesystem maps all remote accesses to the anonymous user. 120.It Dv MNT_EXKERB 121The filesystem is exported with Kerberos uid mapping. 122.El 123.Pp 124Fields that are undefined for a particular file system are set to -1. 125.Fn Fstatfs 126returns the same information about an open file referenced by descriptor 127.Fa fd . 128.Sh RETURN VALUES 129.Rv -std 130.Sh ERRORS 131.Fn Statfs 132fails if one or more of the following are true: 133.Bl -tag -width Er 134.It Bq Er ENOTDIR 135A component of the path prefix of 136.Fa Path 137is not a directory. 138.It Bq Er ENAMETOOLONG 139The length of a component of 140.Fa path 141exceeds 255 characters, 142or the length of 143.Fa path 144exceeds 1023 characters. 145.It Bq Er ENOENT 146The file referred to by 147.Fa path 148does not exist. 149.It Bq Er EACCES 150Search permission is denied for a component of the path prefix of 151.Fa path . 152.It Bq Er ELOOP 153Too many symbolic links were encountered in translating 154.Fa path . 155.It Bq Er EFAULT 156.Fa Buf 157or 158.Fa path 159points to an invalid address. 160.It Bq Er EIO 161An 162.Tn I/O 163error occurred while reading from or writing to the file system. 164.El 165.Pp 166.Fn Fstatfs 167fails if one or more of the following are true: 168.Bl -tag -width Er 169.It Bq Er EBADF 170.Fa fd 171is not a valid open file descriptor. 172.It Bq Er EFAULT 173.Fa Buf 174points to an invalid address. 175.It Bq Er EIO 176An 177.Tn I/O 178error occurred while reading from or writing to the file system. 179.El 180.Sh HISTORY 181The 182.Fn statfs 183function first appeared in 184.Bx 4.4 . 185