X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fstdio%2Ffopen.c;h=c741aede152d55e076fb564ba6320a6918d65e5d;hp=03c10cd16c9a3436906b3d25356395719d118e3a;hb=892cafff665b44d238e3b664f61ca38dd965cba6;hpb=708c91f4e9be2cfd6d35e71361956e13f3201b85 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;