UNIX 文件系统基础概念解析
1. 获取文件属性
在 UNIX 系统里,若要获取任意文件类型的属性,可调用 stat() 系统调用。 ls 命令在显示每个文件时就会调用这个系统调用。下面是 stat() 系统调用的接口:
#include <sys/types.h>
#include <sys/stat.h>
int stat(const char *path, struct stat *buf);
调用者需指定要读取属性的文件路径名,所有信息会通过 stat 结构体返回,该结构体定义如下:
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* Inode number / file serial number */
mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Number of links to file */
uid_t st_uid; /* User ID of file */
gid_t st_gid; /* Group ID of file */
dev_t
超级会员免费看
订阅专栏 解锁全文
1535

被折叠的 条评论
为什么被折叠?



