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
35 .Nd get file system statistics
42 .Fn statfs "const char *path" "struct statfs *buf"
44 .Fn fstatfs "int fd" "struct statfs *buf"
49 returns information about a mounted file system.
53 is the path name of any file within the mounted file system.
59 structure defined as follows:
61 typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
64 * filesystem statistics
67 #define MFSNAMELEN 16 /* length of type name including null */
68 #define MNAMELEN 1024 /* size of on/from name bufs */
69 #define STATFS_VERSION 0x20140518 /* current version number */
72 uint32_t f_version; /* structure version number */
73 uint32_t f_type; /* type of filesystem */
74 uint64_t f_flags; /* copy of mount exported flags */
75 uint64_t f_bsize; /* filesystem fragment size */
76 uint64_t f_iosize; /* optimal transfer block size */
77 uint64_t f_blocks; /* total data blocks in filesystem */
78 uint64_t f_bfree; /* free blocks in filesystem */
79 int64_t f_bavail; /* free blocks avail to non-superuser */
80 uint64_t f_files; /* total file nodes in filesystem */
81 int64_t f_ffree; /* free nodes avail to non-superuser */
82 uint64_t f_syncwrites; /* count of sync writes since mount */
83 uint64_t f_asyncwrites; /* count of async writes since mount */
84 uint64_t f_syncreads; /* count of sync reads since mount */
85 uint64_t f_asyncreads; /* count of async reads since mount */
86 uint64_t f_spare[10]; /* unused spare */
87 uint32_t f_namemax; /* maximum filename length */
88 uid_t f_owner; /* user that mounted the filesystem */
89 fsid_t f_fsid; /* filesystem id */
90 char f_charspare[80]; /* spare string space */
91 char f_fstypename[MFSNAMELEN]; /* filesystem type name */
92 char f_mntfromname[MNAMELEN]; /* mounted filesystem */
93 char f_mntonname[MNAMELEN]; /* directory on which mounted */
97 The flags that may be returned include:
98 .Bl -tag -width MNT_SYNCHRONOUS
100 The file system is mounted read-only;
101 Even the super-user may not write on it.
103 Files may not be executed from the file system.
105 Setuid and setgid bits on files are not honored when they are executed.
106 .It Dv MNT_SYNCHRONOUS
107 All I/O to the file system is done synchronously.
109 No file system I/O is done synchronously.
111 Soft updates being done (see
114 Journaling with gjournal is enabled (see
117 Special handling of SUID bit on directories.
119 Union with underlying file system.
120 .It Dv MNT_NOSYMFOLLOW
121 Symbolic links are not followed.
122 .It Dv MNT_NOCLUSTERR
123 Read clustering is disabled.
124 .It Dv MNT_NOCLUSTERW
125 Write clustering is disabled.
126 .\".It Dv MNT_JAILDEVFS
128 .It Dv MNT_MULTILABEL
129 Mandatory Access Control (MAC) support for individual objects
133 Access Control List (ACL) support enabled.
135 The file system resides locally.
137 The file system has quotas enabled on it.
139 Identifies the root file system.
141 The file system is exported read-only.
143 Updating of file access times is disabled.
145 The file system has been mounted by a user.
149 The file system is exported for both reading and writing.
150 .It Dv MNT_DEFEXPORTED
151 The file system is exported for both reading and writing to any Internet host.
152 .It Dv MNT_EXPORTANON
153 The file system maps all remote accesses to the anonymous user.
155 The file system is exported with Kerberos uid mapping.
157 The file system is exported publicly (WebNFS).
160 Fields that are undefined for a particular file system are set to -1.
164 returns the same information about an open file referenced by descriptor
172 fails if one or more of the following are true:
175 A component of the path prefix of
178 .It Bq Er ENAMETOOLONG
179 The length of a component of
181 exceeds 255 characters,
184 exceeds 1023 characters.
186 The file referred to by
190 Search permission is denied for a component of the path prefix of
193 Too many symbolic links were encountered in translating
201 points to an invalid address.
205 error occurred while reading from or writing to the file system.
207 Corrupted data was detected while reading from the file system.
213 fails if one or more of the following are true:
219 is not a valid open file descriptor.
224 points to an invalid address.
228 error occurred while reading from or writing to the file system.
230 Corrupted data was detected while reading from the file system.
235 structure have been defined to provide the parameters relevant for
239 For some other file systems, values that have similar, but not
240 identical, semantics to those described above may be returned.
241 An example is msdosfs, which in case of FAT12 or FAT16 file systems
242 reports the number of available and of free root directory entries
245 where 1 to 21 such directory entries are required to store
246 each file or directory name or disk label
254 system call first appeared in