socket/socketpair: Add SOCK_{NONBLOCK,CLOEXEC} support.
[dragonfly.git] / lib / libc / sys / statvfs.2
1 .\"     $OpenBSD: statvfs.3,v 1.5 2008/03/26 09:37:59 jmc Exp $
2 .\"     $NetBSD: statfs.2,v 1.10 1995/06/29 11:40:48 cgd Exp $
3 .\"     $DragonFly: src/lib/libc/sys/statvfs.2,v 1.3 2008/09/30 08:28:36 swildner Exp $
4 .\"
5 .\" Copyright (c) 1989, 1991, 1993
6 .\"     The Regents of the University of California.  All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. 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.3 (Berkeley) 2/11/94
33 .\"
34 .Dd September 28, 2008
35 .Dt STATVFS 2
36 .Os
37 .Sh NAME
38 .Nm statvfs ,
39 .Nm fstatvfs
40 .Nd get file system statistics
41 .Sh LIBRARY
42 .Lb libc
43 .Sh SYNOPSIS
44 .In sys/statvfs.h
45 .Ft int
46 .Fn statvfs "const char *path" "struct statvfs *buf"
47 .Ft int
48 .Fn fstatvfs "int fd" "struct statvfs *buf"
49 .Sh DESCRIPTION
50 .Fn statvfs
51 returns information about a mounted file system.
52 .Fa path
53 is the path name of any file within the mounted file system.
54 .Fa buf
55 is a pointer to a
56 .Nm statvfs
57 structure defined as follows:
58 .Bd -literal
59 struct statvfs {
60         unsigned long f_bsize;       /* file system block size */
61         unsigned long f_frsize;      /* fundamental file system block size */
62         fsblkcnt_t    f_blocks;      /* number of blocks (unit f_frsize) */
63         fsblkcnt_t    f_bfree;       /* free blocks in file system */
64         fsblkcnt_t    f_bavail;      /* free blocks for non-root */
65         fsfilcnt_t    f_files;       /* total file inodes */
66         fsfilcnt_t    f_ffree;       /* free file inodes */
67         fsfilcnt_t    f_favail;      /* free file inodes for to non-root */
68         unsigned long f_fsid;        /* file system id */
69         unsigned long f_flag;        /* bit mask of f_flag values */
70         unsigned long f_namemax;     /* maximum filename length */
71         uid_t         f_owner;       /* user that mounted the filesystem */
72         unsigned int  f_type;        /* filesystem type */
73
74         uint64_t      f_syncreads;   /* count of sync reads since mount */
75         uint64_t      f_syncwrites;  /* count of sync writes since mount */
76
77         uint64_t      f_asyncreads;  /* count of async reads since mount */
78         uint64_t      f_asyncwrites; /* count of async writes since mount */
79
80         /*
81          * DragonFly extensions - full uuid FSID and owner
82          */
83         uuid_t        f_fsid_uuid;
84         uuid_t        f_uid_uuid;
85 };
86
87 /*
88  * f_flag definitions
89  */
90 #define ST_RDONLY     0x00000001     /* fs is read-only */
91 #define ST_NOSUID     0x00000002     /* ST_ISUID or ST_ISGID not supported */
92
93 /*
94  * DragonFly specific flags
95  */
96 #define ST_FSID_UUID  0x40000000     /* f_fsid_uuid field is valid */
97 #define ST_OWNER_UUID 0x80000000     /* f_owner_uuid field is valid */
98 .Ed
99 .Pp
100 The fields of type
101 .Va fsblkcnt_t
102 are reported in units of
103 .Va f_frsize .
104 .Pp
105 .Fn fstatvfs
106 returns the same information about an open file referenced by descriptor
107 .Fa fd .
108 .Sh RETURN VALUES
109 .Rv -std statvfs fstatvfs
110 .Sh ERRORS
111 .Fn statvfs
112 fails if one or more of the following are true:
113 .Bl -tag -width Er
114 .It Bq Er ENOTDIR
115 A component of the path prefix of
116 .Fa path
117 is not a directory.
118 .It Bq Er ENAMETOOLONG
119 The length of a component of
120 .Fa path
121 exceeds
122 .Dv {NAME_MAX}
123 characters, or the length of
124 .Fa path
125 exceeds
126 .Dv {PATH_MAX}
127 characters.
128 .It Bq Er ENOENT
129 The file referred to by
130 .Fa path
131 does not exist.
132 .It Bq Er EACCES
133 Search permission is denied for a component of the path prefix of
134 .Fa path .
135 .It Bq Er ELOOP
136 Too many symbolic links were encountered in translating
137 .Fa path .
138 .It Bq Er EFAULT
139 .Fa buf
140 or
141 .Fa path
142 points to an invalid address.
143 .It Bq Er EIO
144 An
145 .Tn I/O
146 error occurred while reading from or writing to the file system.
147 .El
148 .Pp
149 .Fn fstatvfs
150 fails if one or more of the following are true:
151 .Bl -tag -width Er
152 .It Bq Er EBADF
153 .Fa fd
154 is not a valid open file descriptor.
155 .It Bq Er EFAULT
156 .Fa buf
157 points to an invalid address.
158 .It Bq Er EIO
159 An
160 .Tn I/O
161 error occurred while reading from or writing to the file system.
162 .El
163 .Sh SEE ALSO
164 .Xr df 1 ,
165 .Xr mount 2 ,
166 .Xr stat 2 ,
167 .Xr statfs 2
168 .Sh STANDARDS
169 The
170 .Fn statvfs
171 and
172 .Fn fstatvfs
173 system calls conform to
174 .St -p1003.1-2001 .
175 .Sh HISTORY
176 The
177 .Fn statvfs
178 and
179 .Fn fstatvfs
180 functions first appeared in
181 .Dx 1.13 .