make it possible to compile new versions of db that load against
[unix-history] / usr / src / lib / libc / sys / statfs.2
CommitLineData
fe657527
KB
1.\" Copyright (c) 1989, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
f70c4002 3.\"
faf7e3e0 4.\" %sccs.include.redist.roff%
f70c4002 5.\"
653ba8b6 6.\" @(#)statfs.2 8.2 (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 23returns information about a mounted file system.
931b8415 24.Fa Path
f70c4002 25is the path name of any file within the mounted filesystem.
931b8415 26.Fa Buf
f70c4002 27is a pointer to a
931b8415 28.Fn statfs
f70c4002 29structure defined as follows:
931b8415 30.Bd -literal
f70c4002 31typedef quad fsid_t;
931b8415 32
f70c4002 33#define MNAMELEN 32 /* length of buffer for returned name */
931b8415 34
f70c4002 35struct statfs {
931b8415
CL
36short f_type; /* type of filesystem (see below) */
37short f_flags; /* copy of mount flags */
e5490a3f
KM
38long f_bsize; /* fundamental file system block size */
39long f_iosize; /* optimal transfer block size */
931b8415
CL
40long f_blocks; /* total data blocks in file system */
41long f_bfree; /* free blocks in fs */
42long f_bavail; /* free blocks avail to non-superuser */
43long f_files; /* total file nodes in file system */
44long f_ffree; /* free file nodes in fs */
45fsid_t f_fsid; /* file system id */
46long f_spare[6]; /* spare for later */
47char f_mntonname[MNAMELEN]; /* mount point */
48char 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
59Fields that are undefined for a particular file system are set to -1.
60.Fn Fstatfs
f70c4002 61returns the same information about an open file referenced by descriptor
931b8415
CL
62.Fa fd .
63.Sh RETURN VALUES
f70c4002 64Upon successful completion, a value of 0 is returned.
931b8415
CL
65Otherwise, -1 is returned and the global variable
66.Va errno
f70c4002 67is set to indicate the error.
931b8415
CL
68.Sh ERRORS
69.Fn Statfs
f70c4002 70fails if one or more of the following are true:
931b8415
CL
71.Bl -tag -width ENAMETOOLONGA
72.It Bq Er ENOTDIR
f70c4002 73A component of the path prefix of
931b8415 74.Fa Path
f70c4002 75is not a directory.
931b8415
CL
76.It Bq Er EINVAL
77.Fa path
f70c4002 78contains a character with the high-order bit set.
931b8415 79.It Bq Er ENAMETOOLONG
f70c4002 80The length of a component of
931b8415 81.Fa path
f70c4002
KM
82exceeds 255 characters,
83or the length of
931b8415 84.Fa path
f70c4002 85exceeds 1023 characters.
931b8415 86.It Bq Er ENOENT
f70c4002 87The file referred to by
931b8415 88.Fa path
f70c4002 89does not exist.
931b8415 90.It Bq Er EACCES
f70c4002 91Search permission is denied for a component of the path prefix of
931b8415
CL
92.Fa path .
93.It Bq Er ELOOP
f70c4002 94Too many symbolic links were encountered in translating
931b8415
CL
95.Fa path .
96.It Bq Er EFAULT
97.Fa Buf
f70c4002 98or
931b8415 99.Fa path
f70c4002 100points to an invalid address.
931b8415 101.It Bq Er EIO
faf7e3e0
CL
102An
103.Tn I/O
104error occurred while reading from or writing to the file system.
931b8415
CL
105.El
106.Pp
107.Fn Fstatfs
653ba8b6 108fails if one or more of the following are true:
931b8415
CL
109.Bl -tag -width ENAMETOOLONGA
110.It Bq Er EBADF
111.Fa Fd
f70c4002 112is not a valid open file descriptor.
931b8415
CL
113.It Bq Er EFAULT
114.Fa Buf
f70c4002 115points to an invalid address.
931b8415 116.It Bq Er EIO
faf7e3e0
CL
117An
118.Tn I/O
119error occurred while reading from or writing to the file system.
931b8415
CL
120.El
121.Sh HISTORY
122The
faf7e3e0 123.Nm statfs
04ce9f2a 124function first appeared in 4.4BSD.