Stat (system Call) - Stat Functions

Stat Functions

The C POSIX library header , found on POSIX and other Unix-like operating systems, declares the stat functions, as well as related function called fstat and lstat. The functions take a struct stat buffer argument, which is used to return the file attributes. On success, the functions return zero, and on error, −1 is returned and errno is set appropriately.

The stat and lstat functions take a filename argument. If the file name is a symbolic link, stat returns attributes of the eventual target of the link, while lstat returns attributes of the link itself. The fstat function takes a file descriptor argument instead, and returns attributes of the file that it identifies.

The family of functions was extended to implement large file support. Functions named stat64, lstat64 and fstat64 return attributes in a struct stat64 structure, which represents file sizes with a 64-bit type, allowing the functions to work on files 2 GiB and larger. When the _FILE_OFFSET_BITS macro is defined to 64, these 64-bit functions are available under the original names.

The functions are defined as:

int stat(const char *filename, struct stat *buf); int lstat(const char *filename, struct stat *buf); int fstat(int filedesc, struct stat *buf);

Read more about this topic:  Stat (system Call)

Famous quotes containing the word functions:

    Let us stop being afraid. Of our own thoughts, our own minds. Of madness, our own or others’. Stop being afraid of the mind itself, its astonishing functions and fandangos, its complications and simplifications, the wonderful operation of its machinery—more wonderful because it is not machinery at all or predictable.
    Kate Millett (b. 1934)