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.3 (Berkeley) 05/25/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 52The flags that may be returned include: 53.Bl -tag -width MNT_ASYNCHRONOUS 54.It Dv MNT_RDONLY 55The filesystem is mounted read-only; 56Even the super-user may not write on it. 57.It Dv MNT_NOEXEC 58Files may not be executed from the filesystem. 59.It Dv MNT_NOSUID 60Setuid and setgid bits on files are not honored when they are executed. 61.It Dv MNT_NODEV 62Special files in the filesystem may not be opened. 63.It Dv MNT_SYNCHRONOUS 64All I/O to the filesystem is done synchronously. 65.It Dv MNT_ASYNCHRONOUS 66No filesystem I/O is done synchronously. 67.It Dv MNT_LOCAL 68The filesystem resides locally. 69.It Dv MNT_QUOTA 70The filesystem has quotas enabled on it. 71.It Dv MNT_ROOTFS 72Identifies the root filesystem. 73.It Dv MNT_EXRDONLY 74The filesystem is exported read-only. 75.It Dv MNT_EXPORTED 76The filesystem is exported for both reading and writing. 77.It Dv MNT_DEFEXPORTED 78The filesystem is exported for both reading and writing to any Internet host. 79.It Dv MNT_EXPORTANON 80The filesystem maps all remote accesses to the anonymous user. 81.It Dv MNT_EXKERB 82The filesystem is exported with Kerberos uid mapping. 83.El 84.Pp 85Fields that are undefined for a particular filesystem are set to -1. 86The buffer is filled with an array of 87.Fa fsstat 88structures, one for each mounted filesystem 89up to the size specified by 90.Fa bufsize . 91.Pp 92If 93.Fa buf 94is given as NULL, 95.Fn getfsstat 96returns just the number of mounted filesystems. 97.Pp 98Normally 99.Fa flags 100should be specified as 101.Dv MNT_WAIT . 102If 103.Fa flags 104is set to 105.Dv MNT_NOWAIT , 106.Fn getfsstat 107will return the information it has available without requesting 108an update from each filesystem. 109Thus, some of the information will be out of date, but 110.Fn getfsstat 111will not block waiting for information from a filesystem that is 112unable to respond. 113.Sh RETURN VALUES 114Upon successful completion, the number of 115.Fa fsstat 116structures is returned. 117Otherwise, -1 is returned and the global variable 118.Va errno 119is set to indicate the error. 120.Sh ERRORS 121.Fn Getfsstat 122fails if one or more of the following are true: 123.Bl -tag -width Er 124.It EFAULT 125.Fa Buf 126points to an invalid address. 127.It EIO 128An 129.Tn I/O 130error occurred while reading from or writing to the filesystem. 131.El 132.Sh SEE ALSO 133.Xr statfs 2 , 134.Xr fstab 5 , 135.Xr mount 8 136.Sh HISTORY 137The 138.Nm getfsstat 139function first appeared in 4.4BSD. 140