1statvfs(2)                       System Calls                       statvfs(2)
2
3
4

NAME

6       statvfs, fstatvfs - get file system information
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/statvfs.h>
11
12       int statvfs(const char *restrict path, struct statvfs *restrict buf);
13
14
15       int fstatvfs(int fildes, struct statvfs *buf);
16
17

DESCRIPTION

19       The statvfs() function returns a "generic superblock" describing a file
20       system; it can be used to acquire information about mounted  file  sys‐
21       tems.   The  buf argument is a pointer to a structure (described below)
22       that is filled by the function.
23
24
25       The path argument should name a file that resides on that file  system.
26       The  file system type is known to the operating system. Read, write, or
27       execute permission for the named file is not required, but all directo‐
28       ries listed in the path name leading to the file must be searchable.
29
30
31       The statvfs structure pointed to by buf includes the following members:
32
33         u_long      f_bsize;             /* preferred file system block size */
34         u_long      f_frsize;            /* fundamental filesystem block
35                                             (size if supported) */
36         fsblkcnt_t  f_blocks;            /* total # of blocks on file system
37                                             in units of f_frsize */
38         fsblkcnt_t  f_bfree;             /* total # of free blocks */
39         fsblkcnt_t  f_bavail;            /* # of free blocks avail to
40                                             non-privileged user */
41         fsfilcnt_t  f_files;             /* total # of file nodes (inodes) */
42         fsfilcnt_t  f_ffree;             /* total # of free file nodes */
43         fsfilcnt_t  f_favail;            /* # of inodes avail to
44                                             non-privileged user*/
45         u_long      f_fsid;              /* file system id (dev for now) */
46         char        f_basetype[FSTYPSZ]; /* target fs type name,
47                                             null-terminated */
48         u_long      f_flag;              /* bit mask of flags */
49         u_long      f_namemax;           /* maximum file name length */
50         char        f_fstr[32];          /* file system specific string */
51         u_long      f_filler[16];        /* reserved for future expansion */
52
53
54
55       The  f_basetype  member  contains  a null-terminated FSType name of the
56       mounted target.
57
58
59       The following values can be returned in the f_flag field:
60
61         ST_RDONLY    0x01    /* read-only file system */
62         ST_NOSUID    0x02    /* does not support setuid/setgid semantics */
63         ST_NOTRUNC   0x04    /* does not truncate file names longer than
64                                 NAME_MAX */
65
66
67
68       The fstatvfs() function is similar to statvfs(), except that  the  file
69       named  by  path  in  statvfs()  is  instead  identified by an open file
70       descriptor fildes obtained from a successful open(2), creat(2), dup(2),
71       fcntl(2), or pipe(2) function call.
72

RETURN VALUES

74       Upon  successful  completion,  0 is returned. Otherwise, −1 is returned
75       and errno is set to indicate the error.
76

ERRORS

78       The statvfs() and fstatvfs() functions will fail if:
79
80       EOVERFLOW    One of the values to be  returned  cannot  be  represented
81                    correctly in the structure pointed to by buf.
82
83
84
85       The statvfs() function will fail if:
86
87       EACCES          Search  permission is denied on a component of the path
88                       prefix.
89
90
91       EFAULT          The path or buf argument points to an illegal address.
92
93
94       EINTR           A  signal  was  caught  during  the  execution  of  the
95                       statvfs() function.
96
97
98       EIO             An I/O error occurred while reading the file system.
99
100
101       ELOOP           Too many symbolic links were encountered in translating
102                       path.
103
104
105       ENAMETOOLONG    The length of a path component exceeds NAME_MAX charac‐
106                       ters,  or the length of path The exceeds PATH_MAX char‐
107                       acters.
108
109
110       ENOENT          Either a component of  the  path  prefix  or  the  file
111                       referred to by path does not exist.
112
113
114       ENOLINK         The  path  argument  points to a remote machine and the
115                       link to that machine is no longer active.
116
117
118       ENOTDIR         A component of the path prefix of path is not a  direc‐
119                       tory.
120
121
122
123       The fstatvfs() function will fail if:
124
125       EBADF     The fildes argument is not an open file descriptor.
126
127
128       EFAULT    The buf argument points to an illegal address.
129
130
131       EINTR     A  signal  was  caught during the execution of the fstatvfs()
132                 function.
133
134
135       EIO       An I/O error occurred while reading the file system.
136
137

USAGE

139       The statvfs() and fstatvfs() functions have transitional interfaces for
140       64-bit file offsets.  See lf64(5).
141

ATTRIBUTES

143       See attributes(5) for descriptions of the following attributes:
144
145
146
147
148       ┌─────────────────────────────┬─────────────────────────────┐
149       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
150       ├─────────────────────────────┼─────────────────────────────┤
151       │Interface Stability          │Standard                     │
152       └─────────────────────────────┴─────────────────────────────┘
153

SEE ALSO

155       chmod(2),  chown(2),  creat(2),  dup(2),  fcntl(2),  link(2), mknod(2),
156       open(2), pipe(2),  read(2),  time(2),  unlink(2),  utime(2),  write(2),
157       attributes(5), lf64(5), standards(5)
158

BUGS

160       The values returned for f_files, f_ffree, and f_favail may not be valid
161       for NFS mounted file systems.
162
163
164
165SunOS 5.11                        22 Mar 2004                       statvfs(2)
Impressum