strcut stat中各成员含义:
通过man手册查询struct stat的具体构成,附上源代码可知,
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 */
};
结构体各个成员表示含义:
st_dev:文件所在磁盘的磁盘的ID号
st_ino:节点编号
st_mode:描述文件的类型和权限
st_nlink:硬链接的数量
st_uid:文件属于用户的ID
st_gid:文件所属用户组ID
st_rdev:如果是设备文件则是设备ID号
st_size:文件大小
st_blksize:文件内容对应的块的大小
st_blocks:文件内容对应得块数量
st_atime:上次访问时间,访问文件的操作会改变该值
st_mtime:上次修改时间,
st_ctime:上次状态改变的时间,对文件的读写将改变该值。
上述众多的结构体成员中,值得细说的还是属于st_mode,它不仅包含的文件的类型,也包含的文件的权限信息。通过在某个目录下运行ls命令,出现一个结果,其中某一行开头的十个字符就是文件的类型和属性。
在linux下,一切皆文件,linux将文件分为7个种类,
普通文件:-
目录文