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