xref: /freebsd-14.2/lib/libc/sys/statfs.2 (revision 9b50d902)
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.3 (Berkeley) 2/11/94
33.\"
34.Dd February 11, 1994
35.Dt STATFS 2
36.Os
37.Sh NAME
38.Nm statfs
39.Nd get file system statistics
40.Sh SYNOPSIS
41.Fd #include <sys/param.h>
42.Fd #include <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 quad fsid_t;
58
59#define MNAMELEN 90	/* length of buffer for returned name */
60
61struct statfs {
62short	f_type;		  /* type of filesystem (see below) */
63short	f_flags;	  /* copy of mount flags */
64long	f_bsize;	  /* fundamental file system block size */
65long	f_iosize;	  /* optimal transfer block size */
66long	f_blocks;	  /* total data blocks in file system */
67long	f_bfree;	  /* free blocks in fs */
68long	f_bavail;	  /* free blocks avail to non-superuser */
69long	f_files;	  /* total file nodes in file system */
70long	f_ffree;	  /* free file nodes in fs */
71fsid_t	f_fsid;		  /* file system id */
72long	f_spare[9];	  /* spare for later */
73char	f_mntonname[MNAMELEN];	  /* mount point */
74char	f_mntfromname[MNAMELEN];  /* mounted filesystem */
75};
76/*
77* File system types.
78*/
79#define	MOUNT_UFS	1	/* Fast Filesystem */
80#define	MOUNT_NFS	2	/* Sun-compatible Network Filesystem */
81#define	MOUNT_MFS	3	/* Memory-based Filesystem */
82#define	MOUNT_MSDOS	4	/* MS/DOS Filesystem */
83#define	MOUNT_LFS	5	/* Log-based Filesystem */
84#define	MOUNT_LOFS	6	/* Loopback Filesystem */
85#define	MOUNT_FDESC	7	/* File Descriptor Filesystem */
86#define	MOUNT_PORTAL	8	/* Portal Filesystem */
87#define MOUNT_NULL	9	/* Minimal Filesystem Layer */
88#define MOUNT_UMAP	10	/* Uid/Gid Remapping Filesystem */
89#define MOUNT_KERNFS	11	/* Kernel Information Filesystem */
90#define MOUNT_PROCFS	12	/* /proc Filesystem */
91#define MOUNT_AFS	13	/* Andrew Filesystem */
92#define MOUNT_CD9660	14	/* ISO9660 (aka CDROM) Filesystem */
93#define MOUNT_UNION	15	/* Union (translucent) Filesystem */
94.Ed
95.Pp
96Fields that are undefined for a particular file system are set to -1.
97.Fn Fstatfs
98returns the same information about an open file referenced by descriptor
99.Fa fd .
100.Sh RETURN VALUES
101Upon successful completion, a value of 0 is returned.
102Otherwise, -1 is returned and the global variable
103.Va errno
104is set to indicate the error.
105.Sh ERRORS
106.Fn Statfs
107fails if one or more of the following are true:
108.Bl -tag -width ENAMETOOLONGA
109.It Bq Er ENOTDIR
110A component of the path prefix of
111.Fa Path
112is not a directory.
113.It Bq Er EINVAL
114.Fa path
115contains a character with the high-order bit set.
116.It Bq Er ENAMETOOLONG
117The length of a component of
118.Fa path
119exceeds 255 characters,
120or the length of
121.Fa path
122exceeds 1023 characters.
123.It Bq Er ENOENT
124The file referred to by
125.Fa path
126does not exist.
127.It Bq Er EACCES
128Search permission is denied for a component of the path prefix of
129.Fa path .
130.It Bq Er ELOOP
131Too many symbolic links were encountered in translating
132.Fa path .
133.It Bq Er EFAULT
134.Fa Buf
135or
136.Fa path
137points to an invalid address.
138.It Bq Er EIO
139An
140.Tn I/O
141error occurred while reading from or writing to the file system.
142.El
143.Pp
144.Fn Fstatfs
145fails if one or more of the following are true:
146.Bl -tag -width ENAMETOOLONGA
147.It Bq Er EBADF
148.Fa Fd
149is not a valid open file descriptor.
150.It Bq Er EFAULT
151.Fa Buf
152points to an invalid address.
153.It Bq Er EIO
154An
155.Tn I/O
156error occurred while reading from or writing to the file system.
157.El
158.Sh HISTORY
159The
160.Nm statfs
161function first appeared in 4.4BSD.
162