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