long sys_create(const char __user *pathname, int mode)
| |
+---+ +-----------+
| +------------------------+ | O_CREAT=00000100=0x40=64
| |O_CREAT|O_WRONLY|O_TRUNC| | O_RDONLY=0,O_WRONLY=1,O_RDWR=2
| +------------------------+ | O_TRUNC=00001000=0x200=512
+---+ | +--+
| | |
V V V
long sys_open(const char __user *filename, int flags, int mode)
| | |
+--------+ | | +------------+
|AT_FDCWD| | +------------+ |
+--------+ +-----------+ | |
| | | |
V V V V
long do_sys_open(int dfd, const char __user * filename, int flags, int mode)
| | | |
+------------+ V | |
| +------------------------+ | |
| |tmp = getname(filename);| | |
| +------------------------+ | | +-+
+---------------------+ | | | |0|
| +--------------+ | +---+ +-+
| | | | |
V V V V V
struct file *do_filp_open(int dfd, const char *pathname, int open_flag, int mode, int acc_mode)
| | |
+--------------------------+ | V sys-open() for internal routine(open_namei/follow_link...)
| +--------------------------------------+ +---------------+ +--------------------------+
| | +--------------------------------------+ |00 - read-only | |00 - no permissions needed|
| | |flag = open_to_namei_flags(open_flag);| |01 - write-only|----\|01 - read-permission |
| | +--------------------------------------+ |10 - read-write|----/|10 - write-permission |
| | |11 - special | |11 - read-write |
| | +---------------+ +--------------------------+
| |
| +-------------------------+ +-------------+ +--------------------+
+-------------+ | |LOOKUP_PARENT| |struct nameidata nd;|
| | +-------------+ +--------------------+
| | | |
V V V V
int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd)