读取文件的inode,然后把inode中的各种文件属性填入一个strcut stat结构体传出给调用者。stat(1)命令是基于stat函数实现的。stat需要根据传入文件的路径找到inode。
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
int lstat(const char *path, struct stat *buf);