Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: fusl/src/stdio/fopen.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/stdio/fmemopen.c ('k') | fusl/src/stdio/fprintf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "stdio_impl.h"
2 #include <fcntl.h>
3 #include <string.h>
4 #include <errno.h>
5
6 FILE *fopen(const char *restrict filename, const char *restrict mode)
7 {
8 FILE *f;
9 int fd;
10 int flags;
11
12 /* Check for valid initial mode character */
13 if (!strchr("rwa", *mode)) {
14 errno = EINVAL;
15 return 0;
16 }
17
18 /* Compute the flags to pass to open() */
19 flags = __fmodeflags(mode);
20
21 fd = sys_open(filename, flags, 0666);
22 if (fd < 0) return 0;
23 if (flags & O_CLOEXEC)
24 __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
25
26 f = __fdopen(fd, mode);
27 if (f) return f;
28
29 __syscall(SYS_close, fd);
30 return 0;
31 }
32
33 LFS64(fopen);
OLDNEW
« no previous file with comments | « fusl/src/stdio/fmemopen.c ('k') | fusl/src/stdio/fprintf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698