logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Description

       Describes information about a file.

       The fields are as follows:

       st_dev This field describes the device on which this file resides.  (The major(3) and minor(3) macros may
              be useful to decompose the device ID in this field.)

       st_ino This field contains the file's inode number.

       st_mode
              This field contains the file type and mode.  See inode(7) for further information.

       st_nlink
              This field contains the number of hard links to the file.

       st_uid This field contains the user ID of the owner of the file.

       st_gid This field contains the ID of the group owner of the file.

       st_rdev
              This field describes the device that this file (inode) represents.

       st_size
              This  field gives the size of the file (if it is a regular file or a symbolic link) in bytes.  The
              size of a symbolic link is the length of the pathname it  contains,  without  a  terminating  null
              byte.

       st_blksize
              This field gives the "preferred" block size for efficient filesystem I/O.

       st_blocks
              This  field indicates the number of blocks allocated to the file, in 512-byte units.  (This may be
              smaller than st_size/512 when the file has holes.)

       st_atime
              This is the time of the last access of file data.

       st_mtime
              This is the time of last modification of file data.

       st_ctime
              This is the file's last status change timestamp (time of last change to the inode).

       For further information on the above fields, see inode(7).

History

       POSIX.1-2001.

       Old kernels and old standards did not support nanosecond timestamp fields.   Instead,  there  were  three
       timestamp  fields—st_atime,  st_mtime,  and  st_ctime—typed  as time_t that recorded timestamps with one-
       second precision.

       Since Linux 2.5.48, the stat structure supports  nanosecond  resolution  for  the  three  file  timestamp
       fields.  The nanosecond components of each timestamp are available via names of the form st_atim.tv_nsec,
       if  suitable  test  macros  are  defined.   Nanosecond timestamps were standardized in POSIX.1-2008, and,
       starting with glibc 2.12, glibc exposes the nanosecond component names if _POSIX_C_SOURCE is defined with
       the value 200809L or greater, or _XOPEN_SOURCE is defined with the value  700  or  greater.   Up  to  and
       including  glibc  2.19,  the definitions of the nanoseconds components are also defined if _BSD_SOURCE or
       _SVID_SOURCE is defined.  If none of the aforementioned macros are defined, then  the  nanosecond  values
       are exposed with names of the form st_atimensec.

Library

       Standard C library (libc)

Name

       stat - file status

Notes

       The following header also provides this type: <ftw.h>.

See Also

stat(2), inode(7)

Linux man-pages 6.9.1                              2024-05-02                                        stat(3type)

Standards

       POSIX.1-2008.

Synopsis

#include<sys/stat.h>structstat{dev_tst_dev;      /* ID of device containing file */
           ino_tst_ino;      /* Inode number */
           mode_tst_mode;     /* File type and mode */
           nlink_tst_nlink;    /* Number of hard links */
           uid_tst_uid;      /* User ID of owner */
           gid_tst_gid;      /* Group ID of owner */
           dev_tst_rdev;     /* Device ID (if special file) */
           off_tst_size;     /* Total size, in bytes */
           blksize_tst_blksize;  /* Block size for filesystem I/O */
           blkcnt_tst_blocks;   /* Number of 512 B blocks allocated */

           /* Since POSIX.1-2008, this structure supports nanosecond
              precision for the following timestamp fields.
              For the details before POSIX.1-2008, see VERSIONS. */

           structtimespecst_atim;  /* Time of last access */
           structtimespecst_mtim;  /* Time of last modification */
           structtimespecst_ctim;  /* Time of last status change */

       #definest_atimest_atim.tv_sec  /* Backward compatibility */
       #definest_mtimest_mtim.tv_sec#definest_ctimest_ctim.tv_sec};

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       st_atim, st_mtim, st_ctim:
           Since glibc 2.12:
               _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
           glibc 2.19 and earlier:
               _BSD_SOURCE || _SVID_SOURCE

See Also