xref: /csrg-svn/lib/libc/sys/getfsstat.2 (revision 69682)
162907Sbostic.\" Copyright (c) 1989, 1991, 1993
262907Sbostic.\"	The Regents of the University of California.  All rights reserved.
338243Smckusick.\"
450487Scael.\" %sccs.include.redist.roff%
538243Smckusick.\"
6*69682Smckusick.\"	@(#)getfsstat.2	8.3 (Berkeley) 05/25/95
738243Smckusick.\"
847208Scael.Dd
947208Scael.Dt GETFSSTAT 2
1050487Scael.Os
1147208Scael.Sh NAME
1247208Scael.Nm getfsstat
1347208Scael.Nd get list of all mounted filesystems
1447208Scael.Sh SYNOPSIS
1551745Smckusick.Fd #include <sys/param.h>
1651745Smckusick.Fd #include <sys/ucred.h>
1747208Scael.Fd #include <sys/mount.h>
1847208Scael.Ft int
1947208Scael.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags"
2047208Scael.Sh DESCRIPTION
2147208Scael.Fn Getfsstat
2238243Smckusickreturns information about all mounted filesystems.
2347208Scael.Fa Buf
2447208Scaelis a pointer to
2547208Scael.Xr statfs
2638243Smckusickstructures defined as follows:
2747208Scael.Bd -literal
2838243Smckusicktypedef quad fsid_t;
2947208Scael
3068723Smckusick#define MFSNAMELEN	16	/* length of fs type name, including null */
3168723Smckusick#define	MNAMELEN	90	/* length of buffer for returned name */
3247208Scael
3338243Smckusickstruct statfs {
3468723Smckusick	short	f_type;			/* filesystem type number */
3568723Smckusick	short	f_flags;		/* copy of mount flags */
3668723Smckusick	long	f_bsize;		/* fundamental file system block size */
3768723Smckusick	long	f_iosize;		/* optimal transfer block size */
3868723Smckusick	long	f_blocks;		/* total data blocks in file system */
3968723Smckusick	long	f_bfree;		/* free blocks in fs */
4068723Smckusick	long	f_bavail;		/* free blocks avail to non-superuser */
4168723Smckusick	long	f_files;		/* total file nodes in file system */
4268723Smckusick	long	f_ffree;		/* free file nodes in fs */
4368723Smckusick	fsid_t	f_fsid;			/* file system id */
4468723Smckusick	uid_t	f_owner;		/* user that mounted the filesystem */
4568723Smckusick	long	f_spare[4];		/* spare for later */
4668723Smckusick	char	f_fstypename[MFSNAMELEN]; /* fs type name */
4768723Smckusick	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
4868723Smckusick	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
4938243Smckusick};
5047208Scael.Ed
5147208Scael.Pp
52*69682SmckusickThe flags that may be returned include:
53*69682Smckusick.Bl -tag -width MNT_ASYNCHRONOUS
54*69682Smckusick.It Dv MNT_RDONLY
55*69682SmckusickThe filesystem is mounted read-only;
56*69682SmckusickEven the super-user may not write on it.
57*69682Smckusick.It Dv MNT_NOEXEC
58*69682SmckusickFiles may not be executed from the filesystem.
59*69682Smckusick.It Dv MNT_NOSUID
60*69682SmckusickSetuid and setgid bits on files are not honored when they are executed.
61*69682Smckusick.It Dv MNT_NODEV
62*69682SmckusickSpecial files in the filesystem may not be opened.
63*69682Smckusick.It Dv MNT_SYNCHRONOUS
64*69682SmckusickAll I/O to the filesystem is done synchronously.
65*69682Smckusick.It Dv MNT_ASYNCHRONOUS
66*69682SmckusickNo filesystem I/O is done synchronously.
67*69682Smckusick.It Dv MNT_LOCAL
68*69682SmckusickThe filesystem resides locally.
69*69682Smckusick.It Dv MNT_QUOTA
70*69682SmckusickThe filesystem has quotas enabled on it.
71*69682Smckusick.It Dv MNT_ROOTFS
72*69682SmckusickIdentifies the root filesystem.
73*69682Smckusick.It Dv MNT_EXRDONLY
74*69682SmckusickThe filesystem is exported read-only.
75*69682Smckusick.It Dv MNT_EXPORTED
76*69682SmckusickThe filesystem is exported for both reading and writing.
77*69682Smckusick.It Dv MNT_DEFEXPORTED
78*69682SmckusickThe filesystem is exported for both reading and writing to any Internet host.
79*69682Smckusick.It Dv MNT_EXPORTANON
80*69682SmckusickThe filesystem maps all remote accesses to the anonymous user.
81*69682Smckusick.It Dv MNT_EXKERB
82*69682SmckusickThe filesystem is exported with Kerberos uid mapping.
83*69682Smckusick.El
84*69682Smckusick.Pp
8547208ScaelFields that are undefined for a particular filesystem are set to -1.
8638243SmckusickThe buffer is filled with an array of
8747208Scael.Fa fsstat
8838243Smckusickstructures, one for each mounted filesystem
8938243Smckusickup to the size specified by
9047208Scael.Fa bufsize .
9147208Scael.Pp
9238243SmckusickIf
9347208Scael.Fa buf
9447208Scaelis given as NULL,
9547208Scael.Fn getfsstat
9638243Smckusickreturns just the number of mounted filesystems.
9747208Scael.Pp
9840334SmckusickNormally
9947208Scael.Fa flags
10047208Scaelshould be specified as
10147208Scael.Dv MNT_WAIT .
10240334SmckusickIf
10347208Scael.Fa flags
10447208Scaelis set to
10547208Scael.Dv MNT_NOWAIT ,
10647208Scael.Fn getfsstat
10740334Smckusickwill return the information it has available without requesting
10840334Smckusickan update from each filesystem.
10940334SmckusickThus, some of the information will be out of date, but
11047208Scael.Fn getfsstat
11140334Smckusickwill not block waiting for information from a filesystem that is
11240334Smckusickunable to respond.
11347208Scael.Sh RETURN VALUES
11438243SmckusickUpon successful completion, the number of
11547208Scael.Fa fsstat
11638243Smckusickstructures is returned.
11747208ScaelOtherwise, -1 is returned and the global variable
11847208Scael.Va errno
11938243Smckusickis set to indicate the error.
12047208Scael.Sh ERRORS
12147208Scael.Fn Getfsstat
12238243Smckusickfails if one or more of the following are true:
12347208Scael.Bl -tag -width Er
12447208Scael.It EFAULT
12547208Scael.Fa Buf
12638243Smckusickpoints to an invalid address.
12747208Scael.It EIO
12850487ScaelAn
12950487Scael.Tn I/O
13050487Scaelerror occurred while reading from or writing to the filesystem.
13147208Scael.El
13247208Scael.Sh SEE ALSO
13347208Scael.Xr statfs 2 ,
13447208Scael.Xr fstab 5 ,
13547208Scael.Xr mount 8
13647208Scael.Sh HISTORY
13747208ScaelThe
13850487Scael.Nm getfsstat
13962906Sbosticfunction first appeared in 4.4BSD.
140