Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ FS.staticInit();
if (FS.isLink(node.mode)) {
return {{{ cDefs.ELOOP }}};
} else if (FS.isDir(node.mode)) {
if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write
(flags & {{{ cDefs.O_TRUNC }}})) { // TODO: check for O_SEARCH? (== search for dir only)
if (FS.flagsToPermissionString(flags) !== 'r' // opening for write
|| (flags & ({{{ cDefs.O_TRUNC }}} | {{{ cDefs.O_CREAT }}}))) { // TODO: check for O_SEARCH? (== search for dir only)
return {{{ cDefs.EISDIR }}};
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/lib/wasmfs/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static __wasi_fd_t doOpen(path::ParsedParent parsed,
return -EEXIST;
}

if (child->is<Directory>() && accessMode != O_RDONLY) {
if (child->is<Directory>() && (accessMode != O_RDONLY || (flags & O_CREAT))) {
return -EISDIR;
}

Expand Down
2 changes: 1 addition & 1 deletion test/fcntl/test_fcntl_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void test() {
if ((flags & O_CREAT) && (flags & O_EXCL)) {
assert(!success);
assert(errno == EEXIST);
} else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/) {
} else if ((flags & O_TRUNC) || i != 0 /*mode != O_RDONLY*/ || (flags & O_CREAT)) {
assert(!success);
assert(errno == EISDIR);
} else {
Expand Down
16 changes: 8 additions & 8 deletions test/fcntl/test_fcntl_open.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,1
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,1
Expand Down Expand Up @@ -139,8 +139,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,9
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,9
Expand Down Expand Up @@ -259,8 +259,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,17
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,17
Expand Down Expand Up @@ -379,8 +379,8 @@ errno: 0
st_mode: 0100000

EXISTING FOLDER 0,25
success: 1
errno: 0
success: 0
errno: 31
st_mode: 040000

NON-EXISTING 0,25
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8407
8408
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8390
8392
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9411
9413
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8373
8374
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8373
8374
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8404
8406
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9416
9417
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8407
8408
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7702
7704
1 change: 1 addition & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5543,6 +5543,7 @@ def test_fcntl(self):
self.add_pre_run("FS.createDataFile('/', 'test', 'abcdef', true, true, false);")
self.do_run_in_out_file_test('fcntl/test_fcntl.c')

@also_with_nodefs_both
def test_fcntl_open(self):
self.do_run_in_out_file_test('fcntl/test_fcntl_open.c')

Expand Down
Loading