HP-UX Reference (11i v1 05/09) - 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. The buf argument is a pointer to a
stat structure, as defined in
<sys/stat.h> , into which information is placed concerning the file.
The structure members st_mode, st_ino, st_dev, st_uid, st_gid, st_atime, st_ctime , and st_mtime will have
meaningful values for all file types defined in this document. The value of the member st_nlink will be set
to the number of links to the file.
An implementation that provides additional or alternative file access control mechanisms may, under
implementation-dependent conditions, cause
fstat() to fail.
The
fstat() function updates any time-related fields as described in File Times Update (see the XBD
specification, Chapter 4, Character Set), before writing into the stat structure.
RETURN VALUE
Upon successful completion, 0 is returned. Otherwise, 1 is returned and errno is set to indicate the
error.
When using fstat() to get the status of a socket descriptor, the following return values are also possible:
[EINPROGRESS] Nonblocking I/O is enabled using O_NONBLOCK, O_NODELAY, or
FIOSNBIO, and the connection cannot be completed immediately. This is
not a failure. Make the connect() call again a few seconds later. Alter-
natively, wait for completion by calling select() and selecting for write.
[EWOULDBLOCK] Non-blocking I/O is enabled using ioctl() FIOSNBIO request, and the
requested operation would block.
ERRORS
The fstat() function will fail if:
[EBADF] The fildes argument is not a valid file descriptor.
[EIO] An I/O error occurred while reading from the file system.
The fstat() function may fail if:
[EOVERFLOW] One of the values is too large to store into the structure pointed to by the
buf argument.
SEE ALSO
lstat(2), stat(2), <sys/stat.h>, <sys/types.h>.
CHANGE HISTORY
First released in Issue 1.
Derived from Issue 1 of the SVID.
Issue 4
The following changes are incorporated in the DESCRIPTION section for alignment with the ISO POSIX-1
standard:
A paragraph defining the contents of stat structure members is added.
The words "extended security controls" are replaced by "additional or alternative file access control
mechanisms."
Another change is incorporated as follows:
HP-UX 11i Version 1: September 2005 1 Hewlett-Packard Company Section 273