diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-05-08 19:41:25 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-05-08 19:41:25 -0700 |
commit | f8e0ad9812f5e3fe0e7006061b1d5f9f67a80325 (patch) | |
tree | 126c2ae2f3f2e23388eafb7acae128d5ca8dedce | |
parent | 115fc7e79d6becb1e14f98ef1c6f15c27b6f3d10 (diff) | |
download | klibc-f8e0ad9812f5e3fe0e7006061b1d5f9f67a80325.tar.gz |
[klibc] Make __parse_open_mode handle "e" for O_CLOEXEC
glibc now supports an "e" for O_CLOEXEC; this makes sense so follow
suit.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | usr/klibc/stdio/fxopen.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/usr/klibc/stdio/fxopen.c b/usr/klibc/stdio/fxopen.c index 5f9d61d1d6edc..7e8608ffc5062 100644 --- a/usr/klibc/stdio/fxopen.c +++ b/usr/klibc/stdio/fxopen.c @@ -15,33 +15,36 @@ struct _IO_file __stdio_headnode = .next = &__stdio_headnode, }; -/* This depends on O_RDONLY == 0, O_WRONLY == 1, O_RDWR == 2 */ int __parse_open_mode(const char *mode) { - int plus = 0; - int flags = O_RDONLY; + int rwflags = O_RDONLY; + int crflags = 0; + int eflag = 0; while (*mode) { switch (*mode++) { case 'r': - flags = O_RDONLY; + rwflags = O_RDONLY; + crflags = 0; break; case 'w': - flags = O_WRONLY | O_CREAT | O_TRUNC; + rwflags = O_WRONLY; + crflags = O_CREAT | O_TRUNC; break; case 'a': - flags = O_WRONLY | O_CREAT | O_APPEND; + rwflags = O_WRONLY; + crflags = O_CREAT | O_APPEND; + break; + case 'e': + eflag = O_CLOEXEC; break; case '+': - plus = 1; + rwflags = O_RDWR; break; } } - if (plus) - flags = (flags & ~(O_RDONLY | O_WRONLY)) | O_RDWR; - - return flags; + return rwflags | crflags | eflag; } FILE *__fxopen(int fd, int flags, int close_on_err) |