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 $
30 .\" $DragonFly: src/lib/libc/sys/statfs.2,v 1.4 2008/09/28 16:33:35 swildner Exp $
32 .Dd September 28, 2008
38 .Nd get file system statistics
45 .Fn statfs "const char *path" "struct statfs *buf"
47 .Fn fstatfs "int fd" "struct statfs *buf"
50 returns information about a mounted file system.
52 is the path name of any file within the mounted filesystem.
56 structure defined as follows:
58 typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
61 * file system statistics
64 #define MFSNAMELEN 16 /* length of fs type name, including null */
65 #define MNAMELEN 90 /* length of buffer for returned name */
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 */
89 The flags that may be returned include:
90 .Bl -tag -width MNT_SYNCHRONOUS
92 The filesystem is mounted read-only;
93 Even the super-user may not write on it.
95 Files may not be executed from the filesystem.
97 Setuid and setgid bits on files are not honored when they are executed.
99 Special files in the filesystem may not be opened.
100 .It Dv MNT_SYNCHRONOUS
101 All I/O to the filesystem is done synchronously.
103 No filesystem I/O is done synchronously.
105 The filesystem resides locally.
107 The filesystem has quotas enabled on it.
109 Identifies the root filesystem.
111 The filesystem is exported read-only.
113 The filesystem is exported for both reading and writing.
114 .It Dv MNT_DEFEXPORTED
115 The filesystem is exported for both reading and writing to any Internet host.
116 .It Dv MNT_EXPORTANON
117 The filesystem maps all remote accesses to the anonymous user.
119 The filesystem is exported with Kerberos uid mapping.
122 Fields that are undefined for a particular file system are set to -1.
124 returns the same information about an open file referenced by descriptor
130 fails if one or more of the following are true:
133 A component of the path prefix of
136 .It Bq Er ENAMETOOLONG
137 The length of a component of
139 exceeds 255 characters,
142 exceeds 1023 characters.
144 The file referred to by
148 Search permission is denied for a component of the path prefix of
151 Too many symbolic links were encountered in translating
157 points to an invalid address.
161 error occurred while reading from or writing to the file system.
165 fails if one or more of the following are true:
169 is not a valid open file descriptor.
172 points to an invalid address.
176 error occurred while reading from or writing to the file system.
184 function first appeared in