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@gmx.net>
26 .TH STATFS 2 2004-06-23 "Linux 2.6.7" "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 path name of any file within the mounted filesystem.
44 structure defined approximately as follows:
49 long f_type; /* type of filesystem (see below) */
50 long f_bsize; /* optimal transfer block size */
51 long f_blocks; /* total data blocks in file system */
52 long f_bfree; /* free blocks in fs */
53 long f_bavail; /* free blocks avail to non-superuser */
54 long f_files; /* total file nodes in file system */
55 long f_ffree; /* free file nodes in fs */
56 fsid_t f_fsid; /* file system id */
57 long f_namelen; /* maximum length of filenames */
62 ADFS_SUPER_MAGIC 0xadf5
63 AFFS_SUPER_MAGIC 0xADFF
64 BEFS_SUPER_MAGIC 0x42465331
66 CIFS_MAGIC_NUMBER 0xFF534D42
67 CODA_SUPER_MAGIC 0x73757245
68 COH_SUPER_MAGIC 0x012FF7B7
69 CRAMFS_MAGIC 0x28cd3d45
70 DEVFS_SUPER_MAGIC 0x1373
71 EFS_SUPER_MAGIC 0x00414A53
72 EXT_SUPER_MAGIC 0x137D
73 EXT2_OLD_SUPER_MAGIC 0xEF51
74 EXT2_SUPER_MAGIC 0xEF53
75 EXT3_SUPER_MAGIC 0xEF53
76 HFS_SUPER_MAGIC 0x4244
77 HPFS_SUPER_MAGIC 0xF995E849
78 HUGETLBFS_MAGIC 0x958458f6
79 ISOFS_SUPER_MAGIC 0x9660
80 JFFS2_SUPER_MAGIC 0x72b6
81 JFS_SUPER_MAGIC 0x3153464a
82 MINIX_SUPER_MAGIC 0x137F /* orig. minix */
83 MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */
84 MINIX2_SUPER_MAGIC 0x2468 /* minix V2 */
85 MINIX2_SUPER_MAGIC2 0x2478 /* minix V2, 30 char names */
86 MSDOS_SUPER_MAGIC 0x4d44
87 NCP_SUPER_MAGIC 0x564c
88 NFS_SUPER_MAGIC 0x6969
89 NTFS_SB_MAGIC 0x5346544e
90 OPENPROM_SUPER_MAGIC 0x9fa1
91 PROC_SUPER_MAGIC 0x9fa0
92 QNX4_SUPER_MAGIC 0x002f
93 REISERFS_SUPER_MAGIC 0x52654973
95 SMB_SUPER_MAGIC 0x517B
96 SYSV2_SUPER_MAGIC 0x012FF7B6
97 SYSV4_SUPER_MAGIC 0x012FF7B5
98 TMPFS_MAGIC 0x01021994
99 UDF_SUPER_MAGIC 0x15013346
101 USBDEVICE_SUPER_MAGIC 0x9fa2
102 VXFS_SUPER_MAGIC 0xa501FCF5
103 XENIX_SUPER_MAGIC 0x012FF7B4
104 XFS_SUPER_MAGIC 0x58465342
105 _XIAFS_SUPER_MAGIC 0x012FD16D
111 is supposed to contain (but see below).
113 Fields that are undefined for a particular file system are set to 0.
115 returns the same information about an open file referenced by descriptor
118 On success, zero is returned. On error, \-1 is returned, and
120 is set appropriately.
125 Search permission is denied for a component of the path prefix of
128 .BR path_resolution (2).)
133 is not a valid open file descriptor.
139 points to an invalid address.
142 This call was interrupted by a signal.
145 An I/O error occurred while reading from the file system.
149 Too many symbolic links were encountered in translating
159 The file referred to by
164 Insufficient kernel memory was available.
167 The file system does not support this call.
171 A component of the path prefix of
176 Some values were too large to be represented in the returned struct.
181 was inspired by the 4.4BSD one
182 (but they do not use the same structure).
183 .SH "NOTES ON f_fsid"
184 Solaris, Irix and POSIX have a system call
189 .IR "<sys/statvfs.h>" )
193 Linux, SunOS, HPUX, 4.4BSD have a system call
205 .BR "struct { int val[2]; }" .
206 The same holds for FreeBSD, except that it uses the include file
207 .IR "<sys/mount.h>" .
209 The general idea is that
211 contains some random stuff such that the pair
213 uniquely determines a file.
214 Some OSes use (a variation on) the device number, or the device number
215 combined with the filesystem type.
216 Several OSes restrict giving out the
218 field to the superuser only (and zero it for nonprivileged users),
219 because this field is used in the filehandle of the filesystem
220 when NFS-exported, and giving it out is a security concern.
224 can be used as second parameter to the
228 The kernel has system calls statfs, fstatfs, statfs64, fstatfs64
229 to support this library call.
231 Some systems only have <sys/vfs.h>, other systems also have
232 <sys/statfs.h>, where the former includes the latter. So it seems
233 including the former is the best choice.
235 LSB has deprecated the library calls
241 .BR path_resolution (2),