]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/statvfs.2
ffix
[thirdparty/man-pages.git] / man2 / statvfs.2
1 .\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" The pathconf note is from Walter Harms
24 .\" This is not a system call on Linux
25 .\"
26 .\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
27 .\"
28 .TH STATVFS 2 2003-08-22 "Linux 2.6.0" "Linux Programmer's Manual"
29 .SH NAME
30 statvfs, fstatvfs \- get file system statistics
31 .SH SYNOPSIS
32 .B #include <sys/statvfs.h>
33 .sp
34 .BI "int statvfs(const char *" path ", struct statvfs *" buf );
35 .br
36 .BI "int fstatvfs(int " fd ", struct statvfs *" buf );
37 .SH DESCRIPTION
38 The function
39 .BR statvfs ()
40 returns information about a mounted file system.
41 .I path
42 is the pathname of any file within the mounted filesystem.
43 .I buf
44 is a pointer to a
45 .I statvfs
46 structure defined approximately as follows:
47
48 .nf
49 struct statvfs {
50 unsigned long f_bsize; /* file system block size */
51 unsigned long f_frsize; /* fragment size */
52 fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
53 fsblkcnt_t f_bfree; /* # free blocks */
54 fsblkcnt_t f_bavail; /* # free blocks for non-root */
55 fsfilcnt_t f_files; /* # inodes */
56 fsfilcnt_t f_ffree; /* # free inodes */
57 fsfilcnt_t f_favail; /* # free inodes for non-root */
58 unsigned long f_fsid; /* file system ID */
59 unsigned long f_flag; /* mount flags */
60 unsigned long f_namemax; /* maximum filename length */
61 };
62 .fi
63
64 Here the types
65 .B fsblkcnt_t
66 and
67 .B fsfilcnt_t
68 are defined in
69 .IR <sys/types.h> .
70 Both used to be
71 .IR "unsigned long" .
72
73 The field
74 .I f_flag
75 is a bit mask (of mount flags, see
76 .BR mount (8)).
77 Bits defined by POSIX are
78 .TP
79 .B ST_RDONLY
80 Read-only file system.
81 .TP
82 .B ST_NOSUID
83 Set-user-ID/set-group-ID bits are ignored by
84 .BR exec (2).
85 .LP
86 It is unspecified whether all members of the returned struct
87 have meaningful values on all filesystems.
88
89 .BR fstatvfs ()
90 returns the same information about an open file referenced by descriptor
91 .IR fd .
92 .SH "RETURN VALUE"
93 On success, zero is returned. On error, \-1 is returned, and
94 .I errno
95 is set appropriately.
96 .SH ERRORS
97 .TP
98 .B EACCES
99 .RB ( statvfs ())
100 Search permission is denied for a component of the path prefix of
101 .IR path .
102 (See also
103 .BR path_resolution (2).)
104 .TP
105 .B EBADF
106 .RB ( fstatvfs ())
107 .I fd
108 is not a valid open file descriptor.
109 .TP
110 .B EFAULT
111 .I Buf
112 or
113 .I path
114 points to an invalid address.
115 .TP
116 .B EINTR
117 This call was interrupted by a signal.
118 .TP
119 .B EIO
120 An I/O error occurred while reading from the file system.
121 .TP
122 .B ELOOP
123 .RB ( statvfs ())
124 Too many symbolic links were encountered in translating
125 .IR path .
126 .TP
127 .B ENAMETOOLONG
128 .RB ( statvfs ())
129 .I path
130 is too long.
131 .TP
132 .B ENOENT
133 .RB ( statvfs ())
134 The file referred to by
135 .I path
136 does not exist.
137 .TP
138 .B ENOMEM
139 Insufficient kernel memory was available.
140 .TP
141 .B ENOSYS
142 The file system does not support this call.
143 .TP
144 .B ENOTDIR
145 .RB ( statvfs ())
146 A component of the path prefix of
147 .I path
148 is not a directory.
149 .TP
150 .B EOVERFLOW
151 Some values were too large to be represented in the returned struct.
152 .SH "CONFORMING TO"
153 POSIX.1-2001
154 .SH NOTES
155 The Linux kernel has system calls
156 .BR statfs ()
157 and
158 .BR fstatfs ()
159 to support this library call.
160
161 The current glibc implementations of
162 .sp
163 .nf
164 pathconf(path, _PC_REC_XFER_ALIGN);
165 pathconf(path, _PC_ALLOC_SIZE_MIN);
166 pathconf(path, _PC_REC_MIN_XFER_SIZE);
167 .fi
168 .sp
169 respectively use the
170 .IR f_frsize ,
171 .IR f_frsize ,
172 and
173 .IR f_bsize
174 fields of the return value of
175 .IR "statvfs(path,buf)" .
176 .SH "SEE ALSO"
177 .BR statfs (2)