1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)getfsstat.2 8.3 (Berkeley) 5/25/95 33.\" $FreeBSD: src/lib/libc/sys/getfsstat.2,v 1.7.2.4 2001/12/14 18:34:00 ru Exp $ 34.\" $DragonFly: src/lib/libc/sys/getfsstat.2,v 1.5 2008/06/01 20:46:45 dillon Exp $ 35.\" 36.Dd May 25, 1995 37.Dt GETFSSTAT 2 38.Os 39.Sh NAME 40.Nm getfsstat , 41.Nm getvfsstat 42.Nd get list of all mounted filesystems 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.In sys/param.h 47.In sys/ucred.h 48.In sys/mount.h 49.Ft int 50.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags" 51.Fn getvfsstat "struct statfs *buf" "struct statvfs *vbuf" "long vbufsize" "int flags" 52.Sh DESCRIPTION 53.Fn Getfsstat 54returns information about all mounted filesystems. 55.Fa Buf 56is a pointer to 57.Vt statfs 58structures defined as follows: 59.Bd -literal 60typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ 61 62/* 63 * file system statistics 64 */ 65 66#define MFSNAMELEN 16 /* length of fs type name, including null */ 67#define MNAMELEN 80 /* length of buffer for returned name */ 68 69struct statfs { 70 long f_spare2; /* placeholder */ 71 long f_bsize; /* fundamental file system block size */ 72 long f_iosize; /* optimal transfer block size */ 73 long f_blocks; /* total data blocks in file system */ 74 long f_bfree; /* free blocks in fs */ 75 long f_bavail; /* free blocks avail to non-superuser */ 76 long f_files; /* total file nodes in file system */ 77 long f_ffree; /* free file nodes in fs */ 78 fsid_t f_fsid; /* file system id */ 79 uid_t f_owner; /* user that mounted the filesystem */ 80 int f_type; /* type of filesystem (see below) */ 81 int f_flags; /* copy of mount flags */ 82 long f_syncwrites; /* count of sync writes since mount */ 83 long f_asyncwrites; /* count of async writes since mount */ 84 char f_fstypename[MFSNAMELEN];/* fs type name */ 85 char f_mntonname[MNAMELEN];/* directory on which mounted */ 86 long f_syncreads; /* count of sync reads since mount */ 87 long f_asyncreads; /* count of async reads since mount */ 88 short f_spares1; /* unused spare */ 89 char f_mntfromname[MNAMELEN];/* mounted filesystem */ 90 short f_spares2; /* unused spare */ 91 long f_spare[2]; /* unused spare */ 92}; 93.Ed 94.Pp 95The flags that may be returned include: 96.Bl -tag -width ".Dv MNT_SYNCHRONOUS" 97.It Dv MNT_RDONLY 98The filesystem is mounted read-only; 99Even the super-user may not write on it. 100.It Dv MNT_NOEXEC 101Files may not be executed from the filesystem. 102.It Dv MNT_NOSUID 103Setuid and setgid bits on files are not honored when they are executed. 104.It Dv MNT_NODEV 105Special files in the filesystem may not be opened. 106.It Dv MNT_SYNCHRONOUS 107All I/O to the filesystem is done synchronously. 108.It Dv MNT_ASYNC 109No filesystem I/O is done synchronously. 110.It Dv MNT_LOCAL 111The filesystem resides locally. 112.It Dv MNT_QUOTA 113The filesystem has quotas enabled on it. 114.It Dv MNT_ROOTFS 115Identifies the root filesystem. 116.It Dv MNT_EXRDONLY 117The filesystem is exported read-only. 118.It Dv MNT_EXPORTED 119The filesystem is exported for both reading and writing. 120.It Dv MNT_DEFEXPORTED 121The filesystem is exported for both reading and writing to any Internet host. 122.It Dv MNT_EXPORTANON 123The filesystem maps all remote accesses to the anonymous user. 124.It Dv MNT_EXKERB 125The filesystem is exported with Kerberos uid mapping. 126.El 127.Pp 128Fields that are undefined for a particular filesystem are set to -1. 129The buffer is filled with an array of 130.Fa fsstat 131structures, one for each mounted filesystem 132up to the size specified by 133.Fa bufsize . 134.Pp 135If 136.Fa buf 137is given as NULL, 138.Fn getfsstat 139returns just the number of mounted filesystems. 140.Pp 141Normally 142.Fa flags 143should be specified as 144.Dv MNT_WAIT . 145If 146.Fa flags 147is set to 148.Dv MNT_NOWAIT , 149.Fn getfsstat 150will return the information it has available without requesting 151an update from each filesystem. 152Thus, some of the information will be out of date, but 153.Fn getfsstat 154will not block waiting for information from a filesystem that is 155unable to respond. 156.Fn Getvfsstat 157returns extended information about all mounted filesystems. 158Note that 159.Fa vbufsize 160represents the size of 161.Fa vbuf , 162and 163.Fa buf 164is expected to be of contemporary size for its own structures. 165.Sh RETURN VALUES 166Upon successful completion, the number of 167.Fa fsstat 168structures is returned. 169Otherwise, -1 is returned and the global variable 170.Va errno 171is set to indicate the error. 172.Sh ERRORS 173.Fn Getfsstat 174and 175.Fn getvfsstat 176fail if one or more of the following are true: 177.Bl -tag -width Er 178.It Bq Er EFAULT 179.Fa Buf 180points to an invalid address. 181.It Bq Er EIO 182An 183.Tn I/O 184error occurred while reading from or writing to the filesystem. 185.El 186.Sh SEE ALSO 187.Xr statfs 2 , 188.Xr fstab 5 , 189.Xr mount 8 190.Sh HISTORY 191The 192.Fn getfsstat 193function first appeared in 194.Bx 4.4 . 195