/*
* Fstat (Get file status from file descriptor)
* Correlation function Stat,lstat,chmod,chown,readlink,utime
* Table header File
* #include <sys/stat.h>
* #include <unistd.h>
* Define function
* int fstat (int fildes,struct stat *buf);
The * Function Description Fstat () is used to copy the file state of the parameter fildes to the structure referred to in the parameter buf (struct stat).
* Fstat () is exactly the same as stat (), except that the passed parameter is an open file descriptor.
* The return value performs successfully returns 0, the failure returns 1, and the error code is stored in errno.
*/
/* Example * *
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/ types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main (int argc, char *argv)
{
struct stat buf;
int FD;
FD = open ("/etc/passwd", o_rdonly);
Fstat (FD, &buf);
printf ("/etc/passwd File Size:%d\n", buf.st_size);
return 0;
}
/* Execute/etc/passwd File size = 705 * *