1 #include "stdio_impl.h"
6 FILE *fopen(const char *restrict filename
, const char *restrict mode
)
12 /* Check for valid initial mode character */
13 if (!strchr("rwa", *mode
)) {
18 /* Compute the flags to pass to open() */
19 flags
= __fmodeflags(mode
);
21 fd
= sys_open(filename
, flags
, 0666);
23 if (flags
& O_CLOEXEC
)
24 __syscall(SYS_fcntl
, fd
, F_SETFD
, FD_CLOEXEC
);
26 f
= __fdopen(fd
, mode
);
29 __syscall(SYS_close
, fd
);