]> git.saurik.com Git - apple/xnu.git/blame - bsd/man/man2/getfsstat.2
xnu-1504.15.3.tar.gz
[apple/xnu.git] / bsd / man / man2 / getfsstat.2
CommitLineData
9bccf70c
A
1.\" $NetBSD: getfsstat.2,v 1.6 1995/06/29 11:40:44 cgd Exp $
2.\"
3.\" Copyright (c) 1989, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)getfsstat.2 8.1 (Berkeley) 6/9/93
35.\"
b0d623f7 36.Dd Oct 28, 2008
9bccf70c
A
37.Dt GETFSSTAT 2
38.Os
39.Sh NAME
40.Nm getfsstat
41.Nd get list of all mounted file systems
42.Sh SYNOPSIS
43.Fd #include <sys/param.h>
44.Fd #include <sys/ucred.h>
45.Fd #include <sys/mount.h>
46.Ft int
91447636 47.Fn getfsstat "struct statfs *buf" "int bufsize" "int flags"
b0d623f7
A
48.Sh TRANSITIIONAL SYNOPSIS (NOW DEPRECATED)
49.Ft int
50.br
51.Fn getfsstat64 "struct statfs64 *buf" "int bufsize" "int flags" ;
9bccf70c 52.Sh DESCRIPTION
b0d623f7
A
53The
54.Fn getfsstat
55function returns information about all mounted file systems.
56The
57.Fa buf
58argument is a pointer to an array of
9bccf70c 59.Xr statfs
b0d623f7
A
60structures.
61.Pp
62As of Mac OS X 10.6, the default size of the
63.Ft ino_t
64type is 64 bits (the macro
65.Dv _DARWIN_FEATURE_64_BIT_INODE
66will be defined).
67While there is no
68.Ft ino_t
69type used in the
70.Xr statfs
71structure, the changes to
72.Fn getfsstat
73are grouped together with the 64-bit inode changes.
74The string fields in the
75.Xr statfs
76structure are larger and the variant symbol
77.Li _getfsstat$INODE64
78will be automatically used.
79The
80.Xr statfs
81structure is defined as:
9bccf70c
A
82.Bd -literal
83typedef struct { int32_t val[2]; } fsid_t;
84
b0d623f7
A
85#define MFSTYPENAMELEN 16 /* length of fs type name including null */
86#define MAXPATHLEN 1024
87#define MNAMELEN MAXPATHLEN
88
89struct statfs { /* when _DARWIN_FEATURE_64_BIT_INODE is defined */
90 uint32_t f_bsize; /* fundamental file system block size */
91 int32_t f_iosize; /* optimal transfer block size */
92 uint64_t f_blocks; /* total data blocks in file system */
93 uint64_t f_bfree; /* free blocks in fs */
94 uint64_t f_bavail; /* free blocks avail to non-superuser */
95 uint64_t f_files; /* total file nodes in file system */
96 uint64_t f_ffree; /* free file nodes in fs */
97 fsid_t f_fsid; /* file system id */
98 uid_t f_owner; /* user that mounted the filesystem */
99 uint32_t f_type; /* type of filesystem */
100 uint32_t f_flags; /* copy of mount exported flags */
101 uint32_t f_fssubtype; /* fs sub-type (flavor) */
102 char f_fstypename[MFSTYPENAMELEN]; /* fs type name */
103 char f_mntonname[MAXPATHLEN]; /* directory on which mounted */
104 char f_mntfromname[MAXPATHLEN]; /* mounted filesystem */
105 uint32_t f_reserved[8]; /* For future use */
106};
107.Ed
108.Pp
109(In 10.5, 64-bit
110.Ft ino_t ,
111larger
112.Xr statfs
113structure and variant symbol were available if the macro
114.Dv _DARWIN_USE_64_BIT_INODE
115is defined before any header files are included; this macro is optional in
11610.6.)
117.Pp
118If the macro
119.Dv _DARWIN_NO_64_BIT_INODE
120is defined before any header files are included, or if the deployment target
121is less than 10.6, the legacy
122.Xr statfs
123structure will be in effect.
124The
125.Ft ino_t
126type will be 32 bits (the
127.Dv _DARWIN_FEATURE_64_BIT_INODE
128macro will not be defined), the strings in the
129.Xr statfs
130structure will be their smaller legacy size (and long mount paths may no longer
131fit) and the undecorated symbol
132.Li _getfsstat
133will be used.
134This legacy
135.Fa statfs
136structure is defined as:
137.Bd -literal
138#define MFSNAMELEN 15 /* length of fs type name, not inc. nul */
139#define MNAMELEN 90 /* length of buffer for returned name */
9bccf70c 140
b0d623f7 141struct statfs { /* when _DARWIN_FEATURE_64_BIT_INODE is NOT defined */
55e303ae
A
142 short f_otype; /* type of file system (reserved: zero) */
143 short f_oflags; /* copy of mount flags (reserved: zero) */
9bccf70c
A
144 long f_bsize; /* fundamental file system block size */
145 long f_iosize; /* optimal transfer block size */
146 long f_blocks; /* total data blocks in file system */
147 long f_bfree; /* free blocks in fs */
148 long f_bavail; /* free blocks avail to non-superuser */
149 long f_files; /* total file nodes in file system */
150 long f_ffree; /* free file nodes in fs */
b0d623f7 151 fsid_t f_fsid; /* file system id */
9bccf70c 152 uid_t f_owner; /* user that mounted the file system */
55e303ae
A
153 short f_reserved1; /* reserved for future use */
154 short f_type; /* type of file system (reserved) */
155 long f_flags; /* copy of mount flags (reserved) */
156 long f_reserved2[2]; /* reserved for future use */
9bccf70c
A
157 char f_fstypename[MFSNAMELEN]; /* fs type name */
158 char f_mntonname[MNAMELEN]; /* directory on which mounted */
159 char f_mntfromname[MNAMELEN]; /* mounted file system */
55e303ae
A
160 char f_reserved3; /* reserved for future use */
161 long f_reserved4[4]; /* reserved for future use */
9bccf70c
A
162};
163.Ed
164.Pp
165Fields that are undefined for a particular file system are set to -1.
166The buffer is filled with an array of
167.Fa statfs
168structures, one for each mounted file system
169up to the size specified by
170.Fa bufsize .
171.Pp
172If
173.Fa buf
174is given as NULL,
175.Fn getfsstat
176returns just the number of mounted file systems.
177.Pp
9bccf70c
A
178If
179.Fa flags
180is set to
181.Dv MNT_NOWAIT ,
182.Fn getfsstat
91447636
A
183will directly return the information retained in the kernel
184to avoid delays caused by waiting for updated information from
185a file system that is perhaps temporarily unable to respond.
186Some of the information returned may be out of date, however; if
187.Fa flags
188is set to
189.Dv MNT_WAIT
b0d623f7
A
190or
191.Dv MNT_DWAIT
91447636 192instead,
9bccf70c 193.Fn getfsstat
91447636
A
194will request updated information from each mounted filesystem before
195returning.
9bccf70c
A
196.Sh RETURN VALUES
197Upon successful completion, the number of
198.Fa statfs
199structures is returned.
200Otherwise, -1 is returned and the global variable
201.Va errno
202is set to indicate the error.
203.Sh ERRORS
204.Fn Getfsstat
205fails if one or more of the following are true:
206.Bl -tag -width Er
207.It Bq Er EFAULT
b0d623f7
A
208The
209.Fa buf
210argument points to an invalid address.
9bccf70c
A
211.It Bq Er EIO
212An
213.Tn I/O
214error occurred while reading from or writing to the file system.
215.El
b0d623f7
A
216.Sh TRANSITIONAL DESCRIPTION (NOW DEPRECATED)
217The
218.Fn getfsstat64
219routine is equivalent to the default
220.Fn getfstat
221(when
222.Dv _DARWIN_FEATURE_64_BIT_INODE
223is defined), so there is no longer any reason to use it (it will be removed
224in the future).
9bccf70c
A
225.Sh SEE ALSO
226.Xr statfs 2 ,
227.Xr fstab 5 ,
228.Xr mount 8
229.Sh HISTORY
230The
231.Fn getfsstat
232function first appeared in 4.4BSD.