1 .\" Copyright (c) 1989, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
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 $
31 .Dd September 28, 2008
37 .Nd get file system statistics
44 .Fn statfs "const char *path" "struct statfs *buf"
46 .Fn fstatfs "int fd" "struct statfs *buf"
49 returns information about a mounted file system.
51 is the path name of any file within the mounted filesystem.
55 structure defined as follows:
57 typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
60 * file system statistics
63 #define MFSNAMELEN 16 /* length of fs type name, including null */
64 #define MNAMELEN 90 /* length of buffer for returned name */
67 long f_bsize; /* fundamental file system block size */
68 long f_iosize; /* optimal transfer block size */
69 long f_blocks; /* total data blocks in file system */
70 long f_bfree; /* free blocks in fs */
71 long f_bavail; /* free blocks avail to non-superuser */
72 long f_files; /* total file nodes in file system */
73 long f_ffree; /* free file nodes in fs */
74 fsid_t f_fsid; /* file system id */
75 uid_t f_owner; /* user that mounted the filesystem */
76 int f_type; /* type of filesystem */
77 int f_flags; /* copy of mount exported flags */
78 long f_syncwrites; /* count of sync writes since mount */
79 long f_asyncwrites; /* count of async writes since mount */
80 char f_fstypename[MFSNAMELEN]; /* fs type name */
81 char f_mntonname[MNAMELEN]; /* directory on which mounted */
82 long f_syncreads; /* count of sync reads since mount */
83 long f_asyncreads; /* count of async reads since mount */
84 char f_mntfromname[MNAMELEN];/* mounted filesystem */
88 The flags that may be returned include:
89 .Bl -tag -width ".Dv MNT_SYNCHRONOUS"
91 The filesystem is mounted read-only;
92 Even the super-user may not write on it.
94 Files may not be executed from the filesystem.
96 Setuid and setgid bits on files are not honored when they are executed.
98 Special files in the filesystem may not be opened.
99 .It Dv MNT_SYNCHRONOUS
100 All I/O to the filesystem is done synchronously.
102 No filesystem I/O is done synchronously.
104 The filesystem resides locally.
106 The filesystem has quotas enabled on it.
108 Identifies the root filesystem.
110 The filesystem is exported read-only.
112 The filesystem is exported for both reading and writing.
113 .It Dv MNT_DEFEXPORTED
114 The filesystem is exported for both reading and writing to any Internet host.
115 .It Dv MNT_EXPORTANON
116 The filesystem maps all remote accesses to the anonymous user.
118 The filesystem is exported with Kerberos uid mapping.
121 Fields that are undefined for a particular file system are set to -1.
123 returns the same information about an open file referenced by descriptor
129 fails if one or more of the following are true:
132 A component of the path prefix of
135 .It Bq Er ENAMETOOLONG
136 The length of a component of
138 exceeds 255 characters,
141 exceeds 1023 characters.
143 The file referred to by
147 Search permission is denied for a component of the path prefix of
150 Too many symbolic links were encountered in translating
156 points to an invalid address.
160 error occurred while reading from or writing to the file system.
164 fails if one or more of the following are true:
168 is not a valid open file descriptor.
171 points to an invalid address.
175 error occurred while reading from or writing to the file system.
183 function first appeared in