First, read file meta data
int stat (const char *path, struct stat *buf);
int fstat (int fd, struct stat *buf);
int Lstat (const char *path, struct stat *buf);
Stat () Stats The file pointed to by path and fills in BUF.
Lstat () is identical to stat (), except this if path is a symbolic link, then the link itself be stat-ed, not the file th At it refers to.
Fstat () is identical to stat (), except which the file to being stat-ed is specified by the file descriptor FD.
Second, stat structural body
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 file system I/O
blkcnt_t st_blocks; /* Number of 512B 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 * *
};