From ebb75f656c0500c28015f4727957d6fa02350b84 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 27 Jan 2015 21:46:33 +0100 Subject: [PATCH] Honor O_EXCL only if O_CREAT. --- ext/inode.cpp | 2 +- kernel/fs/kram.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/inode.cpp b/ext/inode.cpp index a2c7d087..3bd22b75 100644 --- a/ext/inode.cpp +++ b/ext/inode.cpp @@ -390,7 +390,7 @@ Inode* Inode::Open(const char* elem, int flags, mode_t mode) uint32_t inode_id = entry->inode; assert(inode_id); block->Unref(); - if ( flags & O_EXCL ) + if ( (flags & O_CREAT) && (flags & O_EXCL) ) return errno = EEXIST, (Inode*) NULL; if ( (flags & O_DIRECTORY) && file_type != EXT2_FT_UNKNOWN && diff --git a/kernel/fs/kram.cpp b/kernel/fs/kram.cpp index e4f13c41..3ede404c 100644 --- a/kernel/fs/kram.cpp +++ b/kernel/fs/kram.cpp @@ -238,7 +238,7 @@ Ref Dir::open(ioctx_t* ctx, const char* filename, int flags, mode_t mode) size_t child_index = FindChild(filename); if ( child_index != SIZE_MAX ) { - if ( flags & O_EXCL ) + if ( (flags & O_CREATE) && (flags & O_EXCL) ) return errno = EEXIST, Ref(NULL); return children[child_index].inode; }