1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified 2003-08-17 by Walter Harms
26 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
28 .TH STATFS 2 2010-11-21 "Linux" "Linux Programmer's Manual"
30 statfs, fstatfs \- get file system statistics
32 .BR "#include <sys/vfs.h> " "/* or <sys/statfs.h> */"
34 .BI "int statfs(const char *" path ", struct statfs *" buf );
36 .BI "int fstatfs(int " fd ", struct statfs *" buf );
40 returns information about a mounted file system.
42 is the pathname of any file within the mounted file system.
46 structure defined approximately as follows:
50 #if __WORDSIZE == 32 /* System word size */
51 # define __SWORD_TYPE int
52 #else /* __WORDSIZE == 64 */
53 # define __SWORD_TYPE long int
57 __SWORD_TYPE f_type; /* type of file system (see below) */
58 __SWORD_TYPE f_bsize; /* optimal transfer block size */
59 fsblkcnt_t f_blocks; /* total data blocks in file system */
60 fsblkcnt_t f_bfree; /* free blocks in fs */
61 fsblkcnt_t f_bavail; /* free blocks available to
63 fsfilcnt_t f_files; /* total file nodes in file system */
64 fsfilcnt_t f_ffree; /* free file nodes in fs */
65 fsid_t f_fsid; /* file system id */
66 __SWORD_TYPE f_namelen; /* maximum length of filenames */
67 __SWORD_TYPE f_frsize; /* fragment size (since Linux 2.6) */
68 __SWORD_TYPE f_spare[5];
73 ADFS_SUPER_MAGIC 0xadf5
74 AFFS_SUPER_MAGIC 0xADFF
75 BEFS_SUPER_MAGIC 0x42465331
77 CIFS_MAGIC_NUMBER 0xFF534D42
78 CODA_SUPER_MAGIC 0x73757245
79 COH_SUPER_MAGIC 0x012FF7B7
80 CRAMFS_MAGIC 0x28cd3d45
81 DEVFS_SUPER_MAGIC 0x1373
82 EFS_SUPER_MAGIC 0x00414A53
83 EXT_SUPER_MAGIC 0x137D
84 EXT2_OLD_SUPER_MAGIC 0xEF51
85 EXT2_SUPER_MAGIC 0xEF53
86 EXT3_SUPER_MAGIC 0xEF53
87 EXT4_SUPER_MAGIC 0xEF53
88 HFS_SUPER_MAGIC 0x4244
89 HPFS_SUPER_MAGIC 0xF995E849
90 HUGETLBFS_MAGIC 0x958458f6
91 ISOFS_SUPER_MAGIC 0x9660
92 JFFS2_SUPER_MAGIC 0x72b6
93 JFS_SUPER_MAGIC 0x3153464a
94 MINIX_SUPER_MAGIC 0x137F /* orig. minix */
95 MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */
96 MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
97 MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
98 MSDOS_SUPER_MAGIC 0x4d44
99 NCP_SUPER_MAGIC 0x564c
100 NFS_SUPER_MAGIC 0x6969
101 NTFS_SB_MAGIC 0x5346544e
102 OPENPROM_SUPER_MAGIC 0x9fa1
103 PROC_SUPER_MAGIC 0x9fa0
104 QNX4_SUPER_MAGIC 0x002f
105 REISERFS_SUPER_MAGIC 0x52654973
107 SMB_SUPER_MAGIC 0x517B
108 SYSV2_SUPER_MAGIC 0x012FF7B6
109 SYSV4_SUPER_MAGIC 0x012FF7B5
110 TMPFS_MAGIC 0x01021994
111 UDF_SUPER_MAGIC 0x15013346
113 USBDEVICE_SUPER_MAGIC 0x9fa2
114 VXFS_SUPER_MAGIC 0xa501FCF5
115 XENIX_SUPER_MAGIC 0x012FF7B4
116 XFS_SUPER_MAGIC 0x58465342
117 _XIAFS_SUPER_MAGIC 0x012FD16D
123 is supposed to contain (but see below).
125 Fields that are undefined for a particular file system are set to 0.
127 returns the same information about an open file referenced by descriptor
130 On success, zero is returned.
131 On error, \-1 is returned, and
133 is set appropriately.
138 Search permission is denied for a component of the path prefix of
141 .BR path_resolution (7).)
146 is not a valid open file descriptor.
152 points to an invalid address.
155 This call was interrupted by a signal.
158 An I/O error occurred while reading from the file system.
162 Too many symbolic links were encountered in translating
172 The file referred to by
177 Insufficient kernel memory was available.
180 The file system does not support this call.
184 A component of the path prefix of
189 Some values were too large to be represented in the returned struct.
194 was inspired by the 4.4BSD one
195 (but they do not use the same structure).
201 system calls were not designed with extremely large file sizes in mind.
202 Subsequently, Linux 2.6
207 system calls that employ a new structure,
209 The new structure contains the same fields as the original
211 structure, but the sizes of various fields are increased,
212 to accommodate large file sizes.
217 wrapper functions transparently deal with the kernel differences.
219 Some systems only have \fI<sys/vfs.h>\fP, other systems also have
220 \fI<sys/statfs.h>\fP, where the former includes the latter.
222 including the former is the best choice.
224 LSB has deprecated the library calls
234 Solaris, Irix and POSIX have a system call
239 .IR <sys/statvfs.h> )
243 Linux, SunOS, HP-UX, 4.4BSD have a system call
255 .IR "struct { int val[2]; }" .
256 The same holds for FreeBSD, except that it uses the include file
259 The general idea is that
261 contains some random stuff such that the pair
263 uniquely determines a file.
264 Some operating systems use (a variation on) the device number, or the device number
265 combined with the file-system type.
266 Several OSes restrict giving out the
268 field to the superuser only (and zero it for unprivileged users),
269 because this field is used in the filehandle of the file system
270 when NFS-exported, and giving it out is a security concern.
272 Under some operating systems the
274 can be used as second argument to the
280 .BR path_resolution (7)