xref: /original-bsd/lib/libc/sys/getfsstat.2 (revision 7e21a27b)
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.\"	@(#)getfsstat.2	8.2 (Berkeley) 04/03/95
7.\"
8.Dd
9.Dt GETFSSTAT 2
10.Os
11.Sh NAME
12.Nm getfsstat
13.Nd get list of all mounted filesystems
14.Sh SYNOPSIS
15.Fd #include <sys/param.h>
16.Fd #include <sys/ucred.h>
17.Fd #include <sys/mount.h>
18.Ft int
19.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags"
20.Sh DESCRIPTION
21.Fn Getfsstat
22returns information about all mounted filesystems.
23.Fa Buf
24is a pointer to
25.Xr statfs
26structures defined as follows:
27.Bd -literal
28typedef quad fsid_t;
29
30#define MFSNAMELEN	16	/* length of fs type name, including null */
31#define	MNAMELEN	90	/* length of buffer for returned name */
32
33struct statfs {
34	short	f_type;			/* filesystem type number */
35	short	f_flags;		/* copy of mount flags */
36	long	f_bsize;		/* fundamental file system block size */
37	long	f_iosize;		/* optimal transfer block size */
38	long	f_blocks;		/* total data blocks in file system */
39	long	f_bfree;		/* free blocks in fs */
40	long	f_bavail;		/* free blocks avail to non-superuser */
41	long	f_files;		/* total file nodes in file system */
42	long	f_ffree;		/* free file nodes in fs */
43	fsid_t	f_fsid;			/* file system id */
44	uid_t	f_owner;		/* user that mounted the filesystem */
45	long	f_spare[4];		/* spare for later */
46	char	f_fstypename[MFSNAMELEN]; /* fs type name */
47	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
48	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
49};
50.Ed
51.Pp
52Fields that are undefined for a particular filesystem are set to -1.
53The buffer is filled with an array of
54.Fa fsstat
55structures, one for each mounted filesystem
56up to the size specified by
57.Fa bufsize .
58.Pp
59If
60.Fa buf
61is given as NULL,
62.Fn getfsstat
63returns just the number of mounted filesystems.
64.Pp
65Normally
66.Fa flags
67should be specified as
68.Dv MNT_WAIT .
69If
70.Fa flags
71is set to
72.Dv MNT_NOWAIT ,
73.Fn getfsstat
74will return the information it has available without requesting
75an update from each filesystem.
76Thus, some of the information will be out of date, but
77.Fn getfsstat
78will not block waiting for information from a filesystem that is
79unable to respond.
80.Sh RETURN VALUES
81Upon successful completion, the number of
82.Fa fsstat
83structures is returned.
84Otherwise, -1 is returned and the global variable
85.Va errno
86is set to indicate the error.
87.Sh ERRORS
88.Fn Getfsstat
89fails if one or more of the following are true:
90.Bl -tag -width Er
91.It EFAULT
92.Fa Buf
93points to an invalid address.
94.It EIO
95An
96.Tn I/O
97error occurred while reading from or writing to the filesystem.
98.El
99.Sh SEE ALSO
100.Xr statfs 2 ,
101.Xr fstab 5 ,
102.Xr mount 8
103.Sh HISTORY
104The
105.Nm getfsstat
106function first appeared in 4.4BSD.
107