调用open函数时,是以有效用户而不是实际用户的身份去验证进程对要打开的文件的读写权限.但是有时候我们想知道的是实际用户而非有效用户对某一文件的权限,此时就要用到access函数. 函数原型:int access(const char* pathname, int mode); int faccessat(int fd, const char* pathname, int mode, int flag); 所需库:#include<unistd.h> 返回值:如果文件具有指定的访问权
一.stat.fstat.fstatat.lstat函数 函数的原型为: #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,