OSDN Git Service

e35118780a6a6d62658dd5c64d909af9edc313b8
[linuxjm/LDP_man-pages.git] / original / man3 / statvfs.3
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 2003-08-22 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 statvfs, fstatvfs \- get file system statistics
33 .SH SYNOPSIS
34 .B #include <sys/statvfs.h>
35 .sp
36 .BI "int statvfs(const char *" path ", struct statvfs *" buf );
37 .br
38 .BI "int fstatvfs(int " fd ", struct statvfs *" buf );
39 .SH DESCRIPTION
40 The function
41 .BR statvfs ()
42 returns information about a mounted file system.
43 .I path
44 is the pathname of any file within the mounted file system.
45 .I buf
46 is a pointer to a
47 .I statvfs
48 structure defined approximately as follows:
49
50 .in +4n
51 .nf
52 struct statvfs {
53     unsigned long  f_bsize;    /* file system block size */
54     unsigned long  f_frsize;   /* fragment size */
55     fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */
56     fsblkcnt_t     f_bfree;    /* # free blocks */
57     fsblkcnt_t     f_bavail;   /* # free blocks for unprivileged users */
58     fsfilcnt_t     f_files;    /* # inodes */
59     fsfilcnt_t     f_ffree;    /* # free inodes */
60     fsfilcnt_t     f_favail;   /* # free inodes for unprivileged users */
61     unsigned long  f_fsid;     /* file system ID */
62     unsigned long  f_flag;     /* mount flags */
63     unsigned long  f_namemax;  /* maximum filename length */
64 };
65 .fi
66 .in
67
68 Here the types
69 .I fsblkcnt_t
70 and
71 .I fsfilcnt_t
72 are defined in
73 .IR <sys/types.h> .
74 Both used to be
75 .IR "unsigned long" .
76
77 The field
78 .I f_flag
79 is a bit mask (of mount flags, see
80 .BR mount (8)).
81 Bits defined by POSIX are
82 .TP
83 .B ST_RDONLY
84 Read-only file system.
85 .TP
86 .B ST_NOSUID
87 Set-user-ID/set-group-ID bits are ignored by
88 .BR exec (3).
89 .LP
90 It is unspecified whether all members of the returned struct
91 have meaningful values on all file systems.
92
93 .BR fstatvfs ()
94 returns the same information about an open file referenced by descriptor
95 .IR fd .
96 .SH RETURN VALUE
97 On success, zero is returned.
98 On error, \-1 is returned, and
99 .I errno
100 is set appropriately.
101 .SH ERRORS
102 .TP
103 .B EACCES
104 .RB ( statvfs ())
105 Search permission is denied for a component of the path prefix of
106 .IR path .
107 (See also
108 .BR path_resolution (7).)
109 .TP
110 .B EBADF
111 .RB ( fstatvfs ())
112 .I fd
113 is not a valid open file descriptor.
114 .TP
115 .B EFAULT
116 .I Buf
117 or
118 .I path
119 points to an invalid address.
120 .TP
121 .B EINTR
122 This call was interrupted by a signal.
123 .TP
124 .B EIO
125 An I/O error occurred while reading from the file system.
126 .TP
127 .B ELOOP
128 .RB ( statvfs ())
129 Too many symbolic links were encountered in translating
130 .IR path .
131 .TP
132 .B ENAMETOOLONG
133 .RB ( statvfs ())
134 .I path
135 is too long.
136 .TP
137 .B ENOENT
138 .RB ( statvfs ())
139 The file referred to by
140 .I path
141 does not exist.
142 .TP
143 .B ENOMEM
144 Insufficient kernel memory was available.
145 .TP
146 .B ENOSYS
147 The file system does not support this call.
148 .TP
149 .B ENOTDIR
150 .RB ( statvfs ())
151 A component of the path prefix of
152 .I path
153 is not a directory.
154 .TP
155 .B EOVERFLOW
156 Some values were too large to be represented in the returned struct.
157 .SH CONFORMING TO
158 POSIX.1-2001.
159 .SH NOTES
160 The Linux kernel has system calls
161 .BR statfs (2)
162 and
163 .BR fstatfs (2)
164 to support this library call.
165
166 The current glibc implementations of
167 .sp
168 .nf
169    pathconf(path, _PC_REC_XFER_ALIGN);
170    pathconf(path, _PC_ALLOC_SIZE_MIN);
171    pathconf(path, _PC_REC_MIN_XFER_SIZE);
172 .fi
173 .sp
174 respectively use the
175 .IR f_frsize ,
176 .IR f_frsize ,
177 and
178 .I f_bsize
179 fields of the return value of
180 .IR "statvfs(path,buf)" .
181 .SH SEE ALSO
182 .BR statfs (2)