1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified 2003-08-17 by Walter Harms
6 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
8 .TH statfs 2 (date) "Linux man-pages (unreleased)"
10 statfs, fstatfs \- get filesystem statistics
13 .RI ( libc ", " \-lc )
16 .BR "#include <sys/vfs.h> " "/* or <sys/statfs.h> */"
18 .BI "int statfs(const char *" path ", struct statfs *" buf );
19 .BI "int fstatfs(int " fd ", struct statfs *" buf );
24 field, you should use the standard
30 system call returns information about a mounted filesystem.
32 is the pathname of any file within the mounted filesystem.
36 structure defined approximately as follows:
41 __fsword_t f_type; /* Type of filesystem (see below) */
42 __fsword_t f_bsize; /* Optimal transfer block size */
43 fsblkcnt_t f_blocks; /* Total data blocks in filesystem */
44 fsblkcnt_t f_bfree; /* Free blocks in filesystem */
45 fsblkcnt_t f_bavail; /* Free blocks available to
47 fsfilcnt_t f_files; /* Total inodes in filesystem */
48 fsfilcnt_t f_ffree; /* Free inodes in filesystem */
49 fsid_t f_fsid; /* Filesystem ID */
50 __fsword_t f_namelen; /* Maximum length of filenames */
51 __fsword_t f_frsize; /* Fragment size (since Linux 2.6) */
52 __fsword_t f_flags; /* Mount flags of filesystem
53 (since Linux 2.6.36) */
54 __fsword_t f_spare[xxx];
55 /* Padding bytes reserved for future use */
60 The following filesystem types may appear in
65 ADFS_SUPER_MAGIC 0xadf5
66 AFFS_SUPER_MAGIC 0xadff
67 AFS_SUPER_MAGIC 0x5346414f
68 ANON_INODE_FS_MAGIC 0x09041934 /* Anonymous inode FS (for
69 pseudofiles that have no name;
70 e.g., epoll, signalfd, bpf) */
71 AUTOFS_SUPER_MAGIC 0x0187
72 BDEVFS_MAGIC 0x62646576
73 BEFS_SUPER_MAGIC 0x42465331
75 BINFMTFS_MAGIC 0x42494e4d
76 BPF_FS_MAGIC 0xcafe4a11
77 BTRFS_SUPER_MAGIC 0x9123683e
78 BTRFS_TEST_MAGIC 0x73727279
79 CGROUP_SUPER_MAGIC 0x27e0eb /* Cgroup pseudo FS */
80 CGROUP2_SUPER_MAGIC 0x63677270 /* Cgroup v2 pseudo FS */
81 CIFS_MAGIC_NUMBER 0xff534d42
82 CODA_SUPER_MAGIC 0x73757245
83 COH_SUPER_MAGIC 0x012ff7b7
84 CRAMFS_MAGIC 0x28cd3d45
85 DEBUGFS_MAGIC 0x64626720
86 DEVFS_SUPER_MAGIC 0x1373 /* Linux 2.6.17 and earlier */
87 DEVPTS_SUPER_MAGIC 0x1cd1
88 ECRYPTFS_SUPER_MAGIC 0xf15f
89 EFIVARFS_MAGIC 0xde5e81e4
90 EFS_SUPER_MAGIC 0x00414a53
91 EXT_SUPER_MAGIC 0x137d /* Linux 2.0 and earlier */
92 EXT2_OLD_SUPER_MAGIC 0xef51
93 EXT2_SUPER_MAGIC 0xef53
94 EXT3_SUPER_MAGIC 0xef53
95 EXT4_SUPER_MAGIC 0xef53
96 F2FS_SUPER_MAGIC 0xf2f52010
97 FUSE_SUPER_MAGIC 0x65735546
98 FUTEXFS_SUPER_MAGIC 0xbad1dea /* Unused */
99 HFS_SUPER_MAGIC 0x4244
100 HOSTFS_SUPER_MAGIC 0x00c0ffee
101 HPFS_SUPER_MAGIC 0xf995e849
102 HUGETLBFS_MAGIC 0x958458f6
103 ISOFS_SUPER_MAGIC 0x9660
104 JFFS2_SUPER_MAGIC 0x72b6
105 JFS_SUPER_MAGIC 0x3153464a
106 MINIX_SUPER_MAGIC 0x137f /* original minix FS */
107 MINIX_SUPER_MAGIC2 0x138f /* 30 char minix FS */
108 MINIX2_SUPER_MAGIC 0x2468 /* minix V2 FS */
109 MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 FS, 30 char names */
110 MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 FS, 60 char names */
111 MQUEUE_MAGIC 0x19800202 /* POSIX message queue FS */
112 MSDOS_SUPER_MAGIC 0x4d44
113 MTD_INODE_FS_MAGIC 0x11307854
114 NCP_SUPER_MAGIC 0x564c
115 NFS_SUPER_MAGIC 0x6969
116 NILFS_SUPER_MAGIC 0x3434
117 NSFS_MAGIC 0x6e736673
118 NTFS_SB_MAGIC 0x5346544e
119 OCFS2_SUPER_MAGIC 0x7461636f
120 OPENPROM_SUPER_MAGIC 0x9fa1
121 OVERLAYFS_SUPER_MAGIC 0x794c7630
122 PIPEFS_MAGIC 0x50495045
123 PROC_SUPER_MAGIC 0x9fa0 /* /proc FS */
124 PSTOREFS_MAGIC 0x6165676c
125 QNX4_SUPER_MAGIC 0x002f
126 QNX6_SUPER_MAGIC 0x68191122
127 RAMFS_MAGIC 0x858458f6
128 REISERFS_SUPER_MAGIC 0x52654973
130 SECURITYFS_MAGIC 0x73636673
131 SELINUX_MAGIC 0xf97cff8c
132 SMACK_MAGIC 0x43415d53
133 SMB_SUPER_MAGIC 0x517b
134 SMB2_MAGIC_NUMBER 0xfe534d42
135 SOCKFS_MAGIC 0x534f434b
136 SQUASHFS_MAGIC 0x73717368
137 SYSFS_MAGIC 0x62656572
138 SYSV2_SUPER_MAGIC 0x012ff7b6
139 SYSV4_SUPER_MAGIC 0x012ff7b5
140 TMPFS_MAGIC 0x01021994
141 TRACEFS_MAGIC 0x74726163
142 UDF_SUPER_MAGIC 0x15013346
144 USBDEVICE_SUPER_MAGIC 0x9fa2
145 V9FS_MAGIC 0x01021997
146 VXFS_SUPER_MAGIC 0xa501fcf5
147 XENFS_SUPER_MAGIC 0xabba1974
148 XENIX_SUPER_MAGIC 0x012ff7b4
149 XFS_SUPER_MAGIC 0x58465342
150 _XIAFS_SUPER_MAGIC 0x012fd16d /* Linux 2.0 and earlier */
154 Most of these MAGIC constants are defined in
155 .IR /usr/include/linux/magic.h ,
156 and some are hardcoded in kernel sources.
160 field is a bit mask indicating mount options for the filesystem.
161 It contains zero or more of the following bits:
162 .\" XXX Keep this list in sync with statvfs(3)
165 Mandatory locking is permitted on the filesystem (see
169 Do not update access times; see
173 Disallow access to device special files on this filesystem.
176 Do not update directory access times; see
180 Execution of programs is disallowed on this filesystem.
183 The set-user-ID and set-group-ID bits are ignored by
185 for executable files on this filesystem
188 This filesystem is mounted read-only.
191 Update atime relative to mtime/ctime; see
195 Writes are synched to the filesystem immediately (see the description of
200 .BR ST_NOSYMFOLLOW " (since Linux 5.10)"
201 .\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e
202 Symbolic links are not followed when resolving paths; see
207 is supposed to contain (but see below).
209 Fields that are undefined for a particular filesystem are set to 0.
212 returns the same information about an open file referenced by descriptor
215 On success, zero is returned.
216 On error, \-1 is returned, and
218 is set to indicate the error.
223 Search permission is denied for a component of the path prefix of
226 .BR path_resolution (7).)
231 is not a valid open file descriptor.
237 points to an invalid address.
240 The call was interrupted by a signal; see
244 An I/O error occurred while reading from the filesystem.
248 Too many symbolic links were encountered in translating
258 The file referred to by
263 Insufficient kernel memory was available.
266 The filesystem does not support this call.
270 A component of the path prefix of
275 Some values were too large to be represented in the returned struct.
278 Solaris, Irix, and POSIX have a system call
283 .IR <sys/statvfs.h> )
287 Linux, SunOS, HP-UX, 4.4BSD have a system call
299 .IR "struct { int val[2]; }" .
300 The same holds for FreeBSD, except that it uses the include file
303 The general idea is that
305 contains some random stuff such that the pair
307 uniquely determines a file.
308 Some operating systems use (a variation on) the device number,
309 or the device number combined with the filesystem type.
310 Several operating systems restrict giving out the
312 field to the superuser only (and zero it for unprivileged users),
313 because this field is used in the filehandle of the filesystem
314 when NFS-exported, and giving it out is a security concern.
316 Under some operating systems, the
318 can be used as the second argument to the
326 was inspired by the 4.4BSD one
327 (but they do not use the same structure).
333 system calls were not designed with extremely large file sizes in mind.
334 Subsequently, Linux 2.6
339 system calls that employ a new structure,
341 The new structure contains the same fields as the original
343 structure, but the sizes of various fields are increased,
344 to accommodate large file sizes.
349 wrapper functions transparently deal with the kernel differences.
351 LSB has deprecated the library calls
363 type used for various fields in the
365 structure definition is a glibc internal type,
366 not intended for public use.
367 This leaves the programmer in a bit of a conundrum when trying to copy
368 or compare these fields to local variables in a program.
371 for such variables suffices on most systems.
373 Some systems have only \fI<sys/vfs.h>\fP, other systems also have
374 \fI<sys/statfs.h>\fP, where the former includes the latter.
376 including the former is the best choice.
378 From Linux 2.6.38 up to and including Linux 3.1,
379 .\" broken in commit ff0c7d15f9787b7e8c601533c015295cc68329f8
380 .\" fixed in commit d70ef97baf048412c395bb5d65791d8fe133a52b
382 failed with the error
384 for file descriptors created by
389 .BR path_resolution (7)