xv6, line by line
kernel/fcntl.h

kernel/fcntl.h

C header · 5 lines · annotated 100% · kernel · upstream

Included by 14 fileskernel/sysfile.c, user/cat.c, user/dorphan.c, user/forphan.c, user/grep.c, user/grind.c, user/init.c, user/logstress.c, user/ls.c, user/sh.c, user/stressfs.c, user/ulib.c, user/usertests.c, user/wc.c
About this file

The flags a program passes as the second argument of open, shared by the kernel (sys_open in kernel/sysfile.c) and user programs, which include it as kernel/fcntl.h. A call combines one access mode with any of the extra flags using |, as in open("out", O_CREATE | O_WRONLY | O_TRUNC).

Read next: sys_open, which interprets them.

1#define O_RDONLY 0x000
2#define O_WRONLY 0x001
3#define O_RDWR 0x002
4#define O_CREATE 0x200
5#define O_TRUNC 0x400