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 2021-03-22 "Linux" "Linux Programmer's Manual"
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 system call returns information about a mounted filesystem.
26 is the pathname of any file within the mounted filesystem.
30 structure defined approximately as follows:
35 __fsword_t f_type; /* Type of filesystem (see below) */
36 __fsword_t f_bsize; /* Optimal transfer block size */
37 fsblkcnt_t f_blocks; /* Total data blocks in filesystem */
38 fsblkcnt_t f_bfree; /* Free blocks in filesystem */
39 fsblkcnt_t f_bavail; /* Free blocks available to
41 fsfilcnt_t f_files; /* Total inodes in filesystem */
42 fsfilcnt_t f_ffree; /* Free inodes in filesystem */
43 fsid_t f_fsid; /* Filesystem ID */
44 __fsword_t f_namelen; /* Maximum length of filenames */
45 __fsword_t f_frsize; /* Fragment size (since Linux 2.6) */
46 __fsword_t f_flags; /* Mount flags of filesystem
47 (since Linux 2.6.36) */
48 __fsword_t f_spare[xxx];
49 /* Padding bytes reserved for future use */
54 The following filesystem types may appear in
59 ADFS_SUPER_MAGIC 0xadf5
60 AFFS_SUPER_MAGIC 0xadff
61 AFS_SUPER_MAGIC 0x5346414f
62 ANON_INODE_FS_MAGIC 0x09041934 /* Anonymous inode FS (for
63 pseudofiles that have no name;
64 e.g., epoll, signalfd, bpf) */
65 AUTOFS_SUPER_MAGIC 0x0187
66 BDEVFS_MAGIC 0x62646576
67 BEFS_SUPER_MAGIC 0x42465331
69 BINFMTFS_MAGIC 0x42494e4d
70 BPF_FS_MAGIC 0xcafe4a11
71 BTRFS_SUPER_MAGIC 0x9123683e
72 BTRFS_TEST_MAGIC 0x73727279
73 CGROUP_SUPER_MAGIC 0x27e0eb /* Cgroup pseudo FS */
74 CGROUP2_SUPER_MAGIC 0x63677270 /* Cgroup v2 pseudo FS */
75 CIFS_MAGIC_NUMBER 0xff534d42
76 CODA_SUPER_MAGIC 0x73757245
77 COH_SUPER_MAGIC 0x012ff7b7
78 CRAMFS_MAGIC 0x28cd3d45
79 DEBUGFS_MAGIC 0x64626720
80 DEVFS_SUPER_MAGIC 0x1373 /* Linux 2.6.17 and earlier */
81 DEVPTS_SUPER_MAGIC 0x1cd1
82 ECRYPTFS_SUPER_MAGIC 0xf15f
83 EFIVARFS_MAGIC 0xde5e81e4
84 EFS_SUPER_MAGIC 0x00414a53
85 EXT_SUPER_MAGIC 0x137d /* Linux 2.0 and earlier */
86 EXT2_OLD_SUPER_MAGIC 0xef51
87 EXT2_SUPER_MAGIC 0xef53
88 EXT3_SUPER_MAGIC 0xef53
89 EXT4_SUPER_MAGIC 0xef53
90 F2FS_SUPER_MAGIC 0xf2f52010
91 FUSE_SUPER_MAGIC 0x65735546
92 FUTEXFS_SUPER_MAGIC 0xbad1dea /* Unused */
93 HFS_SUPER_MAGIC 0x4244
94 HOSTFS_SUPER_MAGIC 0x00c0ffee
95 HPFS_SUPER_MAGIC 0xf995e849
96 HUGETLBFS_MAGIC 0x958458f6
97 ISOFS_SUPER_MAGIC 0x9660
98 JFFS2_SUPER_MAGIC 0x72b6
99 JFS_SUPER_MAGIC 0x3153464a
100 MINIX_SUPER_MAGIC 0x137f /* original minix FS */
101 MINIX_SUPER_MAGIC2 0x138f /* 30 char minix FS */
102 MINIX2_SUPER_MAGIC 0x2468 /* minix V2 FS */
103 MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 FS, 30 char names */
104 MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 FS, 60 char names */
105 MQUEUE_MAGIC 0x19800202 /* POSIX message queue FS */
106 MSDOS_SUPER_MAGIC 0x4d44
107 MTD_INODE_FS_MAGIC 0x11307854
108 NCP_SUPER_MAGIC 0x564c
109 NFS_SUPER_MAGIC 0x6969
110 NILFS_SUPER_MAGIC 0x3434
111 NSFS_MAGIC 0x6e736673
112 NTFS_SB_MAGIC 0x5346544e
113 OCFS2_SUPER_MAGIC 0x7461636f
114 OPENPROM_SUPER_MAGIC 0x9fa1
115 OVERLAYFS_SUPER_MAGIC 0x794c7630
116 PIPEFS_MAGIC 0x50495045
117 PROC_SUPER_MAGIC 0x9fa0 /* /proc FS */
118 PSTOREFS_MAGIC 0x6165676c
119 QNX4_SUPER_MAGIC 0x002f
120 QNX6_SUPER_MAGIC 0x68191122
121 RAMFS_MAGIC 0x858458f6
122 REISERFS_SUPER_MAGIC 0x52654973
124 SECURITYFS_MAGIC 0x73636673
125 SELINUX_MAGIC 0xf97cff8c
126 SMACK_MAGIC 0x43415d53
127 SMB_SUPER_MAGIC 0x517b
128 SMB2_MAGIC_NUMBER 0xfe534d42
129 SOCKFS_MAGIC 0x534f434b
130 SQUASHFS_MAGIC 0x73717368
131 SYSFS_MAGIC 0x62656572
132 SYSV2_SUPER_MAGIC 0x012ff7b6
133 SYSV4_SUPER_MAGIC 0x012ff7b5
134 TMPFS_MAGIC 0x01021994
135 TRACEFS_MAGIC 0x74726163
136 UDF_SUPER_MAGIC 0x15013346
138 USBDEVICE_SUPER_MAGIC 0x9fa2
139 V9FS_MAGIC 0x01021997
140 VXFS_SUPER_MAGIC 0xa501fcf5
141 XENFS_SUPER_MAGIC 0xabba1974
142 XENIX_SUPER_MAGIC 0x012ff7b4
143 XFS_SUPER_MAGIC 0x58465342
144 _XIAFS_SUPER_MAGIC 0x012fd16d /* Linux 2.0 and earlier */
148 Most of these MAGIC constants are defined in
149 .IR /usr/include/linux/magic.h ,
150 and some are hardcoded in kernel sources.
154 field is a bit mask indicating mount options for the filesystem.
155 It contains zero or more of the following bits:
156 .\" XXX Keep this list in sync with statvfs(3)
159 Mandatory locking is permitted on the filesystem (see
163 Do not update access times; see
167 Disallow access to device special files on this filesystem.
170 Do not update directory access times; see
174 Execution of programs is disallowed on this filesystem.
177 The set-user-ID and set-group-ID bits are ignored by
179 for executable files on this filesystem
182 This filesystem is mounted read-only.
185 Update atime relative to mtime/ctime; see
189 Writes are synched to the filesystem immediately (see the description of
194 .BR ST_NOSYMFOLLOW " (since Linux 5.10)"
195 .\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e
196 Symbolic links are not followed when resolving paths; see
201 is supposed to contain (but see below).
203 Fields that are undefined for a particular filesystem are set to 0.
206 returns the same information about an open file referenced by descriptor
209 On success, zero is returned.
210 On error, \-1 is returned, and
212 is set to indicate the error.
217 Search permission is denied for a component of the path prefix of
220 .BR path_resolution (7).)
225 is not a valid open file descriptor.
231 points to an invalid address.
234 The call was interrupted by a signal; see
238 An I/O error occurred while reading from the filesystem.
242 Too many symbolic links were encountered in translating
252 The file referred to by
257 Insufficient kernel memory was available.
260 The filesystem does not support this call.
264 A component of the path prefix of
269 Some values were too large to be represented in the returned struct.
274 was inspired by the 4.4BSD one
275 (but they do not use the same structure).
279 type used for various fields in the
281 structure definition is a glibc internal type,
282 not intended for public use.
283 This leaves the programmer in a bit of a conundrum when trying to copy
284 or compare these fields to local variables in a program.
287 for such variables suffices on most systems.
293 system calls were not designed with extremely large file sizes in mind.
294 Subsequently, Linux 2.6
299 system calls that employ a new structure,
301 The new structure contains the same fields as the original
303 structure, but the sizes of various fields are increased,
304 to accommodate large file sizes.
309 wrapper functions transparently deal with the kernel differences.
311 Some systems have only \fI<sys/vfs.h>\fP, other systems also have
312 \fI<sys/statfs.h>\fP, where the former includes the latter.
314 including the former is the best choice.
316 LSB has deprecated the library calls
326 Solaris, Irix, and POSIX have a system call
331 .IR <sys/statvfs.h> )
335 Linux, SunOS, HP-UX, 4.4BSD have a system call
347 .IR "struct { int val[2]; }" .
348 The same holds for FreeBSD, except that it uses the include file
351 The general idea is that
353 contains some random stuff such that the pair
355 uniquely determines a file.
356 Some operating systems use (a variation on) the device number,
357 or the device number combined with the filesystem type.
358 Several operating systems restrict giving out the
360 field to the superuser only (and zero it for unprivileged users),
361 because this field is used in the filehandle of the filesystem
362 when NFS-exported, and giving it out is a security concern.
364 Under some operating systems, the
366 can be used as the second argument to the
370 From Linux 2.6.38 up to and including Linux 3.1,
371 .\" broken in commit ff0c7d15f9787b7e8c601533c015295cc68329f8
372 .\" fixed in commit d70ef97baf048412c395bb5d65791d8fe133a52b
374 failed with the error
376 for file descriptors created by
381 .BR path_resolution (7)