1STATFS(2)                     System Calls Manual                    STATFS(2)
2
3
4

NAME

6       statfs, fstatfs - get file system statistics
7

SYNOPSIS

9       #include <sys/param.h>
10       #include <sys/mount.h>
11
12       int
13       statfs(path,buf)
14       char *path;
15       struct statfs *buf;
16
17       int
18       fstatfs(fd,buf)
19       int fd;
20       struct statfs *buf;
21

DESCRIPTION

23       Statfs()  returns information about a mounted file system.  Path is the
24       path name of any file within the mounted filesystem.  Buf is a  pointer
25       to a statfs structure defined as follows:
26
27
28       #define MNAMELEN 90       /* length of buffer for returned name */
29
30       struct statfs {
31       short   f_type;           /* type of filesystem (see below) */
32       short   f_flags;          /* copy of mount flags */
33       short   f_bsize;          /* fundamental file system block size */
34       short   f_iosize;         /* optimal transfer block size */
35       long    f_blocks;         /* total data blocks in file system */
36       long    f_bfree;          /* free blocks in fs */
37       long    f_bavail;         /* free blocks avail to non-superuser */
38       ino_t   f_files;          /* total file nodes in file system */
39       ino_t   f_ffree;          /* free file nodes in fs */
40       u_long  f_fsid[2];        /* file system id */
41       long    f_spare[4];       /* spare for later */
42       char    f_mntonname[MNAMELEN];    /* mount point */
43       char    f_mntfromname[MNAMELEN];  /* mounted filesystem */
44       };
45       /*
46       * File system types. - Only UFS is supported so the other types are not
47       * given.
48       */
49       #define   MOUNT_UFS 1    /* Fast Filesystem */
50
51       Fields  that  are undefined for a particular file system are set to -1.
52       Fstatfs() returns the same information about an open file referenced by
53       descriptor fd.
54

RETURN VALUES

56       Upon successful completion, a value of 0 is returned.  Otherwise, -1 is
57       returned and the global variable errno is set to indicate the error.
58

ERRORS

60       Statfs() fails if one or more of the following are true:
61
62
63       [ENOTDIR]           A component of the path prefix of  Path  is  not  a
64                           directory.
65
66       [EINVAL]            path  contains  a character with the high-order bit
67                           set.
68
69       [ENAMETOOLONG]      The length of a component of path exceeds 63  char‐
70                           acters,  or  the length of path exceeds 255 charac‐
71                           ters.
72
73       [ENOENT]            The file referred to by path does not exist.
74
75       [EACCES]            Search permission is denied for a component of  the
76                           path prefix of path.
77
78       [ELOOP]             Too  many symbolic links were encountered in trans‐
79                           lating path.
80
81       [EFAULT]            Buf or path points to an invalid address.
82
83       [EIO]               An I/O error occurred while reading from or writing
84                           to the file system.
85
86       Fstatfs() fails if one or more of the following are true:
87
88
89       [EBADF]             Fd is not a valid open file descriptor.
90
91       [EFAULT]            Buf points to an invalid address.
92
93       [EIO]               An I/O error occurred while reading from or writing
94                           to the file system.
95

HISTORY

97       The statfs function first appeared in 4.4BSD.
98
99
100
1014.4 Berkeley Distribution      December 26, 1995                     STATFS(2)
Impressum