]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/statfs.2
Add section numbers to references to other pages
[thirdparty/man-pages.git] / man2 / statfs.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
2.\"
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.
6.\"
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.
c13182ef 11.\"
fea681da
MK
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
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" Modified 2003-08-17 by Walter Harms
305a0578 24.\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
25.\"
26.TH STATFS 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
27.SH NAME
28statfs, fstatfs \- get file system statistics
29.SH SYNOPSIS
30.BR "#include <sys/vfs.h> " "/* or <sys/statfs.h> */"
31.sp
32.BI "int statfs(const char *" path ", struct statfs *" buf );
33.br
34.BI "int fstatfs(int " fd ", struct statfs *" buf );
35.SH DESCRIPTION
36The function
e511ffb6 37.BR statfs ()
fea681da
MK
38returns information about a mounted file system.
39.I path
2d7195b8 40is the pathname of any file within the mounted filesystem.
fea681da
MK
41.I buf
42is a pointer to a
43.I statfs
44structure defined approximately as follows:
45
46.RS
47.nf
48struct statfs {
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 */
58};
59
60File system types:
61
62 ADFS_SUPER_MAGIC 0xadf5
63 AFFS_SUPER_MAGIC 0xADFF
64 BEFS_SUPER_MAGIC 0x42465331
65 BFS_MAGIC 0x1BADFACE
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
94 ROMFS_MAGIC 0x7275
95 SMB_SUPER_MAGIC 0x517B
96 SYSV2_SUPER_MAGIC 0x012FF7B6
97 SYSV4_SUPER_MAGIC 0x012FF7B5
98 TMPFS_MAGIC 0x01021994
99 UDF_SUPER_MAGIC 0x15013346
100 UFS_MAGIC 0x00011954
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
106.fi
107.RE
108.PP
109Nobody knows what
110.I f_fsid
111is supposed to contain (but see below).
112.PP
113Fields that are undefined for a particular file system are set to 0.
e511ffb6 114.BR fstatfs ()
fea681da
MK
115returns the same information about an open file referenced by descriptor
116.IR fd .
117.SH "RETURN VALUE"
c13182ef
MK
118On success, zero is returned.
119On error, \-1 is returned, and
fea681da
MK
120.I errno
121is set appropriately.
122.SH ERRORS
123.TP
124.B EACCES
1e321034 125.RB ( statfs ())
fea681da
MK
126Search permission is denied for a component of the path prefix of
127.IR path .
128(See also
129.BR path_resolution (2).)
130.TP
131.B EBADF
1e321034 132.RB ( fstatfs ())
fea681da
MK
133.I fd
134is not a valid open file descriptor.
135.TP
136.B EFAULT
137.I buf
138or
139.I path
140points to an invalid address.
141.TP
142.B EINTR
143This call was interrupted by a signal.
144.TP
145.B EIO
146An I/O error occurred while reading from the file system.
147.TP
148.B ELOOP
1e321034 149.RB ( statfs ())
fea681da
MK
150Too many symbolic links were encountered in translating
151.IR path .
152.TP
153.B ENAMETOOLONG
1e321034 154.RB ( statfs ())
fea681da
MK
155.I path
156is too long.
157.TP
158.B ENOENT
1e321034 159.RB ( statfs ())
fea681da
MK
160The file referred to by
161.I path
162does not exist.
163.TP
164.B ENOMEM
165Insufficient kernel memory was available.
166.TP
167.B ENOSYS
168The file system does not support this call.
169.TP
170.B ENOTDIR
1e321034 171.RB ( statfs ())
fea681da
MK
172A component of the path prefix of
173.I path
174is not a directory.
175.TP
176.B EOVERFLOW
177Some values were too large to be represented in the returned struct.
fea681da 178.SH "CONFORMING TO"
75b48e9d 179Linux specific.
fea681da 180The Linux
e511ffb6 181.BR statfs ()
fea681da
MK
182was inspired by the 4.4BSD one
183(but they do not use the same structure).
56bbbf8e 184.SH NOTES
c13182ef
MK
185The kernel has system calls
186.BR statfs (),
187.BR fstatfs (),
56bbbf8e
MK
188.BR statfs64 (),
189and
190.BR fstatfs64 ()
191to support this library call.
192
193Some systems only have <sys/vfs.h>, other systems also have
c13182ef
MK
194<sys/statfs.h>, where the former includes the latter.
195So it seems
56bbbf8e
MK
196including the former is the best choice.
197
198LSB has deprecated the library calls
199.BR statfs ()
200and
201.BR fstatfs ()
202and tells us to use
0bfa087b 203.BR statvfs (2)
56bbbf8e 204and
0bfa087b 205.BR fstatvfs (2)
56bbbf8e
MK
206instead.
207.SS The f_fsid field
fea681da
MK
208Solaris, Irix and POSIX have a system call
209.BR statvfs (2)
210that returns a
8478ee02 211.I "struct statvfs"
fea681da
MK
212(defined in
213.IR "<sys/statvfs.h>" )
214containing an
9ff08aad 215.I "unsigned long"
fea681da 216.IR f_fsid .
97c1eac8 217Linux, SunOS, HP-UX, 4.4BSD have a system call
31e9a9ec 218.BR statfs ()
fea681da 219that returns a
8478ee02 220.I "struct statfs"
fea681da
MK
221(defined in
222.IR "<sys/vfs.h>" )
223containing a
9ff08aad 224.I fsid_t
fea681da
MK
225.IR f_fsid ,
226where
227.I fsid_t
228is defined as
8478ee02 229.IR "struct { int val[2]; }" .
fea681da
MK
230The same holds for FreeBSD, except that it uses the include file
231.IR "<sys/mount.h>" .
232
233The general idea is that
234.I f_fsid
235contains some random stuff such that the pair
236.RI ( f_fsid , ino )
237uniquely determines a file.
238Some OSes use (a variation on) the device number, or the device number
239combined with the filesystem type.
240Several OSes restrict giving out the
241.I f_fsid
7145b9a9 242field to the superuser only (and zero it for unprivileged users),
fea681da
MK
243because this field is used in the filehandle of the filesystem
244when NFS-exported, and giving it out is a security concern.
245.LP
246Under some OSes the
247.I fsid
248can be used as second parameter to the
31e9a9ec 249.BR sysfs ()
fea681da 250system call.
fea681da
MK
251.SH "SEE ALSO"
252.BR path_resolution (2),
253.BR stat (2),
254.BR statvfs (2)