xref: /original-bsd/lib/libc/sys/statfs.2 (revision d09bf521)
1.\" Copyright (c) 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)statfs.2	8.5 (Berkeley) 05/24/95
7.\"
8.Dd
9.Dt STATFS 2
10.Os
11.Sh NAME
12.Nm statfs
13.Nd get file system statistics
14.Sh SYNOPSIS
15.Fd #include <sys/param.h>
16.Fd #include <sys/mount.h>
17.Ft int
18.Fn statfs "const char *path" "struct statfs *buf"
19.Ft int
20.Fn fstatfs "int fd" "struct statfs *buf"
21.Sh DESCRIPTION
22.Fn Statfs
23returns information about a mounted file system.
24.Fa Path
25is the path name of any file within the mounted filesystem.
26.Fa Buf
27is a pointer to a
28.Fn statfs
29structure defined as follows:
30.Bd -literal
31typedef quad fsid_t;
32
33#define MFSNAMELEN	16	/* length of fs type name, including null */
34#define	MNAMELEN	90	/* length of buffer for returned name */
35
36struct statfs {
37	short	f_type;			/* filesystem type number */
38	short	f_flags;		/* copy of mount flags */
39	long	f_bsize;		/* fundamental file system block size */
40	long	f_iosize;		/* optimal transfer block size */
41	long	f_blocks;		/* total data blocks in file system */
42	long	f_bfree;		/* free blocks in fs */
43	long	f_bavail;		/* free blocks avail to non-superuser */
44	long	f_files;		/* total file nodes in file system */
45	long	f_ffree;		/* free file nodes in fs */
46	fsid_t	f_fsid;			/* file system id */
47	uid_t	f_owner;		/* user that mounted the filesystem */
48	long	f_spare[4];		/* spare for later */
49	char	f_fstypename[MFSNAMELEN]; /* fs type name */
50	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
51	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
52};
53.Ed
54The flags that may be returned include:
55.Bl -tag -width MNT_ASYNCHRONOUS
56.It Dv MNT_RDONLY
57The filesystem is mounted read-only;
58Even the super-user may not write on it.
59.It Dv MNT_NOEXEC
60Files may not be executed from the filesystem.
61.It Dv MNT_NOSUID
62Setuid and setgid bits on files are not honored when they are executed.
63.It Dv MNT_NODEV
64Special files in the filesystem may not be opened.
65.It Dv MNT_SYNCHRONOUS
66All I/O to the filesystem is done synchronously.
67.It Dv MNT_ASYNCHRONOUS
68No filesystem I/O is done synchronously.
69.It Dv MNT_LOCAL
70The filesystem resides locally.
71.It Dv MNT_QUOTA
72The filesystem has quotas enabled on it.
73.It Dv MNT_ROOTFS
74Identifies the root filesystem.
75.It Dv MNT_EXRDONLY
76The filesystem is exported read-only.
77.It Dv MNT_EXPORTED
78The filesystem is exported for both reading and writing.
79.It Dv MNT_DEFEXPORTED
80The filesystem is exported for both reading and writing to any Internet host.
81.It Dv MNT_EXPORTANON
82The filesystem maps all remote accesses to the anonymous user.
83.It Dv MNT_EXKERB
84The filesystem is exported with Kerberos uid mapping.
85.El
86.Pp
87Fields that are undefined for a particular file system are set to -1.
88.Fn Fstatfs
89returns the same information about an open file referenced by descriptor
90.Fa fd .
91.Sh RETURN VALUES
92Upon successful completion, a value of 0 is returned.
93Otherwise, -1 is returned and the global variable
94.Va errno
95is set to indicate the error.
96.Sh ERRORS
97.Fn Statfs
98fails if one or more of the following are true:
99.Bl -tag -width ENAMETOOLONGA
100.It Bq Er ENOTDIR
101A component of the path prefix of
102.Fa Path
103is not a directory.
104.It Bq Er EINVAL
105.Fa path
106contains a character with the high-order bit set.
107.It Bq Er ENAMETOOLONG
108The length of a component of
109.Fa path
110exceeds 255 characters,
111or the length of
112.Fa path
113exceeds 1023 characters.
114.It Bq Er ENOENT
115The file referred to by
116.Fa path
117does not exist.
118.It Bq Er EACCES
119Search permission is denied for a component of the path prefix of
120.Fa path .
121.It Bq Er ELOOP
122Too many symbolic links were encountered in translating
123.Fa path .
124.It Bq Er EFAULT
125.Fa Buf
126or
127.Fa path
128points to an invalid address.
129.It Bq Er EIO
130An
131.Tn I/O
132error occurred while reading from or writing to the file system.
133.El
134.Pp
135.Fn Fstatfs
136fails if one or more of the following are true:
137.Bl -tag -width ENAMETOOLONGA
138.It Bq Er EBADF
139.Fa Fd
140is not a valid open file descriptor.
141.It Bq Er EFAULT
142.Fa Buf
143points to an invalid address.
144.It Bq Er EIO
145An
146.Tn I/O
147error occurred while reading from or writing to the file system.
148.El
149.Sh HISTORY
150The
151.Nm statfs
152function first appeared in 4.4BSD.
153