statfs, fstatfs, statfs64, fstatfs64, or ustat Subroutine

Purpose

Gets file system statistics.

Library

Standard C Library (libc.a)

Syntax

#include <sys/statfs.h>
int statfs ( Path,  StatusBuffer)
char *Path;
struct statfs *StatusBuffer;
int fstatfs ( FileDescriptor, StatusBuffer)
int FileDescriptor;
struct statfs *StatusBuffer;
int statfs64 ( Path,  StatusBuffer64)
char *Path;
struct statfs64 *StatusBuffer64;
int fstatfs64 ( FileDescriptor, StatusBuffer64)
int FileDescriptor;
struct statfs64 *StatusBuffer64;
#include <sys/types.h>
#include <ustat.h>
int ustat ( Device,  Buffer)
dev_t Device;
struct ustat *Buffer;

Description

The statfs and fstatfs subroutines return information about the mounted file system that contains the file named by the Path or FileDescriptor parameters. The returned information is in the format of a statfs structure, described in the sys/statfs.h file.

The statfs64 and fstatfs64 subroutines are similar to the statfs and fstatfs subroutines except that the returned information is in the format of a statfs64 structure, described in the sys/statfs.h file, instead of a statfs structure.

The statfs64 structure provides invariant 64-bit fields for the file system blocks (or inodes) sizes or counts, and the file system ID. This structure allows statfs64 and fstatfs64 to always return the specified information in invariant 64-bit sizes.

The ustat subroutine also returns information about a mounted file system identified by Device. This device identifier is for any given file and can be determined by examining the st_dev field of the stat structure defined in the sys/stat.h file. The returned information is in the format of a ustat structure, described in the ustat.h file. The ustat subroutine is superseded by the statfs and fstatfs subroutines. Use one of these (statfs and fstatfs) subroutines instead.
Note: The ustat subroutine does not work for 64-bit sizes.

Parameters

Item Description
Path The path name of any file within the mounted file system.
FileDescriptor A file descriptor obtained by a successful open or fcntl subroutine. A file descriptor is a small positive integer used instead of a file name.
StatusBuffer A pointer to a statfs buffer for the returned information from the statfs or fstatfs subroutine.
StatusBuffer64 A pointer to a statfs64 buffer for the returned information from the statfs64 or fstatfs64 subroutine.
Device The ID of the device. It corresponds to the st_rdev field of the structure returned by the stat subroutine. The stat subroutine and the sys/stat.h file provide more information about the device driver.
Buffer A pointer to a ustat buffer to hold the returned information.

Return Values

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

Error Codes

The statfs, fstatfs, statfs64, fstatfs64, and ustat subroutines fail if the following is true:

Item Description
EFAULT The Buffer parameter points to a location outside of the allocated address space of the process.

The fstatfs or fstatfs64 subroutine fails if the following is true:

Item Description
EBADF The FileDescriptor parameter is not a valid file descriptor.
EIO An I/O error occurred while reading from the file system.

The statfs or statfs64 subroutine can be unsuccessful for other reasons. For a list of additional errors, see Base Operating System error codes for services that require path-name resolution.