Commit | Line | Data |
---|---|---|
931b8415 | 1 | .\" Copyright (c) 1989, 1991 The Regents of the University of California. |
f70c4002 KM |
2 | .\" All rights reserved. |
3 | .\" | |
faf7e3e0 | 4 | .\" %sccs.include.redist.roff% |
f70c4002 | 5 | .\" |
04ce9f2a | 6 | .\" @(#)statfs.2 6.9 (Berkeley) %G% |
f70c4002 | 7 | .\" |
931b8415 CL |
8 | .Dd |
9 | .Dt STATFS 2 | |
faf7e3e0 | 10 | .Os |
931b8415 CL |
11 | .Sh NAME |
12 | .Nm statfs | |
13 | .Nd get file system statistics | |
14 | .Sh SYNOPSIS | |
d8d36f2a | 15 | .Fd #include <sys/param.h> |
931b8415 CL |
16 | .Fd #include <sys/mount.h> |
17 | .Ft int | |
18 | .Fn statfs "const char *path" "struct statfs *buf" | |
19 | .Ft int | |
20 | .Fn fstatfs "int fd" "struct statfs *buf" | |
21 | .Sh DESCRIPTION | |
22 | .Fn Statfs | |
f70c4002 | 23 | returns information about a mounted file system. |
931b8415 | 24 | .Fa Path |
f70c4002 | 25 | is the path name of any file within the mounted filesystem. |
931b8415 | 26 | .Fa Buf |
f70c4002 | 27 | is a pointer to a |
931b8415 | 28 | .Fn statfs |
f70c4002 | 29 | structure defined as follows: |
931b8415 | 30 | .Bd -literal |
f70c4002 | 31 | typedef quad fsid_t; |
931b8415 | 32 | |
f70c4002 | 33 | #define MNAMELEN 32 /* length of buffer for returned name */ |
931b8415 | 34 | |
f70c4002 | 35 | struct statfs { |
931b8415 CL |
36 | short f_type; /* type of filesystem (see below) */ |
37 | short f_flags; /* copy of mount flags */ | |
e5490a3f KM |
38 | long f_bsize; /* fundamental file system block size */ |
39 | long f_iosize; /* optimal transfer block size */ | |
931b8415 CL |
40 | long f_blocks; /* total data blocks in file system */ |
41 | long f_bfree; /* free blocks in fs */ | |
42 | long f_bavail; /* free blocks avail to non-superuser */ | |
43 | long f_files; /* total file nodes in file system */ | |
44 | long f_ffree; /* free file nodes in fs */ | |
45 | fsid_t f_fsid; /* file system id */ | |
46 | long f_spare[6]; /* spare for later */ | |
47 | char f_mntonname[MNAMELEN]; /* mount point */ | |
48 | char f_mntfromname[MNAMELEN]; /* mounted filesystem */ | |
f70c4002 KM |
49 | }; |
50 | /* | |
931b8415 CL |
51 | * File system types. |
52 | */ | |
f70c4002 KM |
53 | #define MOUNT_UFS 1 |
54 | #define MOUNT_NFS 2 | |
5fc83e4f KM |
55 | #define MOUNT_MFS 3 |
56 | #define MOUNT_PC 4 | |
931b8415 CL |
57 | .Ed |
58 | .Pp | |
59 | Fields that are undefined for a particular file system are set to -1. | |
60 | .Fn Fstatfs | |
f70c4002 | 61 | returns the same information about an open file referenced by descriptor |
931b8415 CL |
62 | .Fa fd . |
63 | .Sh RETURN VALUES | |
f70c4002 | 64 | Upon successful completion, a value of 0 is returned. |
931b8415 CL |
65 | Otherwise, -1 is returned and the global variable |
66 | .Va errno | |
f70c4002 | 67 | is set to indicate the error. |
931b8415 CL |
68 | .Sh ERRORS |
69 | .Fn Statfs | |
f70c4002 | 70 | fails if one or more of the following are true: |
931b8415 CL |
71 | .Bl -tag -width ENAMETOOLONGA |
72 | .It Bq Er ENOTDIR | |
f70c4002 | 73 | A component of the path prefix of |
931b8415 | 74 | .Fa Path |
f70c4002 | 75 | is not a directory. |
931b8415 CL |
76 | .It Bq Er EINVAL |
77 | .Fa path | |
f70c4002 | 78 | contains a character with the high-order bit set. |
931b8415 | 79 | .It Bq Er ENAMETOOLONG |
f70c4002 | 80 | The length of a component of |
931b8415 | 81 | .Fa path |
f70c4002 KM |
82 | exceeds 255 characters, |
83 | or the length of | |
931b8415 | 84 | .Fa path |
f70c4002 | 85 | exceeds 1023 characters. |
931b8415 | 86 | .It Bq Er ENOENT |
f70c4002 | 87 | The file referred to by |
931b8415 | 88 | .Fa path |
f70c4002 | 89 | does not exist. |
931b8415 | 90 | .It Bq Er EACCES |
f70c4002 | 91 | Search permission is denied for a component of the path prefix of |
931b8415 CL |
92 | .Fa path . |
93 | .It Bq Er ELOOP | |
f70c4002 | 94 | Too many symbolic links were encountered in translating |
931b8415 CL |
95 | .Fa path . |
96 | .It Bq Er EFAULT | |
97 | .Fa Buf | |
f70c4002 | 98 | or |
931b8415 | 99 | .Fa path |
f70c4002 | 100 | points to an invalid address. |
931b8415 | 101 | .It Bq Er EIO |
faf7e3e0 CL |
102 | An |
103 | .Tn I/O | |
104 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
105 | .El |
106 | .Pp | |
107 | .Fn Fstatfs | |
f70c4002 | 108 | fails if one or both of the following are true: |
931b8415 CL |
109 | .Bl -tag -width ENAMETOOLONGA |
110 | .It Bq Er EBADF | |
111 | .Fa Fd | |
f70c4002 | 112 | is not a valid open file descriptor. |
931b8415 CL |
113 | .It Bq Er EFAULT |
114 | .Fa Buf | |
f70c4002 | 115 | points to an invalid address. |
931b8415 | 116 | .It Bq Er EIO |
faf7e3e0 CL |
117 | An |
118 | .Tn I/O | |
119 | error occurred while reading from or writing to the file system. | |
931b8415 CL |
120 | .El |
121 | .Sh HISTORY | |
122 | The | |
faf7e3e0 | 123 | .Nm statfs |
04ce9f2a | 124 | function first appeared in 4.4BSD. |