1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)statfs.2 8.3 (Berkeley) 02/11/94 7.\" 8.Dd 9.Dt STATFS 2 10.Os 11.Sh NAME 12.Nm statfs 13.Nd get file system statistics 14.Sh SYNOPSIS 15.Fd #include <sys/param.h> 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 23returns information about a mounted file system. 24.Fa Path 25is the path name of any file within the mounted filesystem. 26.Fa Buf 27is a pointer to a 28.Fn statfs 29structure defined as follows: 30.Bd -literal 31typedef quad fsid_t; 32 33#define MNAMELEN 90 /* length of buffer for returned name */ 34 35struct statfs { 36short f_type; /* type of filesystem (see below) */ 37short f_flags; /* copy of mount flags */ 38long f_bsize; /* fundamental file system block size */ 39long f_iosize; /* optimal transfer block size */ 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[9]; /* spare for later */ 47char f_mntonname[MNAMELEN]; /* mount point */ 48char f_mntfromname[MNAMELEN]; /* mounted filesystem */ 49}; 50/* 51* File system types. 52*/ 53#define MOUNT_UFS 1 /* Fast Filesystem */ 54#define MOUNT_NFS 2 /* Sun-compatible Network Filesystem */ 55#define MOUNT_MFS 3 /* Memory-based Filesystem */ 56#define MOUNT_MSDOS 4 /* MS/DOS Filesystem */ 57#define MOUNT_LFS 5 /* Log-based Filesystem */ 58#define MOUNT_LOFS 6 /* Loopback Filesystem */ 59#define MOUNT_FDESC 7 /* File Descriptor Filesystem */ 60#define MOUNT_PORTAL 8 /* Portal Filesystem */ 61#define MOUNT_NULL 9 /* Minimal Filesystem Layer */ 62#define MOUNT_UMAP 10 /* Uid/Gid Remapping Filesystem */ 63#define MOUNT_KERNFS 11 /* Kernel Information Filesystem */ 64#define MOUNT_PROCFS 12 /* /proc Filesystem */ 65#define MOUNT_AFS 13 /* Andrew Filesystem */ 66#define MOUNT_CD9660 14 /* ISO9660 (aka CDROM) Filesystem */ 67#define MOUNT_UNION 15 /* Union (translucent) Filesystem */ 68.Ed 69.Pp 70Fields that are undefined for a particular file system are set to -1. 71.Fn Fstatfs 72returns the same information about an open file referenced by descriptor 73.Fa fd . 74.Sh RETURN VALUES 75Upon successful completion, a value of 0 is returned. 76Otherwise, -1 is returned and the global variable 77.Va errno 78is set to indicate the error. 79.Sh ERRORS 80.Fn Statfs 81fails if one or more of the following are true: 82.Bl -tag -width ENAMETOOLONGA 83.It Bq Er ENOTDIR 84A component of the path prefix of 85.Fa Path 86is not a directory. 87.It Bq Er EINVAL 88.Fa path 89contains a character with the high-order bit set. 90.It Bq Er ENAMETOOLONG 91The length of a component of 92.Fa path 93exceeds 255 characters, 94or the length of 95.Fa path 96exceeds 1023 characters. 97.It Bq Er ENOENT 98The file referred to by 99.Fa path 100does not exist. 101.It Bq Er EACCES 102Search permission is denied for a component of the path prefix of 103.Fa path . 104.It Bq Er ELOOP 105Too many symbolic links were encountered in translating 106.Fa path . 107.It Bq Er EFAULT 108.Fa Buf 109or 110.Fa path 111points to an invalid address. 112.It Bq Er EIO 113An 114.Tn I/O 115error occurred while reading from or writing to the file system. 116.El 117.Pp 118.Fn Fstatfs 119fails if one or more of the following are true: 120.Bl -tag -width ENAMETOOLONGA 121.It Bq Er EBADF 122.Fa Fd 123is not a valid open file descriptor. 124.It Bq Er EFAULT 125.Fa Buf 126points to an invalid address. 127.It Bq Er EIO 128An 129.Tn I/O 130error occurred while reading from or writing to the file system. 131.El 132.Sh HISTORY 133The 134.Nm statfs 135function first appeared in 4.4BSD. 136