Middleware, development tools, realtime operating system
software and services for superior embedded design


Home
QNX Community Resources
Developer Support
QNX Documentation Library
QNX Developer Support

QNX Developer Support

QNX Software Systems
Developer Resources
Blogs
Board support packages
Foundry27 projects
Forums
Hardware support listing
Online video tutorials
Product documentation
Technical Articles

[Previous] [Contents] [Index] [Next]

fstatvfs(), fstatvfs64()

Get filesystem information, given a file descriptor

Synopsis:

#include <sys/statvfs.h>

int fstatvfs( int fildes, 
              struct statvfs *buf );

int fstatvfs64( int fildes,
                struct statvfs64 *buf );

Arguments:

fildes
The descriptor for a file that resides on the filesystem that you want to get information about.
buf
A pointer to a buffer where the function can store information about the filesystem; see below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The fstatvfs() function returns a "generic superblock" describing a filesystem; you can use it to get information about mounted filesystems. The fstatvfs64() function is a 64-bit version of fstatvfs().

The fildes argument is an open file descriptor, obtained from a successful call to open(), creat(), dup(), fcntl(), or pipe(), for a file that resides on that filesystem. The filesystem type is known to the operating system. Read, write, or execute permission for the named file isn't required.

The buf argument is a pointer to a statvfs or statvfs64 structure that's filled by the function. It contains at least:

unsigned long f_bsize
The preferred filesystem blocksize.
unsigned long f_frsize
The fundamental filesystem blocksize (if supported)
fsblkcnt_t f_blocks
The total number of blocks on the filesystem, in units of f_frsize.
fsblkcnt_t f_bfree
The total number of free blocks.
fsblkcnt_t f_bavail
The number of free blocks available to a nonsuperuser.
fsfilcnt_t f_files
The total number of file nodes (inodes).
fsfilcnt_t f_ffree
The total number of free file nodes.
fsfilcnt_t f_favail
The number of inodes available to a nonsuperuser.
unsigned long f_fsid
The filesystem ID (dev for now).
char f_basetype[16]
The type of the target filesystem, as a null-terminated string.
unsigned long f_flag
A bitmask of flags; the function can set these flags:
  • ST_RDONLY -- read-only filesystem.
  • ST_NOSUID -- the filesystem doesn't support setuid/setgid semantics.
unsigned long f_namemax
The maximum filename length.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
The fildes argument isn't an open file descriptor.
EFAULT
The buf argument points to an illegal address.
EINTR
A signal was caught during execution.
EIO
An I/O error occurred while reading the filesystem.
EOVERFLOW
One of the values to be returned can't be represented correctly in the structure pointed to by buf.

Classification:

fstatvfs() is POSIX 1003.1 XSI; fstatvfs64() is Large-file support

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

The values returned for f_files, f_ffree, and f_favail might not be valid for NFS-mounted filesystems.

See also:

chmod(), chown(), creat(), dup(), fcntl(), link(), mknod(), open(), pipe(), read(), statvfs(), statvfs64(), time(), unlink(), utime(), write()


[Previous] [Contents] [Index] [Next]