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*68723Smckusick.\" @(#)getfsstat.2 8.2 (Berkeley) 04/03/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 30*68723Smckusick#define MFSNAMELEN 16 /* length of fs type name, including null */ 31*68723Smckusick#define MNAMELEN 90 /* length of buffer for returned name */ 3247208Scael 3338243Smckusickstruct statfs { 34*68723Smckusick short f_type; /* filesystem type number */ 35*68723Smckusick short f_flags; /* copy of mount flags */ 36*68723Smckusick long f_bsize; /* fundamental file system block size */ 37*68723Smckusick long f_iosize; /* optimal transfer block size */ 38*68723Smckusick long f_blocks; /* total data blocks in file system */ 39*68723Smckusick long f_bfree; /* free blocks in fs */ 40*68723Smckusick long f_bavail; /* free blocks avail to non-superuser */ 41*68723Smckusick long f_files; /* total file nodes in file system */ 42*68723Smckusick long f_ffree; /* free file nodes in fs */ 43*68723Smckusick fsid_t f_fsid; /* file system id */ 44*68723Smckusick uid_t f_owner; /* user that mounted the filesystem */ 45*68723Smckusick long f_spare[4]; /* spare for later */ 46*68723Smckusick char f_fstypename[MFSNAMELEN]; /* fs type name */ 47*68723Smckusick char f_mntonname[MNAMELEN]; /* directory on which mounted */ 48*68723Smckusick char f_mntfromname[MNAMELEN];/* mounted filesystem */ 4938243Smckusick}; 5047208Scael.Ed 5147208Scael.Pp 5247208ScaelFields that are undefined for a particular filesystem are set to -1. 5338243SmckusickThe buffer is filled with an array of 5447208Scael.Fa fsstat 5538243Smckusickstructures, one for each mounted filesystem 5638243Smckusickup to the size specified by 5747208Scael.Fa bufsize . 5847208Scael.Pp 5938243SmckusickIf 6047208Scael.Fa buf 6147208Scaelis given as NULL, 6247208Scael.Fn getfsstat 6338243Smckusickreturns just the number of mounted filesystems. 6447208Scael.Pp 6540334SmckusickNormally 6647208Scael.Fa flags 6747208Scaelshould be specified as 6847208Scael.Dv MNT_WAIT . 6940334SmckusickIf 7047208Scael.Fa flags 7147208Scaelis set to 7247208Scael.Dv MNT_NOWAIT , 7347208Scael.Fn getfsstat 7440334Smckusickwill return the information it has available without requesting 7540334Smckusickan update from each filesystem. 7640334SmckusickThus, some of the information will be out of date, but 7747208Scael.Fn getfsstat 7840334Smckusickwill not block waiting for information from a filesystem that is 7940334Smckusickunable to respond. 8047208Scael.Sh RETURN VALUES 8138243SmckusickUpon successful completion, the number of 8247208Scael.Fa fsstat 8338243Smckusickstructures is returned. 8447208ScaelOtherwise, -1 is returned and the global variable 8547208Scael.Va errno 8638243Smckusickis set to indicate the error. 8747208Scael.Sh ERRORS 8847208Scael.Fn Getfsstat 8938243Smckusickfails if one or more of the following are true: 9047208Scael.Bl -tag -width Er 9147208Scael.It EFAULT 9247208Scael.Fa Buf 9338243Smckusickpoints to an invalid address. 9447208Scael.It EIO 9550487ScaelAn 9650487Scael.Tn I/O 9750487Scaelerror occurred while reading from or writing to the filesystem. 9847208Scael.El 9947208Scael.Sh SEE ALSO 10047208Scael.Xr statfs 2 , 10147208Scael.Xr fstab 5 , 10247208Scael.Xr mount 8 10347208Scael.Sh HISTORY 10447208ScaelThe 10550487Scael.Nm getfsstat 10662906Sbosticfunction first appeared in 4.4BSD. 107