1FSTATVFS(3P)               POSIX Programmer's Manual              FSTATVFS(3P)
2
3
4

PROLOG

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

NAME

12       fstatvfs, statvfs — get file system information
13

SYNOPSIS

15       #include <sys/statvfs.h>
16
17       int fstatvfs(int fildes, struct statvfs *buf);
18       int statvfs(const char *restrict path, struct statvfs *restrict buf);
19

DESCRIPTION

21       The fstatvfs() function shall obtain information about the file  system
22       containing the file referenced by fildes.
23
24       The  statvfs()  function shall obtain information about the file system
25       containing the file named by path.
26
27       For both functions, the buf argument is a pointer to a  statvfs  struc‐
28       ture  that  shall  be filled. Read, write, or execute permission of the
29       named file is not required.
30
31       The following flags can be returned in the f_flag member:
32
33       ST_RDONLY   Read-only file system.
34
35       ST_NOSUID   Setuid/setgid bits ignored by exec.
36
37       It is unspecified whether all members of  the  statvfs  structure  have
38       meaningful values on all file systems.
39

RETURN VALUE

41       Upon  successful  completion,  statvfs()  shall return 0. Otherwise, it
42       shall return -1 and set errno to indicate the error.
43

ERRORS

45       The fstatvfs() and statvfs() functions shall fail if:
46
47       EIO    An I/O error occurred while reading the file system.
48
49       EINTR  A signal was caught during execution of the function.
50
51       EOVERFLOW
52              One of the values to be returned cannot be represented correctly
53              in the structure pointed to by buf.
54
55       The fstatvfs() function shall fail if:
56
57       EBADF  The fildes argument is not an open file descriptor.
58
59       The statvfs() function shall fail if:
60
61       EACCES Search permission is denied on a component of the path prefix.
62
63       ELOOP  A loop exists in symbolic links encountered during resolution of
64              the path argument.
65
66       ENAMETOOLONG
67              The  length  of  a  component  of  a  pathname  is  longer  than
68              {NAME_MAX}.
69
70       ENOENT A component of path does not name an existing file or path is an
71              empty string.
72
73       ENOTDIR
74              A component of the path prefix names an existing  file  that  is
75              neither  a  directory nor a symbolic link to a directory, or the
76              path argument contains at least one  non-<slash>  character  and
77              ends  with  one or more trailing <slash> characters and the last
78              pathname component names an existing  file  that  is  neither  a
79              directory nor a symbolic link to a directory.
80
81       The statvfs() function may fail if:
82
83       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
84              resolution of the path argument.
85
86       ENAMETOOLONG
87              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
88              tion  of  a symbolic link produced an intermediate result with a
89              length that exceeds {PATH_MAX}.
90
91       The following sections are informative.
92

EXAMPLES

94   Obtaining File System Information Using fstatvfs()
95       The following example shows how to obtain file system  information  for
96       the file system upon which the file named /home/cnd/mod1 resides, using
97       the  fstatvfs()  function.  The  /home/cnd/mod1  file  is  opened  with
98       read/write  privileges  and  the  open file descriptor is passed to the
99       fstatvfs() function.
100
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
117           #include <sys/statvfs.h>
118
119           struct statvfs buffer;
120           int            status;
121           ...
122           status = statvfs("/home/cnd/mod1", &buffer);
123

APPLICATION USAGE

125       None.
126

RATIONALE

128       None.
129

FUTURE DIRECTIONS

131       None.
132

SEE ALSO

134       chmod(), chown(),  creat(),  dup(),  exec,  fcntl(),  link(),  mknod(),
135       open(), pipe(), read(), time(), unlink(), utime(), write()
136
137       The Base Definitions volume of POSIX.1‐2017, <sys_statvfs.h>
138
140       Portions  of  this text are reprinted and reproduced in electronic form
141       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
142       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
143       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
144       Electrical  and  Electronics Engineers, Inc and The Open Group.  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.opengroup.org/unix/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                  2017                         FSTATVFS(3P)
Impressum