1.\" Copyright (c) 1989, 1991 The Regents of the University of California. 2.\" 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 6.6 (Berkeley) 7/23/91 33.\" 34.Dd July 23, 1991 35.Dt GETFSSTAT 2 36.Os 37.Sh NAME 38.Nm getfsstat 39.Nd get list of all mounted filesystems 40.Sh SYNOPSIS 41.Fd #include <sys/types.h> 42.Fd #include <sys/mount.h> 43.Ft int 44.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags" 45.Sh DESCRIPTION 46.Fn Getfsstat 47returns information about all mounted filesystems. 48.Fa Buf 49is a pointer to 50.Xr statfs 51structures defined as follows: 52.Bd -literal 53typedef quad fsid_t; 54 55#define MNAMELEN 32 /* length of buffer for returned name */ 56 57struct statfs { 58 short f_type; /* type of filesystem (see below) */ 59 short f_flags; /* copy of mount flags */ 60 long f_fsize; /* fundamental filesystem block size */ 61 long f_bsize; /* optimal transfer block size */ 62 long f_blocks; /* total data blocks in filesystem */ 63 long f_bfree; /* free blocks in fs */ 64 long f_bavail; /* free blocks avail to non-superuser */ 65 long f_files; /* total file nodes in filesystem */ 66 long f_ffree; /* free file nodes in fs */ 67 fsid_t f_fsid; /* filesystem id */ 68 long f_spare[6]; /* spare for later */ 69 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 70 char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 71}; 72/* 73 * File system types. 74 */ 75#define MOUNT_UFS 1 76#define MOUNT_NFS 2 77#define MOUNT_PC 3 78.Ed 79.Pp 80Fields that are undefined for a particular filesystem are set to -1. 81The buffer is filled with an array of 82.Fa fsstat 83structures, one for each mounted filesystem 84up to the size specified by 85.Fa bufsize . 86.Pp 87If 88.Fa buf 89is given as NULL, 90.Fn getfsstat 91returns just the number of mounted filesystems. 92.Pp 93Normally 94.Fa flags 95should be specified as 96.Dv MNT_WAIT . 97If 98.Fa flags 99is set to 100.Dv MNT_NOWAIT , 101.Fn getfsstat 102will return the information it has available without requesting 103an update from each filesystem. 104Thus, some of the information will be out of date, but 105.Fn getfsstat 106will not block waiting for information from a filesystem that is 107unable to respond. 108.Sh RETURN VALUES 109Upon successful completion, the number of 110.Fa fsstat 111structures is returned. 112Otherwise, -1 is returned and the global variable 113.Va errno 114is set to indicate the error. 115.Sh ERRORS 116.Fn Getfsstat 117fails if one or more of the following are true: 118.Bl -tag -width Er 119.It EFAULT 120.Fa Buf 121points to an invalid address. 122.It EIO 123An 124.Tn I/O 125error occurred while reading from or writing to the filesystem. 126.El 127.Sh SEE ALSO 128.Xr statfs 2 , 129.Xr fstab 5 , 130.Xr mount 8 131.Sh HISTORY 132The 133.Nm getfsstat 134function call is 135.Ud . 136