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().
阅读(511) | 评论(0) | 转发(0) |