author | Rich Felker <dalias@aerifal.cx> | 2012年10月24日 21:16:06 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012年10月24日 21:16:06 -0400 |
commit | 892cafff665b44d238e3b664f61ca38dd965cba6 (patch) | |
tree | c65353fe88b0d78025e113b77ed8728a2b4bc8d4 /src/stdio/fopen.c | |
parent | 708c91f4e9be2cfd6d35e71361956e13f3201b85 (diff) | |
download | musl-892cafff665b44d238e3b664f61ca38dd965cba6.tar.gz |
-rw-r--r-- | src/stdio/fopen.c | 9 |
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 03c10cd1..c741aede 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -13,14 +13,7 @@ FILE *fopen(const char *restrict filename, const char *restrict mode) } /* Compute the flags to pass to open() */ - if (strchr(mode, '+')) flags = O_RDWR; - else if (*mode == 'r') flags = O_RDONLY; - else flags = O_WRONLY; - if (strchr(mode, 'x')) flags |= O_EXCL; - if (strchr(mode, 'e')) flags |= O_CLOEXEC; - if (*mode != 'r') flags |= O_CREAT; - if (*mode == 'w') flags |= O_TRUNC; - if (*mode == 'a') flags |= O_APPEND; + flags = __fmodeflags(mode); fd = syscall_cp(SYS_open, filename, flags|O_LARGEFILE, 0666); if (fd < 0) return 0; |