乱读天书, 不求甚解
周祎骏的个人云笔记
Toggle navigation
乱读天书, 不求甚解
主页
Linux:系统配置
Linux:用户管理
Linux:优化排错
Linux:进程调度
Linux:文件系统
Linux:网络
Linux:系统服务
Linux:安全
Linux:内核
容器:Docker
容器:containerd
容器编排:Kubernetes
IAC:Terraform
大数据:Hadoop
大数据:Zookeeper
大数据:Hbase
消息队列:rsyslog
消息队列:kafka
数据库:MySQL
数据库:MongoDB
搜索引擎:Elasticsearch
时序数据库:OpenTSDB
网站服务:Nginx
编程:Bash
编程:Perl
编程:Python
编程:C
编程:JAVA
编程:Rust
版本控制:gitlab
知识管理:docusaurus
常用小工具
关于我
标签
C 2.06 函数库sys/stat.h
2018-06-17 08:23:04
58
0
0
admin
> 文件系统文件的属性及操作 *有一些数据类型用到了sys/types.h中定义的,所以以下两句话总是同时出现: ``` #include <sys/types.h> #include <sys/stat.h> ``` 函数: **mode_t umask(mode_t mask)** 修改umask值,并返回原来的mask值。 ``` umask(0002); //修改当前进程的umask ``` **int chmod(const char *filename, mode_t mode)** 失败返回-1 **int fchmod(int fd; mode_t mode)** 失败返回-1 **int mkfifo(const char *pathname, mode_t mode)** 创建管道文件 *** stat 数据结构 **int stat(char *filename,struct stat *buf)** 失败返回-1 **int fstat(int fd,struct stat *buf)** 失败返回-1 **int lstat(char *filename,struct stat *buf)** 失败返回-1 如果有软链接的话,lstat 会读取链接本身的信息,其它会读取链接指向的文件的信息。 ``` struct stat /* inode information returned by stat */ { dev_t st_dev; /* device of inode */ ino_t st_ino; /* inode number */ short st_mode; /* mode bits S_IFREG 普通文件 判断宏 S_ISREG() S_IFDIR 目录 判断宏 S_ISDIR() S_IFCHR 字符设备文件 判断宏 S_ISCHR() S_IFBLK 块设备文件 判断宏 S_ISBLK() S_IFFIFO 管道 判断宏 S_ISFIFO() S_IFSLNK 符号链接文件 判断宏 S_ISLNK() S_IFSOCK socket文件 判断宏 S_ISSOCK() */ short st_nlink; /* number of links to file */ short st_uid; /* owners user id */ short st_gid; /* owners group id */ dev_t st_rdev; /* for special files */ off_t st_size; /* file size in characters */ time_t st_atime; /* time last accessed */ time_t st_mtime; /* time last modified */ time_t st_ctime; /* time originally created */ }; ```
上一篇:
C 2.05 函数库stgarg.h
下一篇:
C 2.07 Linux函数库fcntl
文档导航