FAT | RFS | XFS | ZFS

frstat()

PROTOTYPE

#include <posix.h>

int frstat(int fid, struct stat *info);

DESCRIPTION

frstat() is a non-standard routine that writes information about the open file specified by fid to the stat structure indicated by info. The stat structure is defined in “posix.h” and reproduced below:

struct stat
{
  dev_t   st_dev;    /* ID of device containing this file */
  ino_t   st_ino;    /* file serial number */
  nlink_t st_nlink;  /* number of links */
  dev_t   st_rdev;   /* device ID (if inode device) */
  off_t   st_size;   /* the file size in bytes */
  time_t  st_atime;  /* last data access time (secs since Epoch) */
  time_t  st_mtime;  /* last data modification time (secs since Epoch) */
  time_t  st_ctime;  /* last status change time (secs since Epoch) */
  mode_t  st_mode;   /* file mode */
  uid_t   st_uid;    /* user ID of file's owner */
  gid_t   st_gid;    /* group ID of file's owner */
};

“posix.h” defines macros that can be applied to the st_mode field to determine the file’s access permissions and mode. The S_ISDIR() and S_ISREG() macros test whether the file is a directory or regular file.

frstat() behaves like fstat() except if the file is a directory, then the st_size field-instead of being set to zero-is the sum of the size of every regular file in the directory and its subdirectories. Because of the recursive size calculation, frstat() takes longer to execute than fstat().

If successful, frstat() returns 0. Otherwise, it sets errno and returns -1.

ERROR CODES

EBADF fid is not the descriptor of an open file.
EFAULT info equals NULL.