]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/statvfs.3
dlinfo.3: ATTRIBUTES: Note function that is thread-safe
[thirdparty/man-pages.git] / man3 / statvfs.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
7.\"
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.
c13182ef 12.\"
fea681da
MK
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
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" The pathconf note is from Walter Harms
26.\" This is not a system call on Linux
27.\"
c11b1abf 28.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 29.\"
6d322d5f 30.TH STATVFS 3 2015-02-21 "Linux" "Linux Programmer's Manual"
fea681da 31.SH NAME
9ee4a2b6 32statvfs, fstatvfs \- get filesystem statistics
fea681da
MK
33.SH SYNOPSIS
34.B #include <sys/statvfs.h>
35.sp
36.BI "int statvfs(const char *" path ", struct statvfs *" buf );
37.br
38.BI "int fstatvfs(int " fd ", struct statvfs *" buf );
39.SH DESCRIPTION
40The function
e511ffb6 41.BR statvfs ()
9ee4a2b6 42returns information about a mounted filesystem.
fea681da 43.I path
9ee4a2b6 44is the pathname of any file within the mounted filesystem.
fea681da
MK
45.I buf
46is a pointer to a
47.I statvfs
48structure defined approximately as follows:
49
3ad4ddcd 50.in +4n
fea681da 51.nf
cf0a9ace 52struct statvfs {
a7a5d641
MK
53 unsigned long f_bsize; /* Filesystem block size */
54 unsigned long f_frsize; /* Fragment size */
55 fsblkcnt_t f_blocks; /* Size of fs in f_frsize units */
df7a3950
MK
56 fsblkcnt_t f_bfree; /* Number of free blocks */
57 fsblkcnt_t f_bavail; /* Number of free blocks for
58 unprivileged users */
59 fsfilcnt_t f_files; /* Number of inodes */
60 fsfilcnt_t f_ffree; /* Number of free inodes */
61 fsfilcnt_t f_favail; /* Number of free inodes for
62 unprivileged users */
a7a5d641
MK
63 unsigned long f_fsid; /* Filesystem ID */
64 unsigned long f_flag; /* Mount flags */
65 unsigned long f_namemax; /* Maximum filename length */
cf0a9ace 66};
fea681da 67.fi
3ad4ddcd 68.in
fea681da
MK
69
70Here the types
66ee0c7e 71.I fsblkcnt_t
fea681da 72and
66ee0c7e 73.I fsfilcnt_t
fea681da
MK
74are defined in
75.IR <sys/types.h> .
76Both used to be
9ff08aad 77.IR "unsigned long" .
fea681da
MK
78
79The field
80.I f_flag
54083449
MK
81is a bit mask indicating various options that were employed
82when mounting this filesystem.
83It contains zero or more of the following flags:
84.\" XXX Keep this list in sync with statfs(2)
fea681da 85.TP
54083449
MK
86.B ST_MANDLOCK
87Mandatory locking is permitted on the filesystem (see
88.BR fcntl (2)).
89.TP
90.B ST_NOATIME
91Do not update access times; see
92.BR mount (2).
93.TP
94.B ST_NODEV
95Disallow access to device special files on this filesystem.
96.TP
97.B ST_NODIRATIME
98Do not update directory access times; see
99.BR mount (2).
100.TP
101.B ST_NOEXEC
102Execution of programs is disallowed on this filesystem.
fea681da
MK
103.TP
104.B ST_NOSUID
54083449
MK
105The set-user-ID and set-group-ID bits are ignored by
106.BR exec (3)
107for executable files on this filesystem
108.TP
109.B ST_RDONLY
110This filesystem is mounted read-only.
111.TP
112.B ST_RELATIME
113Update atime relative to mtime/ctime; see
114.BR mount (2).
115.TP
116.B ST_SYNCHRONOUS
117Writes are synched to the filesystem immediately (see the description of
118.B O_SYNC
119in
120.BR open (2)).
fea681da 121.LP
fea681da 122It is unspecified whether all members of the returned struct
9ee4a2b6 123have meaningful values on all filesystems.
fea681da 124
e511ffb6 125.BR fstatvfs ()
fea681da
MK
126returns the same information about an open file referenced by descriptor
127.IR fd .
47297adb 128.SH RETURN VALUE
c13182ef
MK
129On success, zero is returned.
130On error, \-1 is returned, and
fea681da
MK
131.I errno
132is set appropriately.
133.SH ERRORS
134.TP
135.B EACCES
1e321034 136.RB ( statvfs ())
fea681da
MK
137Search permission is denied for a component of the path prefix of
138.IR path .
139(See also
ad7cc990 140.BR path_resolution (7).)
fea681da
MK
141.TP
142.B EBADF
1e321034 143.RB ( fstatvfs ())
fea681da
MK
144.I fd
145is not a valid open file descriptor.
146.TP
147.B EFAULT
148.I Buf
149or
150.I path
151points to an invalid address.
152.TP
153.B EINTR
154This call was interrupted by a signal.
155.TP
156.B EIO
9ee4a2b6 157An I/O error occurred while reading from the filesystem.
fea681da
MK
158.TP
159.B ELOOP
1e321034 160.RB ( statvfs ())
fea681da
MK
161Too many symbolic links were encountered in translating
162.IR path .
163.TP
164.B ENAMETOOLONG
1e321034 165.RB ( statvfs ())
fea681da
MK
166.I path
167is too long.
168.TP
169.B ENOENT
1e321034 170.RB ( statvfs ())
fea681da
MK
171The file referred to by
172.I path
173does not exist.
174.TP
175.B ENOMEM
176Insufficient kernel memory was available.
177.TP
178.B ENOSYS
9ee4a2b6 179The filesystem does not support this call.
fea681da
MK
180.TP
181.B ENOTDIR
1e321034 182.RB ( statvfs ())
fea681da
MK
183A component of the path prefix of
184.I path
185is not a directory.
186.TP
187.B EOVERFLOW
188Some values were too large to be represented in the returned struct.
e0cf6f25 189.SH ATTRIBUTES
e67472d2
PH
190For an explanation of the terms used in this section, see
191.BR attributes (7).
192.TS
193allbox;
194lbw21 lb lb
195l l l.
196Interface Attribute Value
197T{
198.BR statvfs (),
e0cf6f25 199.BR fstatvfs ()
e67472d2
PH
200T} Thread safety MT-Safe
201.TE
47297adb 202.SH CONFORMING TO
41017cbb 203POSIX.1-2001, POSIX.1-2008.
54083449
MK
204
205Only the
206.B ST_NOSUID
207and
208.B ST_RDONLY
209flags of the
210.I f_flag
211field are specified in POSIX.1.
212To obtain definitions of the remaining flags, one must define
213.BR _GNU_SOURCE .
fea681da 214.SH NOTES
c13182ef 215The Linux kernel has system calls
0bfa087b 216.BR statfs (2)
1e321034 217and
0bfa087b 218.BR fstatfs (2)
fea681da
MK
219to support this library call.
220
f019cbb4
MK
221In glibc versions before 2.13,
222.\" glibc commit 3cdaa6adb113a088fdfb87aa6d7747557eccc58d
223.BR statvfs ()
224populated the bits of the
225.IR f_flag
226field by scanning the mount options shown in
227.IR /proc/mounts .
228However, starting with Linux 2.6.36, the underlying
229.BR statfs (2)
230system call provides the necessary information via the
231.IR f_flags
232field, and since glibc version 2.13, the
233.BR statvfs ()
234function will use information from that field rather than scanning
235.IR /proc/mounts .
236
12fcbd0b 237The glibc implementations of
fea681da
MK
238.sp
239.nf
240 pathconf(path, _PC_REC_XFER_ALIGN);
241 pathconf(path, _PC_ALLOC_SIZE_MIN);
242 pathconf(path, _PC_REC_MIN_XFER_SIZE);
243.fi
244.sp
11dcec1d 245respectively use the
fea681da
MK
246.IR f_frsize ,
247.IR f_frsize ,
248and
0daa9e92 249.I f_bsize
aaf116b8
MK
250fields returned by a call to
251.BR statvfs ()
252with the argument
253.IR path .
47297adb 254.SH SEE ALSO
fea681da 255.BR statfs (2)