1 #include "stdio_impl.h"
7 FILE *fopen(const char *restrict filename, const char *restrict mode)
13 /* Check for valid initial mode character */
14 if (!strchr("rwa", *mode)) {
19 /* Compute the flags to pass to open() */
20 flags = __fmodeflags(mode);
22 fd = sys_open(filename, flags, 0666);
24 if (flags & O_CLOEXEC)
25 __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
27 f = __fdopen(fd, mode);
30 __syscall(SYS_close, fd);