1stat(3type)                                                        stat(3type)
2
3
4

NAME

6       stat - file status
7

LIBRARY

9       Standard C library (libc)
10

SYNOPSIS

12       #include <sys/stat.h>
13
14       struct stat {
15           dev_t      st_dev;      /* ID of device containing file */
16           ino_t      st_ino;      /* Inode number */
17           mode_t     st_mode;     /* File type and mode */
18           nlink_t    st_nlink;    /* Number of hard links */
19           uid_t      st_uid;      /* User ID of owner */
20           gid_t      st_gid;      /* Group ID of owner */
21           dev_t      st_rdev;     /* Device ID (if special file) */
22           off_t      st_size;     /* Total size, in bytes */
23           blksize_t  st_blksize;  /* Block size for filesystem I/O */
24           blkcnt_t   st_blocks;   /* Number of 512 B blocks allocated */
25
26           /* Since POSIX.1-2008, this structure supports nanosecond
27              precision for the following timestamp fields.
28              For the details before POSIX.1-2008, see VERSIONS. */
29
30           struct timespec  st_atim;  /* Time of last access */
31           struct timespec  st_mtim;  /* Time of last modification */
32           struct timespec  st_ctim;  /* Time of last status change */
33
34       #define st_atime  st_atim.tv_sec  /* Backward compatibility */
35       #define st_mtime  st_mtim.tv_sec
36       #define st_ctime  st_ctim.tv_sec
37       };
38
39   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
40
41       st_atim, st_mtim, st_ctim:
42           Since glibc 2.12:
43               _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
44           glibc 2.19 and earlier:
45               _BSD_SOURCE || _SVID_SOURCE
46

DESCRIPTION

48       Describes information about a file.
49
50       The fields are as follows:
51
52       st_dev This  field  describes  the  device  on which this file resides.
53              (The major(3) and minor(3) macros may be useful to decompose the
54              device ID in this field.)
55
56       st_ino This field contains the file's inode number.
57
58       st_mode
59              This  field  contains  the file type and mode.  See inode(7) for
60              further information.
61
62       st_nlink
63              This field contains the number of hard links to the file.
64
65       st_uid This field contains the user ID of the owner of the file.
66
67       st_gid This field contains the ID of the group owner of the file.
68
69       st_rdev
70              This field describes the device that this  file  (inode)  repre‐
71              sents.
72
73       st_size
74              This  field  gives the size of the file (if it is a regular file
75              or a symbolic link) in bytes.  The size of a  symbolic  link  is
76              the  length  of  the pathname it contains, without a terminating
77              null byte.
78
79       st_blksize
80              This field  gives  the  "preferred"  block  size  for  efficient
81              filesystem I/O.
82
83       st_blocks
84              This field indicates the number of blocks allocated to the file,
85              in 512-byte units.  (This may be smaller than  st_size/512  when
86              the file has holes.)
87
88       st_atime
89              This is the time of the last access of file data.
90
91       st_mtime
92              This is the time of last modification of file data.
93
94       st_ctime
95              This  is  the  file's last status change timestamp (time of last
96              change to the inode).
97
98       For further information on the above fields, see inode(7).
99

STANDARDS

101       POSIX.1-2008.
102

HISTORY

104       POSIX.1-2001.
105
106       Old kernels and old standards  did  not  support  nanosecond  timestamp
107       fields.  Instead, there were three timestamp fields—st_atime, st_mtime,
108       and st_ctime—typed as time_t that recorded timestamps  with  one-second
109       precision.
110
111       Since  Linux  2.5.48, the stat structure supports nanosecond resolution
112       for the three file timestamp fields.  The nanosecond components of each
113       timestamp are available via names of the form st_atim.tv_nsec, if suit‐
114       able test macros are defined.  Nanosecond timestamps were  standardized
115       in  POSIX.1-2008,  and,  starting  with  glibc  2.12, glibc exposes the
116       nanosecond component names if _POSIX_C_SOURCE is defined with the value
117       200809L  or  greater, or _XOPEN_SOURCE is defined with the value 700 or
118       greater.  Up to and  including  glibc  2.19,  the  definitions  of  the
119       nanoseconds  components are also defined if _BSD_SOURCE or _SVID_SOURCE
120       is defined.  If none of the aforementioned macros are defined, then the
121       nanosecond values are exposed with names of the form st_atimensec.
122

NOTES

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

SEE ALSO

127       stat(2), inode(7)
128
129
130
131Linux man-pages 6.05              2023-05-03                       stat(3type)
Impressum