Stat (Unix)

Stat (Unix)

stat() is a Unix system call that returns useful data about a file inode. The semantics of stat() vary between operating systems. With the Unix command ls, one can gather information about
*mtime: time of last modification (ls -l),
*ctime: time of last status change (ls -lc) and
*atime: time of last access (ls -lu).

Note that ctime is not the time of file creation. Writing to a file changes its mtime, ctime, and atime. A change in file permissions or file ownership changes its ctime and atime. Reading a file changes its atime. File systems mounted with the noatime option do not update the atime on reads, and the relatime option provides for updates only if the previous atime is older than the mtime or ctime. Unlike atime and mtime, ctime cannot be set with utime() (as used e.g. by touch); the only way to set it to an arbitrary value is by changing the system clock.

lstat()

lstat() is a library function that retrieves the status of a file. It is identical to stat(), except when the file is a symbolic link, in which case information about the link itself is returned instead of the linked-to file.

fstat()

fstat() is a library function that retrieves the status of a file. It is identical to stat() except that the file's identity is passed as a file descriptor instead of as a filename.

tat() functions

The following is a set of declarations from the POSIX library header sys/stat.h typically found on most operating systems.

#include #include int stat(const char *filename, struct stat *buf); int lstat(const char *filename, struct stat *buf); int fstat(int filedesc, struct stat *buf); struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for filesystem I/O */ blkcnt_t st_blocks; /* number of blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ };

References

* [http://linux.die.net/man/2/fstat stat(2) in the Linux Programmer's Manual]

External links

* [http://www.hep.wisc.edu/~pinghc/NoteFileSystemInfo.htm An example showing how to use stat()]
* [http://perldoc.perl.org/functions/stat.html stat() in Perl]
* [http://www.php.net/manual/en/function.stat.php stat() in PHP]
* [http://kerneltrap.org/node/14148 atime and relatime]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • stat (Unix) — stat() is a Unix system call that returns useful data about a file inode. The semantics of stat() vary between operating systems. As an example, the Unix command ls uses it to retrieve information on (among many others): mtime: time of last… …   Wikipedia

  • Stat (Unix) — stat est le nom d un appel système et d une commande Unix faisant partie du paquetage Coreutils (ou GNU Core Utilities). Cet outil permet d obtenir des informations sur des fichiers ou répertoires. Exemple Afficher la taille du fichier… …   Wikipédia en Français

  • Unix — (registrado oficialmente como UNIX®) es un sistema operativo portable, multitarea y multiusuario; desarrollado, en principio, en 1969 por un grupo de empleados de los laboratorios Bell de AT T, entre los que figuran Ken Thompson, Dennis Ritchie y …   Wikipedia Español

  • Unix file types — For normal files in the file system, Unix does not impose or provide any internal file structure. This implies that from the point of view of the operating system, there is only one file type. The structure and interpretation thereof is entirely… …   Wikipedia

  • UNIX — Генеалогическое древо UNIX систем UNIX (читается юникс) семейство переносимых, многозадачных и многопользовательских …   Википедия

  • Unix — Генеалогическое древо UNIX систем UNIX (читается юникс)  группа переносимых, многозадачных и многопользовательских операционных систем. Первая система UNIX была разработана в 1969 г. в подразделении Bell Labs компании AT T. С тех пор было создано …   Википедия

  • STAT — Wiktionary|statSTAT may mean: *STAT protein, the Signal Transducers and Activators of Transcription protein, *Special Tertiary Admissions Test, a set of tests aimed at assessing the critical reasoning abilities of university applicants who lack… …   Wikipedia

  • Stat — Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. Sur les autres projets Wikimedia : « Stat », sur le Wiktionnaire (dictionnaire universel) Cinéma et télévision Stat! est un téléfilm… …   Wikipédia en Français

  • Программы UNIX-подобных операционных систем — Это список популярных программ, работающих в операционных системах основанных на UNIX (POSIX совместимых). Некоторые из этих программ являются стандартными для UNIX подобных систем. Содержание 1 Системный софт 1.1 Общего назначения …   Википедия

  • Pipeline (Unix) — In Unix like computer operating systems, a pipeline is the original software pipeline : a set of processes chained by their standard streams, so that the output of each process ( stdout ) feeds directly as input ( stdin ) of the next one. Each… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”