Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / libc / sys / statfs.2
1 .\" Copyright (c) 1989, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
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.
19 .\"
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.
31 .\"
32 .\"     @(#)statfs.2    8.5 (Berkeley) 5/24/95
33 .\" $FreeBSD: src/lib/libc/sys/statfs.2,v 1.9.2.7 2001/12/14 18:34:01 ru Exp $
34 .\"
35 .Dd May 24, 1995
36 .Dt STATFS 2
37 .Os
38 .Sh NAME
39 .Nm statfs
40 .Nd get file system statistics
41 .Sh LIBRARY
42 .Lb libc
43 .Sh SYNOPSIS
44 .In sys/param.h
45 .In sys/mount.h
46 .Ft int
47 .Fn statfs "const char *path" "struct statfs *buf"
48 .Ft int
49 .Fn fstatfs "int fd" "struct statfs *buf"
50 .Sh DESCRIPTION
51 .Fn Statfs
52 returns information about a mounted file system.
53 .Fa Path
54 is the path name of any file within the mounted filesystem.
55 .Fa Buf
56 is a pointer to a
57 .Fn statfs
58 structure defined as follows:
59 .Bd -literal
60 typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
61
62 /*
63  * file system statistics
64  */
65
66 #define MFSNAMELEN 16   /* length of fs type name, including null */
67 #define MNAMELEN   90   /* length of buffer for returned name */
68
69 struct statfs {
70 long    f_bsize;          /* fundamental file system block size */
71 long    f_iosize;         /* optimal transfer block size */
72 long    f_blocks;         /* total data blocks in file system */
73 long    f_bfree;          /* free blocks in fs */
74 long    f_bavail;         /* free blocks avail to non-superuser */
75 long    f_files;          /* total file nodes in file system */
76 long    f_ffree;          /* free file nodes in fs */
77 fsid_t  f_fsid;           /* file system id */
78 uid_t   f_owner;          /* user that mounted the filesystem */
79 int     f_type;           /* type of filesystem */
80 int     f_flags;          /* copy of mount flags */
81 long    f_syncwrites;     /* count of sync writes since mount */
82 long    f_asyncwrites;    /* count of async writes since mount */
83 char    f_fstypename[MFSNAMELEN];/* fs type name */
84 char    f_mntonname[MNAMELEN];   /* mount point */
85 long    f_syncreads;             /* count of sync reads since mount */
86 long    f_asyncreads;            /* count of async reads since mount */
87 char    f_mntfromname[MNAMELEN]; /* mounted filesystem */
88 };
89 .Ed
90 The flags that may be returned include:
91 .Bl -tag -width MNT_SYNCHRONOUS
92 .It Dv MNT_RDONLY
93 The filesystem is mounted read-only;
94 Even the super-user may not write on it.
95 .It Dv MNT_NOEXEC
96 Files may not be executed from the filesystem.
97 .It Dv MNT_NOSUID
98 Setuid and setgid bits on files are not honored when they are executed.
99 .It Dv MNT_NODEV
100 Special files in the filesystem may not be opened.
101 .It Dv MNT_SYNCHRONOUS
102 All I/O to the filesystem is done synchronously.
103 .It Dv MNT_ASYNC
104 No filesystem I/O is done synchronously.
105 .It Dv MNT_LOCAL
106 The filesystem resides locally.
107 .It Dv MNT_QUOTA
108 The filesystem has quotas enabled on it.
109 .It Dv MNT_ROOTFS
110 Identifies the root filesystem.
111 .It Dv MNT_EXRDONLY
112 The filesystem is exported read-only.
113 .It Dv MNT_EXPORTED
114 The filesystem is exported for both reading and writing.
115 .It Dv MNT_DEFEXPORTED
116 The filesystem is exported for both reading and writing to any Internet host.
117 .It Dv MNT_EXPORTANON
118 The filesystem maps all remote accesses to the anonymous user.
119 .It Dv MNT_EXKERB
120 The filesystem is exported with Kerberos uid mapping.
121 .El
122 .Pp
123 Fields that are undefined for a particular file system are set to -1.
124 .Fn Fstatfs
125 returns the same information about an open file referenced by descriptor
126 .Fa fd .
127 .Sh RETURN VALUES
128 .Rv -std
129 .Sh ERRORS
130 .Fn Statfs
131 fails if one or more of the following are true:
132 .Bl -tag -width Er
133 .It Bq Er ENOTDIR
134 A component of the path prefix of
135 .Fa Path
136 is not a directory.
137 .It Bq Er ENAMETOOLONG
138 The length of a component of
139 .Fa path
140 exceeds 255 characters,
141 or the length of
142 .Fa path
143 exceeds 1023 characters.
144 .It Bq Er ENOENT
145 The file referred to by
146 .Fa path
147 does not exist.
148 .It Bq Er EACCES
149 Search permission is denied for a component of the path prefix of
150 .Fa path .
151 .It Bq Er ELOOP
152 Too many symbolic links were encountered in translating
153 .Fa path .
154 .It Bq Er EFAULT
155 .Fa Buf
156 or
157 .Fa path
158 points to an invalid address.
159 .It Bq Er EIO
160 An
161 .Tn I/O
162 error occurred while reading from or writing to the file system.
163 .El
164 .Pp
165 .Fn Fstatfs
166 fails if one or more of the following are true:
167 .Bl -tag -width Er
168 .It Bq Er EBADF
169 .Fa fd
170 is not a valid open file descriptor.
171 .It Bq Er EFAULT
172 .Fa Buf
173 points to an invalid address.
174 .It Bq Er EIO
175 An
176 .Tn I/O
177 error occurred while reading from or writing to the file system.
178 .El
179 .Sh HISTORY
180 The
181 .Fn statfs
182 function first appeared in
183 .Bx 4.4 .