1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified 2003-08-17 by Walter Harms
24 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
26 .TH STATFS 2 2010-09-04 "Linux" "Linux Programmer's Manual"
28 statfs, fstatfs \- get file system statistics
30 .BR "#include <sys/vfs.h> " "/* or <sys/statfs.h> */"
32 .BI "int statfs(const char *" path ", struct statfs *" buf );
34 .BI "int fstatfs(int " fd ", struct statfs *" buf );
38 returns information about a mounted file system.
40 is the pathname of any file within the mounted file system.
44 structure defined approximately as follows:
48 #if __WORDSIZE == 32 /* System word size */
49 # define __SWORD_TYPE int
50 #else /* __WORDSIZE == 64 */
51 # define __SWORD_TYPE long int
55 __SWORD_TYPE f_type; /* type of file system (see below) */
56 __SWORD_TYPE f_bsize; /* optimal transfer block size */
57 fsblkcnt_t f_blocks; /* total data blocks in file system */
58 fsblkcnt_t f_bfree; /* free blocks in fs */
59 fsblkcnt_t f_bavail; /* free blocks available to
61 fsfilcnt_t f_files; /* total file nodes in file system */
62 fsfilcnt_t f_ffree; /* free file nodes in fs */
63 fsid_t f_fsid; /* file system id */
64 __SWORD_TYPE f_namelen; /* maximum length of filenames */
65 __SWORD_TYPE f_frsize; /* fragment size (since Linux 2.6) */
66 __SWORD_TYPE f_spare[5];
71 ADFS_SUPER_MAGIC 0xadf5
72 AFFS_SUPER_MAGIC 0xADFF
73 BEFS_SUPER_MAGIC 0x42465331
75 CIFS_MAGIC_NUMBER 0xFF534D42
76 CODA_SUPER_MAGIC 0x73757245
77 COH_SUPER_MAGIC 0x012FF7B7
78 CRAMFS_MAGIC 0x28cd3d45
79 DEVFS_SUPER_MAGIC 0x1373
80 EFS_SUPER_MAGIC 0x00414A53
81 EXT_SUPER_MAGIC 0x137D
82 EXT2_OLD_SUPER_MAGIC 0xEF51
83 EXT2_SUPER_MAGIC 0xEF53
84 EXT3_SUPER_MAGIC 0xEF53
85 EXT4_SUPER_MAGIC 0xEF53
86 HFS_SUPER_MAGIC 0x4244
87 HPFS_SUPER_MAGIC 0xF995E849
88 HUGETLBFS_MAGIC 0x958458f6
89 ISOFS_SUPER_MAGIC 0x9660
90 JFFS2_SUPER_MAGIC 0x72b6
91 JFS_SUPER_MAGIC 0x3153464a
92 MINIX_SUPER_MAGIC 0x137F /* orig. minix */
93 MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */
94 MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
95 MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
96 MSDOS_SUPER_MAGIC 0x4d44
97 NCP_SUPER_MAGIC 0x564c
98 NFS_SUPER_MAGIC 0x6969
99 NTFS_SB_MAGIC 0x5346544e
100 OPENPROM_SUPER_MAGIC 0x9fa1
101 PROC_SUPER_MAGIC 0x9fa0
102 QNX4_SUPER_MAGIC 0x002f
103 REISERFS_SUPER_MAGIC 0x52654973
105 SMB_SUPER_MAGIC 0x517B
106 SYSV2_SUPER_MAGIC 0x012FF7B6
107 SYSV4_SUPER_MAGIC 0x012FF7B5
108 TMPFS_MAGIC 0x01021994
109 UDF_SUPER_MAGIC 0x15013346
111 USBDEVICE_SUPER_MAGIC 0x9fa2
112 VXFS_SUPER_MAGIC 0xa501FCF5
113 XENIX_SUPER_MAGIC 0x012FF7B4
114 XFS_SUPER_MAGIC 0x58465342
115 _XIAFS_SUPER_MAGIC 0x012FD16D
121 is supposed to contain (but see below).
123 Fields that are undefined for a particular file system are set to 0.
125 returns the same information about an open file referenced by descriptor
128 On success, zero is returned.
129 On error, \-1 is returned, and
131 is set appropriately.
136 Search permission is denied for a component of the path prefix of
139 .BR path_resolution (7).)
144 is not a valid open file descriptor.
150 points to an invalid address.
153 This call was interrupted by a signal.
156 An I/O error occurred while reading from the file system.
160 Too many symbolic links were encountered in translating
170 The file referred to by
175 Insufficient kernel memory was available.
178 The file system does not support this call.
182 A component of the path prefix of
187 Some values were too large to be represented in the returned struct.
192 was inspired by the 4.4BSD one
193 (but they do not use the same structure).
195 The kernel has system calls
201 to support this library call.
203 Some systems only have \fI<sys/vfs.h>\fP, other systems also have
204 \fI<sys/statfs.h>\fP, where the former includes the latter.
206 including the former is the best choice.
208 LSB has deprecated the library calls
218 Solaris, Irix and POSIX have a system call
223 .IR <sys/statvfs.h> )
227 Linux, SunOS, HP-UX, 4.4BSD have a system call
239 .IR "struct { int val[2]; }" .
240 The same holds for FreeBSD, except that it uses the include file
243 The general idea is that
245 contains some random stuff such that the pair
247 uniquely determines a file.
248 Some operating systems use (a variation on) the device number, or the device number
249 combined with the file-system type.
250 Several OSes restrict giving out the
252 field to the superuser only (and zero it for unprivileged users),
253 because this field is used in the filehandle of the file system
254 when NFS-exported, and giving it out is a security concern.
258 can be used as second argument to the
264 .BR path_resolution (7)