X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffopen.c;h=da17ce8b48dc431d6aa70539bbb136841e8f727d;hb=41d7c77d6a2e74294807d35062e4cd1d48ab72d3;hp=560b77e43cafbf53d69dff50a29491308b4631e6;hpb=400c5e5c8307a2ebe44ef1f203f5a15669f20347;p=musl diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 560b77e4..da17ce8b 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include FILE *fopen(const char *restrict filename, const char *restrict mode) { @@ -13,13 +16,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 (*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;