mbrtowc.3: SYNOPSIS: Use 'restrict' in prototypes
[man-pages.git] / man3 / statvfs.3
blob4f278861457455a689348ef2d81bd21947e1d9c3
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 2017-09-15 "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 *" path ", struct statvfs *" buf );
38 .BI "int fstatvfs(int " fd ", struct statvfs *" buf );
39 .fi
40 .SH DESCRIPTION
41 The function
42 .BR statvfs ()
43 returns information about a mounted filesystem.
44 .I path
45 is the pathname of any file within the mounted filesystem.
46 .I buf
47 is a pointer to a
48 .I statvfs
49 structure defined approximately as follows:
50 .PP
51 .in +4n
52 .EX
53 struct statvfs {
54     unsigned long  f_bsize;    /* Filesystem block size */
55     unsigned long  f_frsize;   /* Fragment size */
56     fsblkcnt_t     f_blocks;   /* Size of fs in f_frsize units */
57     fsblkcnt_t     f_bfree;    /* Number of free blocks */
58     fsblkcnt_t     f_bavail;   /* Number of free blocks for
59                                   unprivileged users */
60     fsfilcnt_t     f_files;    /* Number of inodes */
61     fsfilcnt_t     f_ffree;    /* Number of free inodes */
62     fsfilcnt_t     f_favail;   /* Number of free inodes for
63                                   unprivileged users */
64     unsigned long  f_fsid;     /* Filesystem ID */
65     unsigned long  f_flag;     /* Mount flags */
66     unsigned long  f_namemax;  /* Maximum filename length */
68 .EE
69 .in
70 .PP
71 Here the types
72 .I fsblkcnt_t
73 and
74 .I fsfilcnt_t
75 are defined in
76 .IR <sys/types.h> .
77 Both used to be
78 .IR "unsigned long" .
79 .PP
80 The field
81 .I f_flag
82 is a bit mask indicating various options that were employed
83 when mounting this filesystem.
84 It contains zero or more of the following flags:
85 .\" XXX Keep this list in sync with statfs(2)
86 .TP
87 .B ST_MANDLOCK
88 Mandatory locking is permitted on the filesystem (see
89 .BR fcntl (2)).
90 .TP
91 .B ST_NOATIME
92 Do not update access times; see
93 .BR mount (2).
94 .TP
95 .B ST_NODEV
96 Disallow access to device special files on this filesystem.
97 .TP
98 .B ST_NODIRATIME
99 Do not update directory access times; see
100 .BR mount (2).
102 .B ST_NOEXEC
103 Execution of programs is disallowed on this filesystem.
105 .B ST_NOSUID
106 The set-user-ID and set-group-ID bits are ignored by
107 .BR exec (3)
108 for executable files on this filesystem
110 .B ST_RDONLY
111 This filesystem is mounted read-only.
113 .B ST_RELATIME
114 Update atime relative to mtime/ctime; see
115 .BR mount (2).
117 .B ST_SYNCHRONOUS
118 Writes are synched to the filesystem immediately (see the description of
119 .B O_SYNC
121 .BR open (2)).
123 It is unspecified whether all members of the returned struct
124 have meaningful values on all filesystems.
126 .BR fstatvfs ()
127 returns the same information about an open file referenced by descriptor
128 .IR fd .
129 .SH RETURN VALUE
130 On success, zero is returned.
131 On error, \-1 is returned, and
132 .I errno
133 is set to indicate the error.
134 .SH ERRORS
136 .B EACCES
137 .RB ( statvfs ())
138 Search permission is denied for a component of the path prefix of
139 .IR path .
140 (See also
141 .BR path_resolution (7).)
143 .B EBADF
144 .RB ( fstatvfs ())
145 .I fd
146 is not a valid open file descriptor.
148 .B EFAULT
149 .I Buf
151 .I path
152 points to an invalid address.
154 .B EINTR
155 This call was interrupted by a signal; see
156 .BR signal (7).
158 .B EIO
159 An I/O error occurred while reading from the filesystem.
161 .B ELOOP
162 .RB ( statvfs ())
163 Too many symbolic links were encountered in translating
164 .IR path .
166 .B ENAMETOOLONG
167 .RB ( statvfs ())
168 .I path
169 is too long.
171 .B ENOENT
172 .RB ( statvfs ())
173 The file referred to by
174 .I path
175 does not exist.
177 .B ENOMEM
178 Insufficient kernel memory was available.
180 .B ENOSYS
181 The filesystem does not support this call.
183 .B ENOTDIR
184 .RB ( statvfs ())
185 A component of the path prefix of
186 .I path
187 is not a directory.
189 .B EOVERFLOW
190 Some values were too large to be represented in the returned struct.
191 .SH ATTRIBUTES
192 For an explanation of the terms used in this section, see
193 .BR attributes (7).
194 .ad l
197 allbox;
198 lbx lb lb
199 l l l.
200 Interface       Attribute       Value
202 .BR statvfs (),
203 .BR fstatvfs ()
204 T}      Thread safety   MT-Safe
208 .sp 1
209 .SH CONFORMING TO
210 POSIX.1-2001, POSIX.1-2008.
212 Only the
213 .B ST_NOSUID
215 .B ST_RDONLY
216 flags of the
217 .I f_flag
218 field are specified in POSIX.1.
219 To obtain definitions of the remaining flags, one must define
220 .BR _GNU_SOURCE .
221 .SH NOTES
222 The Linux kernel has system calls
223 .BR statfs (2)
225 .BR fstatfs (2)
226 to support this library call.
228 In glibc versions before 2.13,
229 .\" glibc commit 3cdaa6adb113a088fdfb87aa6d7747557eccc58d
230 .BR statvfs ()
231 populated the bits of the
232 .IR f_flag
233 field by scanning the mount options shown in
234 .IR /proc/mounts .
235 However, starting with Linux 2.6.36, the underlying
236 .BR statfs (2)
237 system call provides the necessary information via the
238 .IR f_flags
239 field, and since glibc version 2.13, the
240 .BR statvfs ()
241 function will use information from that field rather than scanning
242 .IR /proc/mounts .
244 The glibc implementations of
246 .in +4n
248 pathconf(path, _PC_REC_XFER_ALIGN);
249 pathconf(path, _PC_ALLOC_SIZE_MIN);
250 pathconf(path, _PC_REC_MIN_XFER_SIZE);
254 respectively use the
255 .IR f_frsize ,
256 .IR f_frsize ,
258 .I f_bsize
259 fields returned by a call to
260 .BR statvfs ()
261 with the argument
262 .IR path .
263 .SH SEE ALSO
264 .BR statfs (2)