宏:整数常量 O_ACCMODE
2016-03-30 15:19
302 查看
Macro: int O_ACCMODE
This macro stands for a mask that can be bitwise-ANDed with the file status flag value to produce a value representing the file access mode. The mode will be O_RDONLY, O_WRONLY, or O_RDWR. (In the GNU system it could also be zero, and it never includes the O_EXEC bit.)
翻译:
这个宏作为一个掩码以与文件状态标识值做AND位运算,产生一个表示文件访问模式的值。这模式将是O_RDONLY, O_WRONLY, 或 O_RDWR(在GNU系统中,也可能是零,并且从不包括 O_EXEC 位)
O_ACCMODE<0003>:读写文件操作时,用于取出flag的低2位
O_RDONLY<00>:只读打开
O_WRONLY<01>:只写打开
O_RDWR<02>:读写打开
原文链接:
/article/9850803.html
This macro stands for a mask that can be bitwise-ANDed with the file status flag value to produce a value representing the file access mode. The mode will be O_RDONLY, O_WRONLY, or O_RDWR. (In the GNU system it could also be zero, and it never includes the O_EXEC bit.)
翻译:
这个宏作为一个掩码以与文件状态标识值做AND位运算,产生一个表示文件访问模式的值。这模式将是O_RDONLY, O_WRONLY, 或 O_RDWR(在GNU系统中,也可能是零,并且从不包括 O_EXEC 位)
O_ACCMODE<0003>:读写文件操作时,用于取出flag的低2位
O_RDONLY<00>:只读打开
O_WRONLY<01>:只写打开
O_RDWR<02>:读写打开
#include "apue.h" #include <fcntl.h> int main(int argc, char *argv[]) { int val; if (argc != 2) err_quit("usage: a.out <descriptor#>"); if ((val = fcntl(atoi(argv[1]), F_GETFL, 0)) < 0) err_sys("fcntl error for fd %d", atoi(argv[1])); switch (val & O_ACCMODE) { case O_RDONLY: printf("read only"); break; case O_WRONLY: printf("write only"); break; case O_RDWR: printf("read write"); break; default: err_dump("unknown access mode"); } if (val & O_APPEND) printf(", append"); if (val & O_NONBLOCK) printf(", nonblocking"); #if defined(O_SYNC) if (val & O_SYNC) printf(", synchronous writes"); #endif #if !defined(_POSIX_C_SOURCE) && defined(O_FSYNC) if (val & O_FSYNC) printf(", synchronous writes"); #endif putchar('/n'); exit(0); }
原文链接:
/article/9850803.html
相关文章推荐
- [leetcode] 339. Nested List Weight Sum 解题报告
- 【转】有关onpropertychange事件
- 正则表达式,验证文件上传类型
- 我所知道的云计算
- Glide与OkHttp3集成
- 2016sdau课程练习专题一 1006 problemG
- Unity ZTest 深度测试 & ZWrite 深度写入
- android 数据库更新
- 常见Android App错误说明
- SQL中Group By的使用
- javascript 微信企业号APP应用URL转换成PC端可正常访问的URL
- 创建和使用Android Library工程
- redis配置文件redis.conf详细说明
- 嵌套循环问题
- lightoj 1126 - Building Twin Towers DP
- B树和B+树
- java过滤器-双向过滤
- Quartz任务调度器及与Spring的整合使用
- centos7基本环境搭建
- An Overview of Complex Event Processing2