aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-12 15:53:52 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-12 15:53:52 -0700
commit8c7394e34a74aeb35ef6563ebd66f43fba7673b0 (patch)
tree71224f92f8d854a34dacc0386cc2d15db2d56e7f
parent1500f92cb22003471211eab1b37be386231c2138 (diff)
downloadklibc-8c7394e34a74aeb35ef6563ebd66f43fba7673b0.tar.gz
[klibc] f*open: support the glibc 'x' flag
Support the glibc 'x' extension for exclusively opening a file (O_EXCL). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--usr/klibc/stdio/openmode.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr/klibc/stdio/openmode.c b/usr/klibc/stdio/openmode.c
index c3503e450454b6..971237d230f474 100644
--- a/usr/klibc/stdio/openmode.c
+++ b/usr/klibc/stdio/openmode.c
@@ -10,7 +10,7 @@ int __parse_open_mode(const char *mode)
{
int rwflags = O_RDONLY;
int crflags = 0;
- int eflag = 0;
+ int eflags = 0;
while (*mode) {
switch (*mode++) {
@@ -27,7 +27,10 @@ int __parse_open_mode(const char *mode)
crflags = O_CREAT | O_APPEND;
break;
case 'e':
- eflag = O_CLOEXEC;
+ eflags |= O_CLOEXEC;
+ break;
+ case 'x':
+ eflags |= O_EXCL;
break;
case '+':
rwflags = O_RDWR;
@@ -35,5 +38,5 @@ int __parse_open_mode(const char *mode)
}
}
- return rwflags | crflags | eflag;
+ return rwflags | crflags | eflags;
}