Permission | Purpose |
---|---|
O_RDONLY |
Open for reading only |
O_WRONLY |
Open for writing only |
O_RDWR |
Open for reading and writing |
O_NONBLOCK |
Do not block on opening while waiting for data |
O_CREAT |
Create the file if it does not exist; requires passing mode_t argument |
O_TRUNC |
Truncate to size 0 |
O_EXCL |
Error if O_CREAT and the file exists |
Table 2.2: Flags for opening files
Name | Bitmask | Description |
---|---|---|
S_IRUSR |
000400 |
Read (user) |
S_IWUSR |
000200 |
Write (user) |
S_IXUSR |
000100 |
Execute (user) |
S_IRGRP |
000040 |
Read (group) |
S_IWGRP |
000020 |
Write (group) |
S_IXGRP |
000010 |
Execute (group) |
S_IROTH |
000004 |
Read (other) |
S_IWOTH |
000002 |
Write (other) |
S_IXOTH |
000001 |
Execute (other) |
Name | Bitmask | Description |
---|---|---|
S_IFIFO |
010000 |
Named pipe (IPC) |
S_IFCHR |
020000 |
Character device (terminal) |
S_IFDIR |
040000 |
Directory file type |
S_IFBLK |
006000 |
Block device (disk drive) |
S_IFREG |
100000 |
Regular file type |
S_IFLNK |
120000 |
Symbolic link |
S_IFSOCK |
140000 |
Socket (IPC, networks) |
S_ISUID |
004000 |
Setuid (SUID ) bit |
S_ISGID |
002000 |
Setgid (SGID ) bit |
S_ISVTX |
001000 |
Sticky bit |
Table 2.3: Bitmasks used in the st_mode field