Commit | Line | Data |
---|---|---|
ad787160 C |
1 | .\" Copyright (c) 1989, 1991, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
f70c4002 | 3 | .\" |
ad787160 C |
4 | .\" Redistribution and use in source and binary forms, with or without |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
f70c4002 | 19 | .\" |
ad787160 C |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
f70c4002 | 31 | .\" |
ad787160 C |
32 | .\" @(#)statfs.2 8.1 (Berkeley) 6/9/93 |
33 | .\" | |
34 | .Dd June 9, 1993 | |
931b8415 | 35 | .Dt STATFS 2 |
faf7e3e0 | 36 | .Os |
931b8415 CL |
37 | .Sh NAME |
38 | .Nm statfs | |
39 | .Nd get file system statistics | |
40 | .Sh SYNOPSIS | |
d8d36f2a | 41 | .Fd #include <sys/param.h> |
931b8415 CL |
42 | .Fd #include <sys/mount.h> |
43 | .Ft int | |
44 | .Fn statfs "const char *path" "struct statfs *buf" | |
45 | .Ft int | |
46 | .Fn fstatfs "int fd" "struct statfs *buf" | |
47 | .Sh DESCRIPTION | |
48 | .Fn Statfs | |
f70c4002 | 49 | returns information about a mounted file system. |
931b8415 | 50 | .Fa Path |
f70c4002 | 51 | is the path name of any file within the mounted filesystem. |
931b8415 | 52 | .Fa Buf |
f70c4002 | 53 | is a pointer to a |
931b8415 | 54 | .Fn statfs |
f70c4002 | 55 | structure defined as follows: |
931b8415 | 56 | .Bd -literal |
f70c4002 | 57 | typedef quad fsid_t; |
931b8415 | 58 | |
f70c4002 | 59 | #define MNAMELEN 32 /* length of buffer for returned name */ |
931b8415 | 60 | |
f70c4002 | 61 | struct statfs { |
931b8415 CL |
62 | short f_type; /* type of filesystem (see below) */ |
63 | short f_flags; /* copy of mount flags */ | |
e5490a3f KM |
64 | long f_bsize; /* fundamental file system block size */ |
65 | long f_iosize; /* optimal transfer block size */ | |
931b8415 CL |
66 | long f_blocks; /* total data blocks in file system */ |
67 | long f_bfree; /* free blocks in fs */ | |
68 | long f_bavail; /* free blocks avail to non-superuser */ | |
69 | long f_files; /* total file nodes in file system */ | |
70 | long f_ffree; /* free file nodes in fs */ | |
71 | fsid_t f_fsid; /* file system id */ | |
72 | long f_spare[6]; /* spare for later */ | |
73 | char f_mntonname[MNAMELEN]; /* mount point */ | |
74 | char f_mntfromname[MNAMELEN]; /* mounted filesystem */ | |
f70c4002 KM |
75 | }; |
76 | /* | |
931b8415 CL |
77 | * File system types. |
78 | */ | |
f70c4002 KM |
79 | #define MOUNT_UFS 1 |
80 | #define MOUNT_NFS 2 | |
5fc83e4f KM |
81 | #define MOUNT_MFS 3 |
82 | #define MOUNT_PC 4 | |
931b8415 CL |
83 | .Ed |
84 | .Pp | |
85 | Fields that are undefined for a particular file system are set to -1. | |
86 | .Fn Fstatfs | |
f70c4002 | 87 | returns the same information about an open file referenced by descriptor |
931b8415 CL |
88 | .Fa fd . |
89 | .Sh RETURN VALUES | |
f70c4002 | 90 | Upon successful completion, a value of 0 is returned. |
931b8415 CL |
91 | Otherwise, -1 is returned and the global variable |
92 | .Va errno | |
f70c4002 | 93 | is set to indicate the error. |
931b8415 CL |
94 | .Sh ERRORS |
95 | .Fn Statfs | |
f70c4002 | 96 | fails if one or more of the following are true: |
931b8415 CL |
97 | .Bl -tag -width ENAMETOOLONGA |
98 | .It Bq Er ENOTDIR | |
f70c4002 | 99 | A component of the path prefix of |
931b8415 | 100 | .Fa Path |
f70c4002 | 101 | is not a directory. |
931b8415 CL |
102 | .It Bq Er EINVAL |
103 | .Fa path | |
f70c4002 | 104 | contains a character with the high-order bit set. |
931b8415 | 105 | .It Bq Er ENAMETOOLONG |
f70c4002 | 106 | The length of a component of |
931b8415 | 107 | .Fa path |
f70c4002 KM |
108 | exceeds 255 characters, |
109 | or the length of | |
931b8415 | 110 | .Fa path |
f70c4002 | 111 | exceeds 1023 characters. |
931b8415 | 112 | .It Bq Er ENOENT |
f70c4002 | 113 | The file referred to by |
931b8415 | 114 | .Fa path |
f70c4002 | 115 | does not exist. |
931b8415 | 116 | .It Bq Er EACCES |
f70c4002 | 117 | Search permission is denied for a component of the path prefix of |
931b8415 CL |
118 | .Fa path . |
119 | .It Bq Er ELOOP | |
f70c4002 | 120 | Too many symbolic links were encountered in translating |
931b8415 CL |
121 | .Fa path . |
122 | .It Bq Er EFAULT | |
123 | .Fa Buf | |
f70c4002 | 124 | or |
931b8415 | 125 | .Fa path |
f70c4002 | 126 | points to an invalid address. |
931b8415 | 127 | .It Bq Er EIO |
faf7e3e0 CL |
128 | An |
129 | .Tn I/O | |
130 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
131 | .El |
132 | .Pp | |
133 | .Fn Fstatfs | |
f70c4002 | 134 | fails if one or both of the following are true: |
931b8415 CL |
135 | .Bl -tag -width ENAMETOOLONGA |
136 | .It Bq Er EBADF | |
137 | .Fa Fd | |
f70c4002 | 138 | is not a valid open file descriptor. |
931b8415 CL |
139 | .It Bq Er EFAULT |
140 | .Fa Buf | |
f70c4002 | 141 | points to an invalid address. |
931b8415 | 142 | .It Bq Er EIO |
faf7e3e0 CL |
143 | An |
144 | .Tn I/O | |
145 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
146 | .El |
147 | .Sh HISTORY | |
148 | The | |
faf7e3e0 | 149 | .Nm statfs |
ad787160 | 150 | function first appeared in 4.4BSD. |