]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/statvfs.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[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.\"
4b8c67d9 30.TH STATVFS 3 2017-09-15 "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>
68e4db0a 35.PP
fea681da
MK
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:
847e0d88 49.PP
3ad4ddcd 50.in +4n
b8302363 51.EX
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};
b8302363 67.EE
3ad4ddcd 68.in
847e0d88 69.PP
fea681da 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" .
847e0d88 78.PP
fea681da
MK
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)).
dd3568a1 121.PP
fea681da 122It is unspecified whether all members of the returned struct
9ee4a2b6 123have meaningful values on all filesystems.
847e0d88 124.PP
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
bb14af39
MK
154This call was interrupted by a signal; see
155.BR signal (7).
fea681da
MK
156.TP
157.B EIO
9ee4a2b6 158An I/O error occurred while reading from the filesystem.
fea681da
MK
159.TP
160.B ELOOP
1e321034 161.RB ( statvfs ())
fea681da
MK
162Too many symbolic links were encountered in translating
163.IR path .
164.TP
165.B ENAMETOOLONG
1e321034 166.RB ( statvfs ())
fea681da
MK
167.I path
168is too long.
169.TP
170.B ENOENT
1e321034 171.RB ( statvfs ())
fea681da
MK
172The file referred to by
173.I path
174does not exist.
175.TP
176.B ENOMEM
177Insufficient kernel memory was available.
178.TP
179.B ENOSYS
9ee4a2b6 180The filesystem does not support this call.
fea681da
MK
181.TP
182.B ENOTDIR
1e321034 183.RB ( statvfs ())
fea681da
MK
184A component of the path prefix of
185.I path
186is not a directory.
187.TP
188.B EOVERFLOW
189Some values were too large to be represented in the returned struct.
e0cf6f25 190.SH ATTRIBUTES
e67472d2
PH
191For an explanation of the terms used in this section, see
192.BR attributes (7).
193.TS
194allbox;
195lbw21 lb lb
196l l l.
197Interface Attribute Value
198T{
199.BR statvfs (),
e0cf6f25 200.BR fstatvfs ()
e67472d2
PH
201T} Thread safety MT-Safe
202.TE
47297adb 203.SH CONFORMING TO
41017cbb 204POSIX.1-2001, POSIX.1-2008.
847e0d88 205.PP
54083449
MK
206Only the
207.B ST_NOSUID
208and
209.B ST_RDONLY
210flags of the
211.I f_flag
212field are specified in POSIX.1.
213To obtain definitions of the remaining flags, one must define
214.BR _GNU_SOURCE .
fea681da 215.SH NOTES
c13182ef 216The Linux kernel has system calls
0bfa087b 217.BR statfs (2)
1e321034 218and
0bfa087b 219.BR fstatfs (2)
fea681da 220to support this library call.
847e0d88 221.PP
f019cbb4
MK
222In glibc versions before 2.13,
223.\" glibc commit 3cdaa6adb113a088fdfb87aa6d7747557eccc58d
224.BR statvfs ()
225populated the bits of the
226.IR f_flag
227field by scanning the mount options shown in
228.IR /proc/mounts .
229However, starting with Linux 2.6.36, the underlying
230.BR statfs (2)
231system call provides the necessary information via the
232.IR f_flags
233field, and since glibc version 2.13, the
234.BR statvfs ()
235function will use information from that field rather than scanning
236.IR /proc/mounts .
847e0d88 237.PP
12fcbd0b 238The glibc implementations of
bdd915e2
MK
239.PP
240.in +4n
241.EX
242pathconf(path, _PC_REC_XFER_ALIGN);
243pathconf(path, _PC_ALLOC_SIZE_MIN);
244pathconf(path, _PC_REC_MIN_XFER_SIZE);
245.EE
246.in
247.PP
11dcec1d 248respectively use the
fea681da
MK
249.IR f_frsize ,
250.IR f_frsize ,
251and
0daa9e92 252.I f_bsize
aaf116b8
MK
253fields returned by a call to
254.BR statvfs ()
255with the argument
256.IR path .
47297adb 257.SH SEE ALSO
fea681da 258.BR statfs (2)