1FSTATVFS(3P) POSIX Programmer's Manual FSTATVFS(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 fstatvfs, statvfs — get file system information
14
16 #include <sys/statvfs.h>
17
18 int fstatvfs(int fildes, struct statvfs *buf);
19 int statvfs(const char *restrict path, struct statvfs *restrict buf);
20
22 The fstatvfs() function shall obtain information about the file system
23 containing the file referenced by fildes.
24
25 The statvfs() function shall obtain information about the file system
26 containing the file named by path.
27
28 For both functions, the buf argument is a pointer to a statvfs struc‐
29 ture that shall be filled. Read, write, or execute permission of the
30 named file is not required.
31
32 The following flags can be returned in the f_flag member:
33
34 ST_RDONLY Read-only file system.
35
36 ST_NOSUID Setuid/setgid bits ignored by exec.
37
38 It is unspecified whether all members of the statvfs structure have
39 meaningful values on all file systems.
40
42 Upon successful completion, statvfs() shall return 0. Otherwise, it
43 shall return −1 and set errno to indicate the error.
44
46 The fstatvfs() and statvfs() functions shall fail if:
47
48 EIO An I/O error occurred while reading the file system.
49
50 EINTR A signal was caught during execution of the function.
51
52 EOVERFLOW
53 One of the values to be returned cannot be represented correctly
54 in the structure pointed to by buf.
55
56 The fstatvfs() function shall fail if:
57
58 EBADF The fildes argument is not an open file descriptor.
59
60 The statvfs() function shall fail if:
61
62 EACCES Search permission is denied on a component of the path prefix.
63
64 ELOOP A loop exists in symbolic links encountered during resolution of
65 the path argument.
66
67 ENAMETOOLONG
68 The length of a component of a pathname is longer than
69 {NAME_MAX}.
70
71 ENOENT A component of path does not name an existing file or path is an
72 empty string.
73
74 ENOTDIR
75 A component of the path prefix names an existing file that is
76 neither a directory nor a symbolic link to a directory, or the
77 path argument contains at least one non-<slash> character and
78 ends with one or more trailing <slash> characters and the last
79 pathname component names an existing file that is neither a
80 directory nor a symbolic link to a directory.
81
82 The statvfs() function may fail if:
83
84 ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during
85 resolution of the path argument.
86
87 ENAMETOOLONG
88 The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
89 tion of a symbolic link produced an intermediate result with a
90 length that exceeds {PATH_MAX}.
91
92 The following sections are informative.
93
95 Obtaining File System Information Using fstatvfs()
96 The following example shows how to obtain file system information for
97 the file system upon which the file named /home/cnd/mod1 resides, using
98 the fstatvfs() function. The /home/cnd/mod1 file is opened with
99 read/write privileges and the open file descriptor is passed to the
100 fstatvfs() function.
101
102 #include <sys/statvfs.h>
103 #include <fcntl.h>
104
105 struct statvfs buffer;
106 int status;
107 ...
108 fildes = open("/home/cnd/mod1", O_RDWR);
109 status = fstatvfs(fildes, &buffer);
110
111 Obtaining File System Information Using statvfs()
112 The following example shows how to obtain file system information for
113 the file system upon which the file named /home/cnd/mod1 resides, using
114 the statvfs() function.
115
116 #include <sys/statvfs.h>
117
118 struct statvfs buffer;
119 int status;
120 ...
121 status = statvfs("/home/cnd/mod1", &buffer);
122
124 None.
125
127 None.
128
130 None.
131
133 chmod(), chown(), creat(), dup(), exec, fcntl(), link(), mknod(),
134 open(), pipe(), read(), time(), unlink(), utime(), write()
135
136 The Base Definitions volume of POSIX.1‐2008, <sys_statvfs.h>
137
139 Portions of this text are reprinted and reproduced in electronic form
140 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
141 -- Portable Operating System Interface (POSIX), The Open Group Base
142 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
143 cal and Electronics Engineers, Inc and The Open Group. (This is
144 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
145 event of any discrepancy between this version and the original IEEE and
146 The Open Group Standard, the original IEEE and The Open Group Standard
147 is the referee document. The original Standard can be obtained online
148 at http://www.unix.org/online.html .
149
150 Any typographical or formatting errors that appear in this page are
151 most likely to have been introduced during the conversion of the source
152 files to man page format. To report such errors, see https://www.ker‐
153 nel.org/doc/man-pages/reporting_bugs.html .
154
155
156
157IEEE/The Open Group 2013 FSTATVFS(3P)