Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250502
  • 博文数量: 65
  • 博客积分: 2599
  • 博客等级: 少校
  • 技术积分: 710
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-04 10:49
文章分类

全部博文(65)

文章存档

2015年(4)

2013年(2)

2012年(4)

2011年(51)

2010年(4)

分类: LINUX

2011-12-15 14:07:41

1. file protection bit
Usually we use it referring to mode_t variable when create files,
eg open() with O_CREATE or create() function. And we can use it to
identify the protection mode of a file via fcntl() function.

/* File protection bits.*/
S_IRWXU  00700 user (file owner) has read, write and execute permission
S_IRUSR  00400 user has read permission
S_IWUSR  00200 user has write permission
S_IXUSR  00100 user has execute permission
S_IRWXG  00070 group has read, write and execute permission
S_IRGRP  00040 group has read permission
S_IWGRP  00020 group has write permission
S_IXGRP  00010 group has execute permission
S_IRWXO  00007 others have read, write and execute permission
S_IROTH  00004 others have read permission
S_IWOTH  00002 others have write permission
S_IXOTH  00001 others have execute permission

Note: the real protection bit is (mode_t & ~umask).

2. file descriptor flags
FD_CLOEXEC : close on exec
this is the only fd flags.

3. file status flags
#define O_ACCMODE       0003     /* get access mode */
#define O_RDONLY         00     /* open for reading only */
#define O_WRONLY         01     /* open for writing only */
#define O_RDWR             02     /* open for reading and writing */
#define O_CREAT           0100        /* not fcntl, creating file, must providing mode_t */
#define O_EXCL           0200        /* not fcntl, should use with O_CREATE. Make sure of creating file. */
#define O_NOCTTY       0400        /* not fcntl, If pathname refers to a terminal device,it will not
                                       become the process's controlling terminal even if the process
                                       does not have one. */
#define O_TRUNC          01000        /* not fcntl, if have write right, change length to 0 */
#define O_APPEND      02000     /* append on each write */
#define O_NONBLOCK      04000     /* nonblocking mode */
#define O_NDELAY    O_NONBLOCK
#define O_SYNC           04010000     /* wait for writes to complete (data and attributes) */
#define O_FSYNC         O_SYNC
#define O_ASYNC         020000     /* asynchronous I/O */
Usually we can get and set it via fcntl().
阅读(483) | 评论(0) | 转发(0) |
0

上一篇:C语言宏 使用+调试

下一篇:quickmarks

给主人留下些什么吧!~~