xref: /dragonfly/lib/libc/sys/statfs.2 (revision ef2b2b9d)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)statfs.2	8.5 (Berkeley) 5/24/95
29.\" $FreeBSD: src/lib/libc/sys/statfs.2,v 1.9.2.7 2001/12/14 18:34:01 ru Exp $
30.\"
31.Dd September 28, 2008
32.Dt STATFS 2
33.Os
34.Sh NAME
35.Nm statfs ,
36.Nm fstatfs
37.Nd get file system statistics
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In sys/param.h
42.In 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
49returns information about a mounted file system.
50.Fa Path
51is the path name of any file within the mounted filesystem.
52.Fa Buf
53is a pointer to a
54.Fn statfs
55structure defined as follows:
56.Bd -literal
57typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
58
59/*
60 * file system statistics
61 */
62
63#define MFSNAMELEN 16	/* length of fs type name, including null */
64#define MNAMELEN   90	/* length of buffer for returned name */
65
66struct statfs {
67	long	f_bsize;	/* fundamental file system block size */
68	long	f_iosize;	/* optimal transfer block size */
69	long	f_blocks;	/* total data blocks in file system */
70	long	f_bfree;	/* free blocks in fs */
71	long	f_bavail;	/* free blocks avail to non-superuser */
72	long	f_files;	/* total file nodes in file system */
73	long	f_ffree;	/* free file nodes in fs */
74	fsid_t	f_fsid;		/* file system id */
75	uid_t	f_owner;	/* user that mounted the filesystem */
76	int	f_type;		/* type of filesystem */
77	int	f_flags;	/* copy of mount exported flags */
78	long    f_syncwrites;	/* count of sync writes since mount */
79	long    f_asyncwrites;	/* count of async writes since mount */
80	char	f_fstypename[MFSNAMELEN]; /* fs type name */
81	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
82	long    f_syncreads;	/* count of sync reads since mount */
83	long    f_asyncreads;	/* count of async reads since mount */
84	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
85};
86.Ed
87.Pp
88The flags that may be returned include:
89.Bl -tag -width ".Dv MNT_SYNCHRONOUS"
90.It Dv MNT_RDONLY
91The filesystem is mounted read-only;
92Even the super-user may not write on it.
93.It Dv MNT_NOEXEC
94Files may not be executed from the filesystem.
95.It Dv MNT_NOSUID
96Setuid and setgid bits on files are not honored when they are executed.
97.It Dv MNT_NODEV
98Special files in the filesystem may not be opened.
99.It Dv MNT_SYNCHRONOUS
100All I/O to the filesystem is done synchronously.
101.It Dv MNT_ASYNC
102No filesystem I/O is done synchronously.
103.It Dv MNT_LOCAL
104The filesystem resides locally.
105.It Dv MNT_QUOTA
106The filesystem has quotas enabled on it.
107.It Dv MNT_ROOTFS
108Identifies the root filesystem.
109.It Dv MNT_EXRDONLY
110The filesystem is exported read-only.
111.It Dv MNT_EXPORTED
112The filesystem is exported for both reading and writing.
113.It Dv MNT_DEFEXPORTED
114The filesystem is exported for both reading and writing to any Internet host.
115.It Dv MNT_EXPORTANON
116The filesystem maps all remote accesses to the anonymous user.
117.It Dv MNT_EXKERB
118The filesystem is exported with Kerberos uid mapping.
119.El
120.Pp
121Fields that are undefined for a particular file system are set to -1.
122.Fn Fstatfs
123returns the same information about an open file referenced by descriptor
124.Fa fd .
125.Sh RETURN VALUES
126.Rv -std
127.Sh ERRORS
128.Fn Statfs
129fails if one or more of the following are true:
130.Bl -tag -width Er
131.It Bq Er ENOTDIR
132A component of the path prefix of
133.Fa path
134is not a directory.
135.It Bq Er ENAMETOOLONG
136The length of a component of
137.Fa path
138exceeds 255 characters,
139or the length of
140.Fa path
141exceeds 1023 characters.
142.It Bq Er ENOENT
143The file referred to by
144.Fa path
145does not exist.
146.It Bq Er EACCES
147Search permission is denied for a component of the path prefix of
148.Fa path .
149.It Bq Er ELOOP
150Too many symbolic links were encountered in translating
151.Fa path .
152.It Bq Er EFAULT
153.Fa Buf
154or
155.Fa path
156points to an invalid address.
157.It Bq Er EIO
158An
159.Tn I/O
160error occurred while reading from or writing to the file system.
161.El
162.Pp
163.Fn Fstatfs
164fails if one or more of the following are true:
165.Bl -tag -width Er
166.It Bq Er EBADF
167.Fa fd
168is not a valid open file descriptor.
169.It Bq Er EFAULT
170.Fa Buf
171points to an invalid address.
172.It Bq Er EIO
173An
174.Tn I/O
175error occurred while reading from or writing to the file system.
176.El
177.Sh SEE ALSO
178.Xr stat 2 ,
179.Xr statvfs 2
180.Sh HISTORY
181The
182.Fn statfs
183function first appeared in
184.Bx 4.4 .
185