xref: /csrg-svn/lib/libc/sys/statfs.2 (revision 69677)
162893Sbostic.\" Copyright (c) 1989, 1991, 1993
262893Sbostic.\"	The Regents of the University of California.  All rights reserved.
338241Smckusick.\"
450487Scael.\" %sccs.include.redist.roff%
538241Smckusick.\"
6*69677Smckusick.\"	@(#)statfs.2	8.5 (Berkeley) 05/24/95
738241Smckusick.\"
847208Scael.Dd
947208Scael.Dt STATFS 2
1050487Scael.Os
1147208Scael.Sh NAME
1247208Scael.Nm statfs
1347208Scael.Nd get file system statistics
1447208Scael.Sh SYNOPSIS
1551744Smckusick.Fd #include <sys/param.h>
1647208Scael.Fd #include <sys/mount.h>
1747208Scael.Ft int
1847208Scael.Fn statfs "const char *path" "struct statfs *buf"
1947208Scael.Ft int
2047208Scael.Fn fstatfs "int fd" "struct statfs *buf"
2147208Scael.Sh DESCRIPTION
2247208Scael.Fn Statfs
2338241Smckusickreturns information about a mounted file system.
2447208Scael.Fa Path
2538241Smckusickis the path name of any file within the mounted filesystem.
2647208Scael.Fa Buf
2738241Smckusickis a pointer to a
2847208Scael.Fn statfs
2938241Smckusickstructure defined as follows:
3047208Scael.Bd -literal
3138241Smckusicktypedef quad fsid_t;
3247208Scael
3368724Smckusick#define MFSNAMELEN	16	/* length of fs type name, including null */
3468724Smckusick#define	MNAMELEN	90	/* length of buffer for returned name */
3547208Scael
3638241Smckusickstruct statfs {
3768724Smckusick	short	f_type;			/* filesystem type number */
3868724Smckusick	short	f_flags;		/* copy of mount flags */
3968724Smckusick	long	f_bsize;		/* fundamental file system block size */
4068724Smckusick	long	f_iosize;		/* optimal transfer block size */
4168724Smckusick	long	f_blocks;		/* total data blocks in file system */
4268724Smckusick	long	f_bfree;		/* free blocks in fs */
4368724Smckusick	long	f_bavail;		/* free blocks avail to non-superuser */
4468724Smckusick	long	f_files;		/* total file nodes in file system */
4568724Smckusick	long	f_ffree;		/* free file nodes in fs */
4668724Smckusick	fsid_t	f_fsid;			/* file system id */
4768724Smckusick	uid_t	f_owner;		/* user that mounted the filesystem */
4868724Smckusick	long	f_spare[4];		/* spare for later */
4968724Smckusick	char	f_fstypename[MFSNAMELEN]; /* fs type name */
5068724Smckusick	char	f_mntonname[MNAMELEN];	/* directory on which mounted */
5168724Smckusick	char	f_mntfromname[MNAMELEN];/* mounted filesystem */
5238241Smckusick};
5347208Scael.Ed
54*69677SmckusickThe flags that may be returned include:
55*69677Smckusick.Bl -tag -width MNT_ASYNCHRONOUS
56*69677Smckusick.It Dv MNT_RDONLY
57*69677SmckusickThe filesystem is mounted read-only;
58*69677SmckusickEven the super-user may not write on it.
59*69677Smckusick.It Dv MNT_NOEXEC
60*69677SmckusickFiles may not be executed from the filesystem.
61*69677Smckusick.It Dv MNT_NOSUID
62*69677SmckusickSetuid and setgid bits on files are not honored when they are executed.
63*69677Smckusick.It Dv MNT_NODEV
64*69677SmckusickSpecial files in the filesystem may not be opened.
65*69677Smckusick.It Dv MNT_SYNCHRONOUS
66*69677SmckusickAll I/O to the filesystem is done synchronously.
67*69677Smckusick.It Dv MNT_ASYNCHRONOUS
68*69677SmckusickNo filesystem I/O is done synchronously.
69*69677Smckusick.It Dv MNT_LOCAL
70*69677SmckusickThe filesystem resides locally.
71*69677Smckusick.It Dv MNT_QUOTA
72*69677SmckusickThe filesystem has quotas enabled on it.
73*69677Smckusick.It Dv MNT_ROOTFS
74*69677SmckusickIdentifies the root filesystem.
75*69677Smckusick.It Dv MNT_EXRDONLY
76*69677SmckusickThe filesystem is exported read-only.
77*69677Smckusick.It Dv MNT_EXPORTED
78*69677SmckusickThe filesystem is exported for both reading and writing.
79*69677Smckusick.It Dv MNT_DEFEXPORTED
80*69677SmckusickThe filesystem is exported for both reading and writing to any Internet host.
81*69677Smckusick.It Dv MNT_EXPORTANON
82*69677SmckusickThe filesystem maps all remote accesses to the anonymous user.
83*69677Smckusick.It Dv MNT_EXKERB
84*69677SmckusickThe filesystem is exported with Kerberos uid mapping.
85*69677Smckusick.El
8647208Scael.Pp
8747208ScaelFields that are undefined for a particular file system are set to -1.
8847208Scael.Fn Fstatfs
8938241Smckusickreturns the same information about an open file referenced by descriptor
9047208Scael.Fa fd .
9147208Scael.Sh RETURN VALUES
9238241SmckusickUpon successful completion, a value of 0 is returned.
9347208ScaelOtherwise, -1 is returned and the global variable
9447208Scael.Va errno
9538241Smckusickis set to indicate the error.
9647208Scael.Sh ERRORS
9747208Scael.Fn Statfs
9838241Smckusickfails if one or more of the following are true:
9947208Scael.Bl -tag -width ENAMETOOLONGA
10047208Scael.It Bq Er ENOTDIR
10138241SmckusickA component of the path prefix of
10247208Scael.Fa Path
10338241Smckusickis not a directory.
10447208Scael.It Bq Er EINVAL
10547208Scael.Fa path
10638241Smckusickcontains a character with the high-order bit set.
10747208Scael.It Bq Er ENAMETOOLONG
10838241SmckusickThe length of a component of
10947208Scael.Fa path
11038241Smckusickexceeds 255 characters,
11138241Smckusickor the length of
11247208Scael.Fa path
11338241Smckusickexceeds 1023 characters.
11447208Scael.It Bq Er ENOENT
11538241SmckusickThe file referred to by
11647208Scael.Fa path
11738241Smckusickdoes not exist.
11847208Scael.It Bq Er EACCES
11938241SmckusickSearch permission is denied for a component of the path prefix of
12047208Scael.Fa path .
12147208Scael.It Bq Er ELOOP
12238241SmckusickToo many symbolic links were encountered in translating
12347208Scael.Fa path .
12447208Scael.It Bq Er EFAULT
12547208Scael.Fa Buf
12638241Smckusickor
12747208Scael.Fa path
12838241Smckusickpoints to an invalid address.
12947208Scael.It Bq Er EIO
13050487ScaelAn
13150487Scael.Tn I/O
13250487Scaelerror occurred while reading from or writing to the file system.
13347208Scael.El
13447208Scael.Pp
13547208Scael.Fn Fstatfs
13665100Smckusickfails if one or more of the following are true:
13747208Scael.Bl -tag -width ENAMETOOLONGA
13847208Scael.It Bq Er EBADF
13947208Scael.Fa Fd
14038241Smckusickis not a valid open file descriptor.
14147208Scael.It Bq Er EFAULT
14247208Scael.Fa Buf
14338241Smckusickpoints to an invalid address.
14447208Scael.It Bq Er EIO
14550487ScaelAn
14650487Scael.Tn I/O
14750487Scaelerror occurred while reading from or writing to the file system.
14847208Scael.El
14947208Scael.Sh HISTORY
15047208ScaelThe
15150487Scael.Nm statfs
15262892Sbosticfunction first appeared in 4.4BSD.
153