xref: /freebsd/lib/libsys/statfs.2 (revision 1a720cbe)
18269e767SBrooks Davis.\" Copyright (c) 1989, 1991, 1993
28269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
38269e767SBrooks Davis.\"
48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
68269e767SBrooks Davis.\" are met:
78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
88269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
98269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
108269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
118269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
128269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
138269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
148269e767SBrooks Davis.\"    without specific prior written permission.
158269e767SBrooks Davis.\"
168269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
178269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
208269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268269e767SBrooks Davis.\" SUCH DAMAGE.
278269e767SBrooks Davis.\"
288269e767SBrooks Davis.Dd March 29, 2023
298269e767SBrooks Davis.Dt STATFS 2
308269e767SBrooks Davis.Os
318269e767SBrooks Davis.Sh NAME
328269e767SBrooks Davis.Nm statfs
338269e767SBrooks Davis.Nd get file system statistics
348269e767SBrooks Davis.Sh LIBRARY
358269e767SBrooks Davis.Lb libc
368269e767SBrooks Davis.Sh SYNOPSIS
378269e767SBrooks Davis.In sys/param.h
388269e767SBrooks Davis.In sys/mount.h
398269e767SBrooks Davis.Ft int
408269e767SBrooks Davis.Fn statfs "const char *path" "struct statfs *buf"
418269e767SBrooks Davis.Ft int
428269e767SBrooks Davis.Fn fstatfs "int fd" "struct statfs *buf"
438269e767SBrooks Davis.Sh DESCRIPTION
448269e767SBrooks DavisThe
458269e767SBrooks Davis.Fn statfs
468269e767SBrooks Davissystem call
478269e767SBrooks Davisreturns information about a mounted file system.
488269e767SBrooks DavisThe
498269e767SBrooks Davis.Fa path
508269e767SBrooks Davisargument
518269e767SBrooks Davisis the path name of any file within the mounted file system.
528269e767SBrooks DavisThe
538269e767SBrooks Davis.Fa buf
548269e767SBrooks Davisargument
558269e767SBrooks Davisis a pointer to a
568269e767SBrooks Davis.Vt statfs
578269e767SBrooks Davisstructure defined as follows:
588269e767SBrooks Davis.Bd -literal
598269e767SBrooks Davistypedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
608269e767SBrooks Davis
618269e767SBrooks Davis/*
628269e767SBrooks Davis * filesystem statistics
638269e767SBrooks Davis */
648269e767SBrooks Davis
658269e767SBrooks Davis#define	MFSNAMELEN	16		/* length of type name including null */
668269e767SBrooks Davis#define	MNAMELEN	1024		/* size of on/from name bufs */
678269e767SBrooks Davis#define	STATFS_VERSION	0x20140518	/* current version number */
688269e767SBrooks Davis
698269e767SBrooks Davisstruct statfs {
708269e767SBrooks Davisuint32_t f_version;		/* structure version number */
718269e767SBrooks Davisuint32_t f_type;		/* type of filesystem */
728269e767SBrooks Davisuint64_t f_flags;		/* copy of mount exported flags */
738269e767SBrooks Davisuint64_t f_bsize;		/* filesystem fragment size */
748269e767SBrooks Davisuint64_t f_iosize;		/* optimal transfer block size */
758269e767SBrooks Davisuint64_t f_blocks;		/* total data blocks in filesystem */
768269e767SBrooks Davisuint64_t f_bfree;		/* free blocks in filesystem */
778269e767SBrooks Davisint64_t	 f_bavail;		/* free blocks avail to non-superuser */
788269e767SBrooks Davisuint64_t f_files;		/* total file nodes in filesystem */
798269e767SBrooks Davisint64_t	 f_ffree;		/* free nodes avail to non-superuser */
808269e767SBrooks Davisuint64_t f_syncwrites;		/* count of sync writes since mount */
818269e767SBrooks Davisuint64_t f_asyncwrites;		/* count of async writes since mount */
828269e767SBrooks Davisuint64_t f_syncreads;		/* count of sync reads since mount */
838269e767SBrooks Davisuint64_t f_asyncreads;		/* count of async reads since mount */
848269e767SBrooks Davisuint64_t f_spare[10];		/* unused spare */
858269e767SBrooks Davisuint32_t f_namemax;		/* maximum filename length */
868269e767SBrooks Davisuid_t	  f_owner;		/* user that mounted the filesystem */
878269e767SBrooks Davisfsid_t	  f_fsid;		/* filesystem id */
888269e767SBrooks Davischar	  f_charspare[80];	    /* spare string space */
898269e767SBrooks Davischar	  f_fstypename[MFSNAMELEN]; /* filesystem type name */
908269e767SBrooks Davischar	  f_mntfromname[MNAMELEN];  /* mounted filesystem */
918269e767SBrooks Davischar	  f_mntonname[MNAMELEN];    /* directory on which mounted */
928269e767SBrooks Davis};
938269e767SBrooks Davis.Ed
948269e767SBrooks Davis.Pp
958269e767SBrooks DavisThe flags that may be returned include:
968269e767SBrooks Davis.Bl -tag -width MNT_SYNCHRONOUS
978269e767SBrooks Davis.It Dv MNT_RDONLY
988269e767SBrooks DavisThe file system is mounted read-only;
998269e767SBrooks DavisEven the super-user may not write on it.
1008269e767SBrooks Davis.It Dv MNT_NOEXEC
1018269e767SBrooks DavisFiles may not be executed from the file system.
1028269e767SBrooks Davis.It Dv MNT_NOSUID
1038269e767SBrooks DavisSetuid and setgid bits on files are not honored when they are executed.
1048269e767SBrooks Davis.It Dv MNT_SYNCHRONOUS
1058269e767SBrooks DavisAll I/O to the file system is done synchronously.
1068269e767SBrooks Davis.It Dv MNT_ASYNC
1078269e767SBrooks DavisNo file system I/O is done synchronously.
1088269e767SBrooks Davis.It Dv MNT_SOFTDEP
1098269e767SBrooks DavisSoft updates being done (see
110*1a720cbeSAlexander Ziaee.Xr ffs 4 ) .
1118269e767SBrooks Davis.It Dv MNT_GJOURNAL
1128269e767SBrooks DavisJournaling with gjournal is enabled (see
1138269e767SBrooks Davis.Xr gjournal 8 ) .
1148269e767SBrooks Davis.It Dv MNT_SUIDDIR
1158269e767SBrooks DavisSpecial handling of SUID bit on directories.
1168269e767SBrooks Davis.It Dv MNT_UNION
1178269e767SBrooks DavisUnion with underlying file system.
1188269e767SBrooks Davis.It Dv MNT_NOSYMFOLLOW
1198269e767SBrooks DavisSymbolic links are not followed.
1208269e767SBrooks Davis.It Dv MNT_NOCLUSTERR
1218269e767SBrooks DavisRead clustering is disabled.
1228269e767SBrooks Davis.It Dv MNT_NOCLUSTERW
1238269e767SBrooks DavisWrite clustering is disabled.
1248269e767SBrooks Davis.\".It Dv MNT_JAILDEVFS
1258269e767SBrooks Davis.\"XXX
1268269e767SBrooks Davis.It Dv MNT_MULTILABEL
1278269e767SBrooks DavisMandatory Access Control (MAC) support for individual objects
1288269e767SBrooks Davis(see
1298269e767SBrooks Davis.Xr mac 4 ) .
1308269e767SBrooks Davis.It Dv MNT_ACLS
1318269e767SBrooks DavisAccess Control List (ACL) support enabled.
1328269e767SBrooks Davis.It Dv MNT_LOCAL
1338269e767SBrooks DavisThe file system resides locally.
1348269e767SBrooks Davis.It Dv MNT_QUOTA
1358269e767SBrooks DavisThe file system has quotas enabled on it.
1368269e767SBrooks Davis.It Dv MNT_ROOTFS
1378269e767SBrooks DavisIdentifies the root file system.
1388269e767SBrooks Davis.It Dv MNT_EXRDONLY
1398269e767SBrooks DavisThe file system is exported read-only.
1408269e767SBrooks Davis.It Dv MNT_NOATIME
1418269e767SBrooks DavisUpdating of file access times is disabled.
1428269e767SBrooks Davis.It Dv MNT_USER
1438269e767SBrooks DavisThe file system has been mounted by a user.
1448269e767SBrooks Davis.\".It Dv MNT_IGNORE
1458269e767SBrooks Davis.\"XXX
1468269e767SBrooks Davis.It Dv MNT_EXPORTED
1478269e767SBrooks DavisThe file system is exported for both reading and writing.
1488269e767SBrooks Davis.It Dv MNT_DEFEXPORTED
1498269e767SBrooks DavisThe file system is exported for both reading and writing to any Internet host.
1508269e767SBrooks Davis.It Dv MNT_EXPORTANON
1518269e767SBrooks DavisThe file system maps all remote accesses to the anonymous user.
1528269e767SBrooks Davis.It Dv MNT_EXKERB
1538269e767SBrooks DavisThe file system is exported with Kerberos uid mapping.
1548269e767SBrooks Davis.It Dv MNT_EXPUBLIC
1558269e767SBrooks DavisThe file system is exported publicly (WebNFS).
1568269e767SBrooks Davis.El
1578269e767SBrooks Davis.Pp
1588269e767SBrooks DavisFields that are undefined for a particular file system are set to -1.
1598269e767SBrooks DavisThe
1608269e767SBrooks Davis.Fn fstatfs
1618269e767SBrooks Davissystem call
1628269e767SBrooks Davisreturns the same information about an open file referenced by descriptor
1638269e767SBrooks Davis.Fa fd .
1648269e767SBrooks Davis.Sh RETURN VALUES
1658269e767SBrooks Davis.Rv -std
1668269e767SBrooks Davis.Sh ERRORS
1678269e767SBrooks DavisThe
1688269e767SBrooks Davis.Fn statfs
1698269e767SBrooks Davissystem call
1708269e767SBrooks Davisfails if one or more of the following are true:
1718269e767SBrooks Davis.Bl -tag -width Er
1728269e767SBrooks Davis.It Bq Er ENOTDIR
1738269e767SBrooks DavisA component of the path prefix of
1748269e767SBrooks Davis.Fa path
1758269e767SBrooks Davisis not a directory.
1768269e767SBrooks Davis.It Bq Er ENAMETOOLONG
1778269e767SBrooks DavisThe length of a component of
1788269e767SBrooks Davis.Fa path
1798269e767SBrooks Davisexceeds 255 characters,
1808269e767SBrooks Davisor the length of
1818269e767SBrooks Davis.Fa path
1828269e767SBrooks Davisexceeds 1023 characters.
1838269e767SBrooks Davis.It Bq Er ENOENT
1848269e767SBrooks DavisThe file referred to by
1858269e767SBrooks Davis.Fa path
1868269e767SBrooks Davisdoes not exist.
1878269e767SBrooks Davis.It Bq Er EACCES
1888269e767SBrooks DavisSearch permission is denied for a component of the path prefix of
1898269e767SBrooks Davis.Fa path .
1908269e767SBrooks Davis.It Bq Er ELOOP
1918269e767SBrooks DavisToo many symbolic links were encountered in translating
1928269e767SBrooks Davis.Fa path .
1938269e767SBrooks Davis.It Bq Er EFAULT
1948269e767SBrooks DavisThe
1958269e767SBrooks Davis.Fa buf
1968269e767SBrooks Davisor
1978269e767SBrooks Davis.Fa path
1988269e767SBrooks Davisargument
1998269e767SBrooks Davispoints to an invalid address.
2008269e767SBrooks Davis.It Bq Er EIO
2018269e767SBrooks DavisAn
2028269e767SBrooks Davis.Tn I/O
2038269e767SBrooks Daviserror occurred while reading from or writing to the file system.
2048269e767SBrooks Davis.It Bq Er EINTEGRITY
2058269e767SBrooks DavisCorrupted data was detected while reading from the file system.
2068269e767SBrooks Davis.El
2078269e767SBrooks Davis.Pp
2088269e767SBrooks DavisThe
2098269e767SBrooks Davis.Fn fstatfs
2108269e767SBrooks Davissystem call
2118269e767SBrooks Davisfails if one or more of the following are true:
2128269e767SBrooks Davis.Bl -tag -width Er
2138269e767SBrooks Davis.It Bq Er EBADF
2148269e767SBrooks DavisThe
2158269e767SBrooks Davis.Fa fd
2168269e767SBrooks Davisargument
2178269e767SBrooks Davisis not a valid open file descriptor.
2188269e767SBrooks Davis.It Bq Er EFAULT
2198269e767SBrooks DavisThe
2208269e767SBrooks Davis.Fa buf
2218269e767SBrooks Davisargument
2228269e767SBrooks Davispoints to an invalid address.
2238269e767SBrooks Davis.It Bq Er EIO
2248269e767SBrooks DavisAn
2258269e767SBrooks Davis.Tn I/O
2268269e767SBrooks Daviserror occurred while reading from or writing to the file system.
2278269e767SBrooks Davis.It Bq Er EINTEGRITY
2288269e767SBrooks DavisCorrupted data was detected while reading from the file system.
2298269e767SBrooks Davis.El
2308269e767SBrooks Davis.Sh NOTES
2318269e767SBrooks DavisThe fields in the
2328269e767SBrooks Davis.Vt statfs
2338269e767SBrooks Davisstructure have been defined to provide the parameters relevant for
2348269e767SBrooks Davistraditional
2358269e767SBrooks Davis.Tm UNIX
2368269e767SBrooks Davisfile systems.
2378269e767SBrooks DavisFor some other file systems, values that have similar, but not
2388269e767SBrooks Davisidentical, semantics to those described above may be returned.
2398269e767SBrooks DavisAn example is msdosfs, which in case of FAT12 or FAT16 file systems
2408269e767SBrooks Davisreports the number of available and of free root directory entries
2418269e767SBrooks Davisinstead of inodes
2428269e767SBrooks Davis.Po
2438269e767SBrooks Daviswhere 1 to 21 such directory entries are required to store
2448269e767SBrooks Daviseach file or directory name or disk label
2458269e767SBrooks Davis.Pc .
2468269e767SBrooks Davis.Sh SEE ALSO
2478269e767SBrooks Davis.Xr fhstatfs 2 ,
2488269e767SBrooks Davis.Xr getfsstat 2
2498269e767SBrooks Davis.Sh HISTORY
2508269e767SBrooks DavisThe
2518269e767SBrooks Davis.Fn statfs
2528269e767SBrooks Davissystem call first appeared in
2538269e767SBrooks Davis.Bx 4.4 .
254