Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

fstatvfs, fstatvfs64, statvfs, statvfs64 - read file system information

&pagelevel(4)&pagelevel

Syntax

#include <sys/statvfs.h>
#include <sys/types.h>

int fstatvfs (int fildes, struct statvfs *buf);
int statvfs (const char *path, struct statvfs *buf);
int fstatvfs64 (int fildes, struct statvfs64 *buf);
int statvfs64 (const char *path, struct statvfs64 *buf); 

Description

fstatvfs() returns information on the file system to which the file identified by fildes belongs. buf is a pointer to a structure that is described below. The information on the file system is entered in this structure during the system call.

fildes identifies an open file descriptor that is the result of a successful open(), creat(), dup(), fcntl() or pipe() system call. The type of the file system containing the file assigned to fildes is known to the operating system. Read, write or execute permissions for the specified file are not needed.

There is no difference in functionality between fstatvfs() / statvfs() and fstatvfs64() / statvfs64() except that fstatvfs64() and statvfs64() both return the file status in statvfs64 structure.

The statvfs structure pointed to by buf contains the following components:

u1ong_t f_bsize;             /* Preferred block size of the file system */
u1ong_t f_frsize;            /* Basic block size of the file system
                                (if supported) */
fsblkcnt_t f_blocks;         /* Total number of blocks on the file system
                                in units of f_frsize */
fsblkcnt_t f_bfree;          /* Total number of free blocks */
fsblkcnt_t f_bavail;         /* Number of available free blocks for a
                                non-system administrator */
fsfilcnt_t f_files;          /* Total number of files (inodes) */
fsfilcnt_t f_ffree;          /* Total number of free nodes */
fsfilcnt_t f_favail;         /* Number of inodes for a
                                non-system administrator */
ulong_t f_fsid;              /* File system ID (currently dev) */
char    f_basetype[FSTYPSZ]; /* Type name of destination file system, 
                                null-terminated */
ulong_t f_flag;              /* Bit mask of the options */
ulong_t f_namemax;           /* Maximum length of the file names */
char    f_fstr[32];          /* File-system-specific string */
ulong_t f_filler[16];        /* Reserved for future extensions */

The statvfs64 structure differs from the statvfs structure by the following components:

fsblkcnt64_t f_blocks
fsblkcnt64_t f_bfree
fsblkcnt64_t f_bavail
fsfilcnt64_t f_files
fsfilcnt64_t f_ffree
fsfilcnt64_t f_favail

f_basetype contains a null-terminated type name of the file system (FST name) above the
mounted destination (e.g. s5 mounted above rfs results in s5).

The following values can be returned in the f_flag component:

ST_RDONLY     0x01    /* Write-protected file system */
ST_NOSUID     0x02    /* setuid/setgid semantics are not supported */
ST_NOTRUNC    0x04    /* Does not truncate file name longer than NAME_MAX*/

statvfs() works in the same way as fstatvfs(), except that the file is addressed via
the pathname referenced by path. Search authorization is required for every directory in the
pathname. 

Return val.

0

-1

if successful.

if an error occurs. errno is set to indicate the error.

Errors

fstatvfs(), fstatvfs64(), statvfs() und statvfs64() will fail if: 

 

EIO

An I/O error occurs during reading of the file system.

 

EINTR

A signal was received during execution of the function.

 

fstatvfs() and fstatvfs64() will fail if: 

 

EBADF

fildes is not an open file descriptor.

 

EOVERFLOW

One of the values returned cannot be represented correctly in the structure pointed to by buf, .


statvfs() and statvfs64() will fail if: 

 

EACCES

No search authorization exists for a component of the path prefix.

 

ELOOP

Too many symbolic links were encountered in resolving path.

 

ENAMETOOLONG 



The pathname to which path points is longer than {PATH_MAX}, or the length of a component of the pathname exceeds {NAME_MAX}.

 

ENOENT

A component of the pathname does not exist, or path points to an empty
string.

 

ENOTDIR

A component of the path prefix of path is not a directory.

 

ENAMETOOLONG 

 


The resolving of symbolic links in the pathname leads to an interim result whose length exceeds {PATH_MAX}.

Notes

Not all elements of the statvfs structure are used in all file systems. 

See also

chmod(), chown(), creat(), dup(), exec, link(), mknod(), pipe(), read(), time(), unlink(), utime(), write(), sys/statvfs.h.