Commit | Line | Data |
---|---|---|
931b8415 | 1 | .\" Copyright (c) 1989, 1991 The Regents of the University of California. |
7478d653 KM |
2 | .\" All rights reserved. |
3 | .\" | |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
7478d653 | 5 | .\" |
931b8415 | 6 | .\" @(#)getfsstat.2 6.5 (Berkeley) %G% |
7478d653 | 7 | .\" |
931b8415 CL |
8 | .Dd |
9 | .Dt GETFSSTAT 2 | |
10 | .Os BSD 4.4 | |
11 | .Sh NAME | |
12 | .Nm getfsstat | |
13 | .Nd get list of all mounted filesystems | |
14 | .Sh SYNOPSIS | |
15 | .Fd #include <sys/types.h> | |
16 | .Fd #include <sys/mount.h> | |
17 | .Ft int | |
18 | .Fn getfsstat "struct statfs *buf" "long bufsize" "int flags" | |
19 | .Sh DESCRIPTION | |
20 | .Fn Getfsstat | |
7478d653 | 21 | returns information about all mounted filesystems. |
931b8415 CL |
22 | .Fa Buf |
23 | is a pointer to | |
24 | .Xr statfs | |
7478d653 | 25 | structures defined as follows: |
931b8415 | 26 | .Bd -literal |
7478d653 | 27 | typedef quad fsid_t; |
931b8415 | 28 | |
7478d653 | 29 | #define MNAMELEN 32 /* length of buffer for returned name */ |
931b8415 | 30 | |
7478d653 | 31 | struct statfs { |
931b8415 CL |
32 | short f_type; /* type of filesystem (see below) */ |
33 | short f_flags; /* copy of mount flags */ | |
34 | long f_fsize; /* fundamental filesystem block size */ | |
35 | long f_bsize; /* optimal transfer block size */ | |
36 | long f_blocks; /* total data blocks in filesystem */ | |
37 | long f_bfree; /* free blocks in fs */ | |
38 | long f_bavail; /* free blocks avail to non-superuser */ | |
39 | long f_files; /* total file nodes in filesystem */ | |
40 | long f_ffree; /* free file nodes in fs */ | |
41 | fsid_t f_fsid; /* filesystem id */ | |
42 | long f_spare[6]; /* spare for later */ | |
43 | char f_mntonname[MNAMELEN]; /* directory on which mounted */ | |
44 | char f_mntfromname[MNAMELEN]; /* mounted filesystem */ | |
7478d653 KM |
45 | }; |
46 | /* | |
47 | * File system types. | |
48 | */ | |
49 | #define MOUNT_UFS 1 | |
50 | #define MOUNT_NFS 2 | |
4debe936 | 51 | #define MOUNT_PC 3 |
931b8415 CL |
52 | .Ed |
53 | .Pp | |
54 | Fields that are undefined for a particular filesystem are set to -1. | |
7478d653 | 55 | The buffer is filled with an array of |
931b8415 | 56 | .Fa fsstat |
7478d653 KM |
57 | structures, one for each mounted filesystem |
58 | up to the size specified by | |
931b8415 CL |
59 | .Fa bufsize . |
60 | .Pp | |
7478d653 | 61 | If |
931b8415 CL |
62 | .Fa buf |
63 | is given as NULL, | |
64 | .Fn getfsstat | |
7478d653 | 65 | returns just the number of mounted filesystems. |
931b8415 | 66 | .Pp |
4debe936 | 67 | Normally |
931b8415 CL |
68 | .Fa flags |
69 | should be specified as | |
70 | .Dv MNT_WAIT . | |
4debe936 | 71 | If |
931b8415 CL |
72 | .Fa flags |
73 | is set to | |
74 | .Dv MNT_NOWAIT , | |
75 | .Fn getfsstat | |
4debe936 KM |
76 | will return the information it has available without requesting |
77 | an update from each filesystem. | |
78 | Thus, some of the information will be out of date, but | |
931b8415 | 79 | .Fn getfsstat |
4debe936 KM |
80 | will not block waiting for information from a filesystem that is |
81 | unable to respond. | |
931b8415 | 82 | .Sh RETURN VALUES |
7478d653 | 83 | Upon successful completion, the number of |
931b8415 | 84 | .Fa fsstat |
7478d653 | 85 | structures is returned. |
931b8415 CL |
86 | Otherwise, -1 is returned and the global variable |
87 | .Va errno | |
7478d653 | 88 | is set to indicate the error. |
931b8415 CL |
89 | .Sh ERRORS |
90 | .Fn Getfsstat | |
7478d653 | 91 | fails if one or more of the following are true: |
931b8415 CL |
92 | .Bl -tag -width Er |
93 | .It EFAULT | |
94 | .Fa Buf | |
7478d653 | 95 | points to an invalid address. |
931b8415 | 96 | .It EIO |
4debe936 | 97 | An I/O error occurred while reading from or writing to the filesystem. |
931b8415 CL |
98 | .El |
99 | .Sh SEE ALSO | |
100 | .Xr statfs 2 , | |
101 | .Xr fstab 5 , | |
102 | .Xr mount 8 | |
103 | .Sh HISTORY | |
104 | The | |
105 | .Nm | |
106 | function call is currently under development. |