HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)

f
fstat(2) fstat(2)
NAME
fstat - get file status
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int fstat(int fildes, struct stat *buf);
DESCRIPTION
The fstat() function obtains information about an open file associated with the file descriptor fildes,
and writes it to the area pointed to by buf. fildes is a file descriptor for an open file, which is created with
the successful completion of an
open(), creat()
, dup(), fcntl(),orpipe() system call. See the
open(2), creat (2), dup(2), fcntl(2), or pipe(2)) manpages for more detailed information. The buf argument
is a pointer to a
stat structure, as defined in
<sys/stat.h>, where the filesystem information is
stored. The
stat structure contains the following members:
dev_t st_dev; /* ID of device containing a */
/* directory entry for this file */
ino_t st_ino; /* Inode number */
short st_fstype; /* Type of filesystem this file */
/* is in; see sysfs(2) */
ushort st_mode; /* File type, attributes, and */
/* access control summary */
ushort st_basemode /* Permission bits (see chmod(1)) */
ushort st_nlink; /* Number of links */
uid_t st_uid; /* User ID of file owner */
gid_t st_gid; /* Group ID of file group */
dev_t st_rdev; /* Device ID; this entry defined */
/* only for char or blk spec files */
off_t st_size; /* File size (bytes) */
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Last modification time */
time_t st_ctime; /* Last file status change time */
/* Measured in secs since */
/* 00:00:00 GMT, Jan 1, 1970 */
long st_blksize; /* File system block size */
uint st_acl:1; /* Set if the file has optional */
/* access control list entries */
/* HFS File Systems only */
uint st_aclv:1; /* Set if the file has optional */
/* access control list entries */
/* JFS File Systems only */
(Note that the position of items in this list does not necessarily reflect the order of the members in the
structure.)
The fields contain the following information:
st_atime Time when file data was last accessed. Changed by the following system calls:
creat(), mknod(), pipe(), read(), readv() (see the read (2)), and
utime(). If a file is mapped into virtual memory, accesses of file data through the
mapping may also modify st_mtime . See mmap(2).
st_mtime Time when data was last modified. Changed by the following system calls:
creat(), truncate(), ftruncate(), (see truncate (2)), mknod(), pipe(),
prealloc(), utime(), write(), and writev() (see write (2)). Also changed
by close() when the reference count reaches zero on a named pipe (FIFO special)
file that contains data. If a file is mapped into virtual memory, updates of file data
through the mapping may also modify st_mtime . See mmap(2).
st_ctime Time when file status was last changed. Changed by the following system calls:
acl(), chmod(), chown(), creat(), fchmod(), fchown(), truncate(),
ftruncate(), (see truncate (2)), link(), mknod(), pipe(), prealloc(),
rename(), setacl(), unlink(), utime(), write(), and writev() (see
write (2)). The touch command (see touch (1)) can be used to explicitly control the
HP-UX 11i Version 2: August 2003 1 Hewlett-Packard Company Section 273