stat、fstat、fstatat和lstat函数

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结构:


猜你喜欢

转载自blog.csdn.net/aabb7012086/article/details/80632524