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.1 (Berkeley) 06/09/93 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 MNAMELEN 32 /* length of buffer for returned name */ 31 32struct statfs { 33 short f_type; /* type of filesystem (see below) */ 34 short f_flags; /* copy of mount flags */ 35 long f_bsize; /* fundamental filesystem block size */ 36 long f_iosize; /* optimal transfer block size */ 37 long f_blocks; /* total data blocks in filesystem */ 38 long f_bfree; /* free blocks in fs */ 39 long f_bavail; /* free blocks avail to non-superuser */ 40 long f_files; /* total file nodes in filesystem */ 41 long f_ffree; /* free file nodes in fs */ 42 fsid_t f_fsid; /* filesystem id */ 43 long f_spare[6]; /* spare for later */ 44 char f_mntonname[MNAMELEN]; /* directory on which mounted */ 45 char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 46}; 47/* 48 * File system types. 49 */ 50#define MOUNT_UFS 1 51#define MOUNT_NFS 2 52#define MOUNT_PC 3 53.Ed 54.Pp 55Fields that are undefined for a particular filesystem are set to -1. 56The buffer is filled with an array of 57.Fa fsstat 58structures, one for each mounted filesystem 59up to the size specified by 60.Fa bufsize . 61.Pp 62If 63.Fa buf 64is given as NULL, 65.Fn getfsstat 66returns just the number of mounted filesystems. 67.Pp 68Normally 69.Fa flags 70should be specified as 71.Dv MNT_WAIT . 72If 73.Fa flags 74is set to 75.Dv MNT_NOWAIT , 76.Fn getfsstat 77will return the information it has available without requesting 78an update from each filesystem. 79Thus, some of the information will be out of date, but 80.Fn getfsstat 81will not block waiting for information from a filesystem that is 82unable to respond. 83.Sh RETURN VALUES 84Upon successful completion, the number of 85.Fa fsstat 86structures is returned. 87Otherwise, -1 is returned and the global variable 88.Va errno 89is set to indicate the error. 90.Sh ERRORS 91.Fn Getfsstat 92fails if one or more of the following are true: 93.Bl -tag -width Er 94.It EFAULT 95.Fa Buf 96points to an invalid address. 97.It EIO 98An 99.Tn I/O 100error occurred while reading from or writing to the filesystem. 101.El 102.Sh SEE ALSO 103.Xr statfs 2 , 104.Xr fstab 5 , 105.Xr mount 8 106.Sh HISTORY 107The 108.Nm getfsstat 109function first appeared in 4.4BSD. 110