[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

statfs, fstatfs, or ustat Subroutine


Gets file system statistics.


Standard C Library (libc.a)


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


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 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.


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.
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, and ustat subroutines fail if the following is true:

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

The fstatfs subroutine fails if the following is true:

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

The statfs 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".

The statfs subroutine can be unsuccessful for other reasons. For a list of additional errors, see Appendix A, "Base Operating System Error Codes for Services That Require Path-Name Resolution" .

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The stat subroutine.

Files, Directories, and File Systems for Programmers in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

[ Previous | Next | Contents | Glossary | Home | Search ]