1 .\" $NetBSD: getfsstat.2,v 1.6 1995/06/29 11:40:44 cgd Exp $
3 .\" Copyright (c) 1989, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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
34 .\" @(#)getfsstat.2 8.1 (Berkeley) 6/9/93
41 .Nd get list of all mounted file systems
43 .Fd #include <sys/param.h>
44 .Fd #include <sys/ucred.h>
45 .Fd #include <sys/mount.h>
47 .Fn getfsstat "struct statfs *buf" "int bufsize" "int flags"
48 .Sh TRANSITIIONAL SYNOPSIS (NOW DEPRECATED)
51 .Fn getfsstat64 "struct statfs64 *buf" "int bufsize" "int flags" ;
55 function returns information about all mounted file systems.
58 argument is a pointer to an array of
62 As of Mac OS X 10.6, the default size of the
64 type is 64 bits (the macro
65 .Dv _DARWIN_FEATURE_64_BIT_INODE
71 structure, the changes to
73 are grouped together with the 64-bit inode changes.
74 The string fields in the
76 structure are larger and the variant symbol
77 .Li _getfsstat$INODE64
78 will be automatically used.
81 structure is defined as:
83 typedef struct { int32_t val[2]; } fsid_t;
85 #define MFSTYPENAMELEN 16 /* length of fs type name including null */
86 #define MAXPATHLEN 1024
87 #define MNAMELEN MAXPATHLEN
89 struct 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 */
113 structure and variant symbol were available if the macro
114 .Dv _DARWIN_USE_64_BIT_INODE
115 is defined before any header files are included; this macro is optional in
119 .Dv _DARWIN_NO_64_BIT_INODE
120 is defined before any header files are included, or if the deployment target
121 is less than 10.6, the legacy
123 structure will be in effect.
126 type will be 32 bits (the
127 .Dv _DARWIN_FEATURE_64_BIT_INODE
128 macro will not be defined), the strings in the
130 structure will be their smaller legacy size (and long mount paths may no longer
131 fit) and the undecorated symbol
136 structure is defined as:
138 #define MFSNAMELEN 15 /* length of fs type name, not inc. nul */
139 #define MNAMELEN 90 /* length of buffer for returned name */
141 struct statfs { /* when _DARWIN_FEATURE_64_BIT_INODE is NOT defined */
142 short f_otype; /* type of file system (reserved: zero) */
143 short f_oflags; /* copy of mount flags (reserved: zero) */
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 */
151 fsid_t f_fsid; /* file system id */
152 uid_t f_owner; /* user that mounted the file system */
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 */
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 */
160 char f_reserved3; /* reserved for future use */
161 long f_reserved4[4]; /* reserved for future use */
165 Fields that are undefined for a particular file system are set to -1.
166 The buffer is filled with an array of
168 structures, one for each mounted file system
169 up to the size specified by
176 returns just the number of mounted file systems.
183 will directly return the information retained in the kernel
184 to avoid delays caused by waiting for updated information from
185 a file system that is perhaps temporarily unable to respond.
186 Some of the information returned may be out of date, however; if
194 will request updated information from each mounted filesystem before
197 Upon successful completion, the number of
199 structures is returned.
200 Otherwise, -1 is returned and the global variable
202 is set to indicate the error.
205 fails if one or more of the following are true:
210 argument points to an invalid address.
214 error occurred while reading from or writing to the file system.
216 .Sh TRANSITIONAL DESCRIPTION (NOW DEPRECATED)
219 routine is equivalent to the default
222 .Dv _DARWIN_FEATURE_64_BIT_INODE
223 is defined), so there is no longer any reason to use it (it will be removed
232 function first appeared in 4.4BSD.