APUE(2)
Chapter4
这章主要讲文件和目录,上一章针对的是普通文件的I/O,这章是各种奇奇怪怪的文件I/O。
各种stat
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);
主要是会取得一个记录了各种信息的struct stat
permission
测试顺序
- uid是否为0
- uid与owner符合,判断owner permission
- gid与group owner符合,判断group permission
- 判断other permission
access
int access(const char* pathname,int mode);
int faccessat(int fd,const char* pathname,int mode,int flag);
return true if accessed
umask
mode_t umask(mode_t cmask);
return mode_t is the previous umask
各种chmod
int chmod(const char* pathname,mode_t mode);
int fchmod(int fd,mode_t mode);
int fchmodat(int fd,const char *pathname,mode_t mode,int flag);
To change the permission bits of the file,the effective ID of the process must be equal to the owner ID of the file,or the process must have superuser permissions.
各种chown
int chown(const char* pathname,uid_t owner,git_t group);
int fchown(int fd,uid_t owner,git_t group);
int fchownat(int fd,const char* pathname,uid_t owner,git_t group,int flag);
int lchown(const char* pathname,uid_t owner,git_t group);
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Kawhicurry's Blog!
评论