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.3 2007/02/25 18:35:05 swildner Exp $ 35.\" 36.Dd May 24, 1995 37.Dt STATFS 2 38.Os 39.Sh NAME 40.Nm statfs , 41.Nm fstatfs 42.Nd get file system statistics 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In sys/param.h 47.In sys/mount.h 48.Ft int 49.Fn statfs "const char *path" "struct statfs *buf" 50.Ft int 51.Fn fstatfs "int fd" "struct statfs *buf" 52.Sh DESCRIPTION 53.Fn Statfs 54returns information about a mounted file system. 55.Fa Path 56is the path name of any file within the mounted filesystem. 57.Fa Buf 58is a pointer to a 59.Fn statfs 60structure defined as follows: 61.Bd -literal 62typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ 63 64/* 65 * file system statistics 66 */ 67 68#define MFSNAMELEN 16 /* length of fs type name, including null */ 69#define MNAMELEN 90 /* length of buffer for returned name */ 70 71struct statfs { 72long f_bsize; /* fundamental file system block size */ 73long f_iosize; /* optimal transfer block size */ 74long f_blocks; /* total data blocks in file system */ 75long f_bfree; /* free blocks in fs */ 76long f_bavail; /* free blocks avail to non-superuser */ 77long f_files; /* total file nodes in file system */ 78long f_ffree; /* free file nodes in fs */ 79fsid_t f_fsid; /* file system id */ 80uid_t f_owner; /* user that mounted the filesystem */ 81int f_type; /* type of filesystem */ 82int f_flags; /* copy of mount flags */ 83long f_syncwrites; /* count of sync writes since mount */ 84long f_asyncwrites; /* count of async writes since mount */ 85char f_fstypename[MFSNAMELEN];/* fs type name */ 86char f_mntonname[MNAMELEN]; /* mount point */ 87long f_syncreads; /* count of sync reads since mount */ 88long f_asyncreads; /* count of async reads since mount */ 89char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 90}; 91.Ed 92The flags that may be returned include: 93.Bl -tag -width MNT_SYNCHRONOUS 94.It Dv MNT_RDONLY 95The filesystem is mounted read-only; 96Even the super-user may not write on it. 97.It Dv MNT_NOEXEC 98Files may not be executed from the filesystem. 99.It Dv MNT_NOSUID 100Setuid and setgid bits on files are not honored when they are executed. 101.It Dv MNT_NODEV 102Special files in the filesystem may not be opened. 103.It Dv MNT_SYNCHRONOUS 104All I/O to the filesystem is done synchronously. 105.It Dv MNT_ASYNC 106No filesystem I/O is done synchronously. 107.It Dv MNT_LOCAL 108The filesystem resides locally. 109.It Dv MNT_QUOTA 110The filesystem has quotas enabled on it. 111.It Dv MNT_ROOTFS 112Identifies the root filesystem. 113.It Dv MNT_EXRDONLY 114The filesystem is exported read-only. 115.It Dv MNT_EXPORTED 116The filesystem is exported for both reading and writing. 117.It Dv MNT_DEFEXPORTED 118The filesystem is exported for both reading and writing to any Internet host. 119.It Dv MNT_EXPORTANON 120The filesystem maps all remote accesses to the anonymous user. 121.It Dv MNT_EXKERB 122The filesystem is exported with Kerberos uid mapping. 123.El 124.Pp 125Fields that are undefined for a particular file system are set to -1. 126.Fn Fstatfs 127returns the same information about an open file referenced by descriptor 128.Fa fd . 129.Sh RETURN VALUES 130.Rv -std 131.Sh ERRORS 132.Fn Statfs 133fails if one or more of the following are true: 134.Bl -tag -width Er 135.It Bq Er ENOTDIR 136A component of the path prefix of 137.Fa Path 138is not a directory. 139.It Bq Er ENAMETOOLONG 140The length of a component of 141.Fa path 142exceeds 255 characters, 143or the length of 144.Fa path 145exceeds 1023 characters. 146.It Bq Er ENOENT 147The file referred to by 148.Fa path 149does not exist. 150.It Bq Er EACCES 151Search permission is denied for a component of the path prefix of 152.Fa path . 153.It Bq Er ELOOP 154Too many symbolic links were encountered in translating 155.Fa path . 156.It Bq Er EFAULT 157.Fa Buf 158or 159.Fa path 160points to an invalid address. 161.It Bq Er EIO 162An 163.Tn I/O 164error occurred while reading from or writing to the file system. 165.El 166.Pp 167.Fn Fstatfs 168fails if one or more of the following are true: 169.Bl -tag -width Er 170.It Bq Er EBADF 171.Fa fd 172is not a valid open file descriptor. 173.It Bq Er EFAULT 174.Fa Buf 175points to an invalid address. 176.It Bq Er EIO 177An 178.Tn I/O 179error occurred while reading from or writing to the file system. 180.El 181.Sh HISTORY 182The 183.Fn statfs 184function first appeared in 185.Bx 4.4 . 186