4个stat函数:
#include <sys/stat.h> int stat(const char *restrict pathname, struct stat *restrict buf); int fstat(int fd, struct stat *buf); int lstat(const char *restrict pathname, struct stat *restrict buf); int fstatat(int fd, const char *restrict pathname, struct stat *restrict buf, int flag);
4个函数的返回值:成功返回0,出错返回-1
lstat和stat的区别是当文件是一个符号链接时,返回符号链接的有关信息,而不是符号链接引用文件的相关信息。
stat结构: