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. --- 16 unchanged lines hidden (view full) --- 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: head/lib/libc/sys/getfsstat.2 107788 2002-12-12 17:26:04Z ru $ |
34.\" 35.Dd May 25, 1995 36.Dt GETFSSTAT 2 37.Os 38.Sh NAME 39.Nm getfsstat |
40.Nd get list of all mounted file systems |
41.Sh LIBRARY 42.Lb libc 43.Sh SYNOPSIS 44.In sys/param.h 45.In sys/ucred.h 46.In sys/mount.h 47.Ft int 48.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags" 49.Sh DESCRIPTION 50.Fn Getfsstat |
51returns information about all mounted file systems. |
52.Fa Buf 53is a pointer to 54.Xr statfs 55structures defined as follows: 56.Bd -literal 57typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ 58 59/* --- 8 unchanged lines hidden (view full) --- 68 long f_bsize; /* fundamental file system block size */ 69 long f_iosize; /* optimal transfer block size */ 70 long f_blocks; /* total data blocks in file system */ 71 long f_bfree; /* free blocks in fs */ 72 long f_bavail; /* free blocks avail to non-superuser */ 73 long f_files; /* total file nodes in file system */ 74 long f_ffree; /* free file nodes in fs */ 75 fsid_t f_fsid; /* file system id */ |
76 uid_t f_owner; /* user that mounted the file system */ 77 int f_type; /* type of file system (see below) */ |
78 int f_flags; /* copy of mount flags */ 79 long f_spare[2]; /* spare for later */ 80 char f_fstypename[MFSNAMELEN];/* fs type name */ 81 char f_mntonname[MNAMELEN];/* directory on which mounted */ |
82 char f_mntfromname[MNAMELEN];/* mounted file system */ |
83}; 84.Ed 85.Pp 86The flags that may be returned include: 87.Bl -tag -width MNT_ASYNCHRONOUS 88.It Dv MNT_RDONLY |
89The file system is mounted read-only; |
90Even the super-user may not write on it. 91.It Dv MNT_NOEXEC |
92Files may not be executed from the file system. |
93.It Dv MNT_NOSUID 94Setuid and setgid bits on files are not honored when they are executed. 95.It Dv MNT_NODEV |
96Special files in the file system may not be opened. |
97.It Dv MNT_SYNCHRONOUS |
98All I/O to the file system is done synchronously. |
99.It Dv MNT_ASYNCHRONOUS |
100No file system I/O is done synchronously. |
101.It Dv MNT_LOCAL |
102The file system resides locally. |
103.It Dv MNT_QUOTA |
104The file system has quotas enabled on it. |
105.It Dv MNT_ROOTFS |
106Identifies the root file system. |
107.It Dv MNT_EXRDONLY |
108The file system is exported read-only. |
109.It Dv MNT_EXPORTED |
110The file system is exported for both reading and writing. |
111.It Dv MNT_DEFEXPORTED |
112The file system is exported for both reading and writing to any Internet host. |
113.It Dv MNT_EXPORTANON |
114The file system maps all remote accesses to the anonymous user. |
115.It Dv MNT_EXKERB |
116The file system is exported with Kerberos uid mapping. |
117.El 118.Pp |
119Fields that are undefined for a particular file system are set to -1. |
120The buffer is filled with an array of 121.Fa fsstat |
122structures, one for each mounted file system |
123up to the size specified by 124.Fa bufsize . 125.Pp 126If 127.Fa buf 128is given as NULL, 129.Fn getfsstat |
130returns just the number of mounted file systems. |
131.Pp 132Normally 133.Fa flags 134should be specified as 135.Dv MNT_WAIT . 136If 137.Fa flags 138is set to 139.Dv MNT_NOWAIT , 140.Fn getfsstat 141will return the information it has available without requesting |
142an update from each file system. |
143Thus, some of the information will be out of date, but 144.Fn getfsstat |
145will not block waiting for information from a file system that is |
146unable to respond. 147.Sh RETURN VALUES 148Upon successful completion, the number of 149.Fa fsstat 150structures is returned. 151Otherwise, -1 is returned and the global variable 152.Va errno 153is set to indicate the error. 154.Sh ERRORS 155.Fn Getfsstat 156fails if one or more of the following are true: 157.Bl -tag -width Er 158.It Bq Er EFAULT 159.Fa Buf 160points to an invalid address. 161.It Bq Er EIO 162An 163.Tn I/O |
164error occurred while reading from or writing to the file system. |
165.El 166.Sh SEE ALSO 167.Xr statfs 2 , 168.Xr fstab 5 , 169.Xr mount 8 170.Sh HISTORY 171The 172.Fn getfsstat 173function first appeared in 174.Bx 4.4 . |