Honor O_EXCL only if O_CREAT.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-01-27 21:46:33 +01:00
parent 4f7c5ebdd3
commit ebb75f656c
2 changed files with 2 additions and 2 deletions

View File

@ -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 &&

View File

@ -238,7 +238,7 @@ Ref<Inode> 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<Inode>(NULL);
return children[child_index].inode;
}