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