COHERENT manpages

This page displays the COHERENT manpage for fstat() [Find attributes of an open file].

List of available manpages
Index


fstat() -- System Call (libc)

Find attributes of an open file
#include <sys/stat.h>
int fstat(fd, statptr)
int fd; struct stat *statptr;

fstat() examines the  attributes of an open file.  fd  is the descriptor of
the open file  or pipe you wish to examine.   statptr points to a structure
of type  stat, which is defined in the  header file <stat.h>; fstat()
writes  into it  the attributes  of the  file or pipe  to which  fd points,
including protection information, file type, and file size.

fstat() returns zero if all goes well.  If an error occurs (e.g., fd is not
found or statptr is invalid), it returns -1.

Example

For  an example  of how  to use  this function, see  the Lexicon  entry for
pipe().

See Also

chmod(),
chown(),
libc,
ls,
open(),
stat(),
stat.h
POSIX Standard, §5.6.2

Notes

fstat() differs from the related function stat() mainly in that it accesses
a file through  its descriptor, which was returned by  a successful call to
open(), whereas stat() takes the file's path name and opens the file itself
before it checks its status.