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