$ stat Cargo.toml
16777220 9094681422 -rw-r--r-- 1 tonytonyjan staff 0 109 "Jan 19 10:05:13 2019" "Dec 31 17:52:29 2018" "Dec 31 17:52:29 2018" "Dec 14 16:32:26 2018" 4096 8 0 Cargo.toml
man stat
does not explain but mention that the output is obtained by lstat
:
The information displayed is obtained by calling lstat(2) with the given argument and evaluating the returned structure.
After man lstat
, it gives a C structure which looks like what I am looking for:
The buf argument is a pointer to a stat structure as defined by <sys/stat.h> and into which information is placed concerning the file. When the macro
_DARWIN_FEATURE_64_BIT_INODE is not defined (see below for more information about this macro), the stat structure is defined as:
struct stat { /* when _DARWIN_FEATURE_64_BIT_INODE is NOT defined */
dev_t st_dev; /* device inode resides on */
ino_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */
nlink_t st_nlink; /* number of hard links to the file */
uid_t st_uid; /* user-id of owner */
gid_t st_gid; /* group-id of owner */
dev_t st_rdev; /* device type, for special file inode */
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
off_t st_size; /* file size, in bytes */
quad_t st_blocks; /* blocks allocated for file */
u_long st_blksize;/* optimal file sys I/O ops blocksize */
u_long st_flags; /* user defined flags for file */
u_long st_gen; /* file generation number */
};
Unfortunately, I still cannot map each field to the output of stat
, for example:
$ stat Cargo.toml
16777220 9094681422 -rw-r--r-- 1 tonytonyjan staff 0 109 "Jan 19 10:05:13 2019" "Dec 31 17:52:29 2018" "Dec 31 17:52:29 2018" "Dec 14 16:32:26 2018" 4096 8 0 Cargo.toml
- 16777220 - device inode resides on
- 9094681422 - inode
- -rw-r--r-- - protection mode
- 1 - number of hard links
- tonytonyjan - user
- staff - group
- 0 - Not sure. Is it device type?
- 109 - size
- "Jan 19 10:05:13 2019" - last access
- "Dec 31 17:52:29 2018" - last modification
- "Dec 31 17:52:29 2018" - last file statu change
- "Dec 14 16:32:26 2018" - There should have been only 3 timestamps, what is this?
- 4096 - file size in bytes
- 8 - blocks allocated for file
- 0 - optimal file sys I/O ops blocksize? user defined flags? or file generation number?
- Cargo.toml - filename
My questions:
- Does the first
0
stand forst_rdev
? - What is the difference between
st_dev
andst_rdev
? - What does the seconds
0
stand for? - Manybe I did not find the correct
man
page (neitherman stat
norman lstat
). Is there any official documentation which explan eachstat
field in detail? Where can I find it?