Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > S

statvfs(2)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

statvfs, fstatvfs — get file system information

SYNOPSIS

#include <sys/types.h>

#include <sys/statvfs.h>

int statvfs (const char *path, struct statvfs *buf);

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

DESCRIPTION

statvfs() returns information about a mounted file system.

fstatvfs() returns similar information about an open file.

The parameters for the statvfs() and fstatvfs() functions are as follows:

path

is a pointer to a path name of any file within the mounted file system.

buf

is a pointer to a statvfs structure, which is where the file system status information is stored.

fildes

is a file descriptor for an open file, which is created with the successful completion of an open(), creat(), dup(), fcntl(), or pipe() system call (see open(2), creat(2), dup(2), fcntl(2), or pipe(2)).

The statvfs structure contains the following members:

fsblkcnt_t f_blocks; /* total blocks of f_frsize on file system */ fsblkcnt_t f_bfree; /* free blocks */ fsblkcnt_t f_bavail; /* blocks available to non-superusers or users without the LIMIT privilege */ fsfilcnt_t f_files; /* total file nodes in file system */ fsfilcnt_t f_ffree; /* free file nodes in file system */ fsfilcnt_t f_favail; /* file nodes available to non-superusers or users without the LIMIT privilege */ ulong f_bsize; /* preferred file system block size */ ulong f_frsize; /* fundamental file system block size */ ulong f_size; /* see note below */ ulong f_fsid; /* file system ID for file system */ /* type; see sysfs(2) */ char f_basetype[FSTYPSZ]; /* file system type name is */ /* null-terminated */ ulong f_flag; /* bit mask of flags */ ulong f_namemax /* maximum file name length */ char f_fstr[32]; /* file system specific string */ time_t f_time; /* Last time file system was written */

The field f_size contains the size of file system in f_frsize units. Note that this field is not part of the standard POSIX definition of statvfs. When a 32-bit application uses statvfs64() with a large file system, f_size will top out at MAXINT, rather than return an EOVERFLOW error. Use f_blocks instead.

The field f_basetype contains a null-terminated file-system-type name.

The constant [FSTYPSZ] is defined in the header file <statvfs.h>.

The following flags can be returned in the f_flag field:

ST_LARGEFILES

File system is enabled for large files.

ST_RDONLY

File system is read-only.

ST_NOSUID

File system does not support setuid and setgid semantics.

ST_EXPORTED

File system is exported (NFS).

ST_QUOTA

ST_USRQUOTA

User quotas enabled on this file system.

ST_GRPQUOTA

Group quotas enabled on this file system.

Security Restrictions

The field f_bavail is the number of blocks available to non-superusers or users without the LIMIT privilege. The field f_favail is the number of file nodes available to non-superusers or users without the LIMIT privilege. See privileges(5) for more information about privileged access on systems that support fine-grained privileges.

RETURN VALUE

statvfs() and fstatvfs() return 0 upon successful completion; otherwise, they return -1 and set errno to indicate the error.

ERRORS

If statvfs() fails, errno is set to one of the following values:

EACCES

Search permission is denied for a component of the path prefix.

ELOOP

Too many symbolic links are encountered during path-name translation.

ENAMETOOLONG

The length of the specified path name exceeds PATH_MAX bytes, or the length of a component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect.

ENOENT

The named file does not exist (for example, path is null or a component of path does not exist).

ENOTDIR

A component of the path prefix is not a directory.

If fstatvfs() fails, errno is set to the following value:

EBADF

fildes is not a valid open file descriptor.

When both statvfs() and fstatvfs() fail, errno is set to one of the following values:

EFAULT

buf points to an invalid address.

EIO

An I/O error occurred while reading from or writing to the file system.

EOVERFLOW

Result would overflow one or more fields of the statvfs struct.

SEE ALSO

df(1M), fstatfs(2), fstatvfs64(2), quotactl(2), stat(2), statfs(2), statvfs64(2), sysfs(2), ustat(2), privileges(5).

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.