diff --git a/src/lib/libfs.js b/src/lib/libfs.js index 65674a584ef8b..b317f55d4cbc7 100644 --- a/src/lib/libfs.js +++ b/src/lib/libfs.js @@ -376,9 +376,11 @@ FS.staticInit();`; // return 0 if any user, group or owner bits are set. if (perms.includes('r') && !(node.mode & {{{ cDefs.S_IRUGO }}})) { return {{{ cDefs.EACCES }}}; - } else if (perms.includes('w') && !(node.mode & {{{ cDefs.S_IWUGO }}})) { + } + if (perms.includes('w') && !(node.mode & {{{ cDefs.S_IWUGO }}})) { return {{{ cDefs.EACCES }}}; - } else if (perms.includes('x') && !(node.mode & {{{ cDefs.S_IXUGO }}})) { + } + if (perms.includes('x') && !(node.mode & {{{ cDefs.S_IXUGO }}})) { return {{{ cDefs.EACCES }}}; } return 0; @@ -419,10 +421,8 @@ FS.staticInit();`; if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) { return {{{ cDefs.EBUSY }}}; } - } else { - if (FS.isDir(node.mode)) { - return {{{ cDefs.EISDIR }}}; - } + } else if (FS.isDir(node.mode)) { + return {{{ cDefs.EISDIR }}}; } return 0; }, @@ -432,13 +432,16 @@ 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 }}} | {{{ cDefs.O_CREAT }}}))) { // TODO: check for O_SEARCH? (== search for dir only) + } + var mode = FS.flagsToPermissionString(flags); + if (FS.isDir(node.mode)) { + // opening for write + // TODO: check for O_SEARCH? (== search for dir only) + if (mode !== 'r' || (flags & ({{{ cDefs.O_TRUNC }}} | {{{ cDefs.O_CREAT }}}))) { return {{{ cDefs.EISDIR }}}; } } - return FS.nodePermissions(node, FS.flagsToPermissionString(flags)); + return FS.nodePermissions(node, mode); }, checkOpExists(op, err) { if (!op) { diff --git a/test/codesize/test_codesize_cxx_ctors1.json b/test/codesize/test_codesize_cxx_ctors1.json index 95216d3081c13..1c8129ca845cf 100644 --- a/test/codesize/test_codesize_cxx_ctors1.json +++ b/test/codesize/test_codesize_cxx_ctors1.json @@ -1,10 +1,10 @@ { - "a.out.js": 19664, - "a.out.js.gz": 8146, + "a.out.js": 19602, + "a.out.js.gz": 8132, "a.out.nodebug.wasm": 132844, "a.out.nodebug.wasm.gz": 49884, - "total": 152508, - "total_gz": 58030, + "total": 152446, + "total_gz": 58016, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index 48936da20a1ec..41cd79a8400ca 100644 --- a/test/codesize/test_codesize_cxx_ctors2.json +++ b/test/codesize/test_codesize_cxx_ctors2.json @@ -1,10 +1,10 @@ { - "a.out.js": 19641, - "a.out.js.gz": 8133, + "a.out.js": 19579, + "a.out.js.gz": 8118, "a.out.nodebug.wasm": 132264, "a.out.nodebug.wasm.gz": 49542, - "total": 151905, - "total_gz": 57675, + "total": 151843, + "total_gz": 57660, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index 92eb77122cb42..9be7f7ac3e551 100644 --- a/test/codesize/test_codesize_cxx_except.json +++ b/test/codesize/test_codesize_cxx_except.json @@ -1,10 +1,10 @@ { - "a.out.js": 23325, - "a.out.js.gz": 9127, + "a.out.js": 23263, + "a.out.js.gz": 9109, "a.out.nodebug.wasm": 172774, "a.out.nodebug.wasm.gz": 57405, - "total": 196099, - "total_gz": 66532, + "total": 196037, + "total_gz": 66514, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_except_wasm.json b/test/codesize/test_codesize_cxx_except_wasm.json index 47b46492f6198..e75001f0e9542 100644 --- a/test/codesize/test_codesize_cxx_except_wasm.json +++ b/test/codesize/test_codesize_cxx_except_wasm.json @@ -1,10 +1,10 @@ { - "a.out.js": 19475, - "a.out.js.gz": 8072, + "a.out.js": 19413, + "a.out.js.gz": 8054, "a.out.nodebug.wasm": 148169, "a.out.nodebug.wasm.gz": 55285, - "total": 167644, - "total_gz": 63357, + "total": 167582, + "total_gz": 63339, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_except_wasm_legacy.json b/test/codesize/test_codesize_cxx_except_wasm_legacy.json index 91e7d7962c513..b6507346a16b6 100644 --- a/test/codesize/test_codesize_cxx_except_wasm_legacy.json +++ b/test/codesize/test_codesize_cxx_except_wasm_legacy.json @@ -1,10 +1,10 @@ { - "a.out.js": 19549, - "a.out.js.gz": 8091, + "a.out.js": 19487, + "a.out.js.gz": 8074, "a.out.nodebug.wasm": 145975, "a.out.nodebug.wasm.gz": 54915, - "total": 165524, - "total_gz": 63006, + "total": 165462, + "total_gz": 62989, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_lto.json b/test/codesize/test_codesize_cxx_lto.json index a0ba138c38f43..c1a578dd35d89 100644 --- a/test/codesize/test_codesize_cxx_lto.json +++ b/test/codesize/test_codesize_cxx_lto.json @@ -1,10 +1,10 @@ { - "a.out.js": 19011, - "a.out.js.gz": 7826, + "a.out.js": 18949, + "a.out.js.gz": 7812, "a.out.nodebug.wasm": 102076, "a.out.nodebug.wasm.gz": 39428, - "total": 121087, - "total_gz": 47254, + "total": 121025, + "total_gz": 47240, "sent": [ "a (emscripten_resize_heap)", "b (_setitimer_js)", diff --git a/test/codesize/test_codesize_cxx_mangle.json b/test/codesize/test_codesize_cxx_mangle.json index 30a9a72863718..713ae0455d4c5 100644 --- a/test/codesize/test_codesize_cxx_mangle.json +++ b/test/codesize/test_codesize_cxx_mangle.json @@ -1,10 +1,10 @@ { - "a.out.js": 23375, - "a.out.js.gz": 9147, + "a.out.js": 23313, + "a.out.js.gz": 9128, "a.out.nodebug.wasm": 239224, "a.out.nodebug.wasm.gz": 79795, - "total": 262599, - "total_gz": 88942, + "total": 262537, + "total_gz": 88923, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_noexcept.json b/test/codesize/test_codesize_cxx_noexcept.json index 6df78e553c6c6..2a1a664f97065 100644 --- a/test/codesize/test_codesize_cxx_noexcept.json +++ b/test/codesize/test_codesize_cxx_noexcept.json @@ -1,10 +1,10 @@ { - "a.out.js": 19664, - "a.out.js.gz": 8146, + "a.out.js": 19602, + "a.out.js.gz": 8132, "a.out.nodebug.wasm": 134851, "a.out.nodebug.wasm.gz": 50712, - "total": 154515, - "total_gz": 58858, + "total": 154453, + "total_gz": 58844, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_file_preload.expected.js b/test/codesize/test_codesize_file_preload.expected.js index 1030cbe8fad3a..089058d9e9f84 100644 --- a/test/codesize/test_codesize_file_preload.expected.js +++ b/test/codesize/test_codesize_file_preload.expected.js @@ -1638,9 +1638,11 @@ var FS = { // return 0 if any user, group or owner bits are set. if (perms.includes("r") && !(node.mode & 292)) { return 2; - } else if (perms.includes("w") && !(node.mode & 146)) { + } + if (perms.includes("w") && !(node.mode & 146)) { return 2; - } else if (perms.includes("x") && !(node.mode & 73)) { + } + if (perms.includes("x") && !(node.mode & 73)) { return 2; } return 0; @@ -1680,10 +1682,8 @@ var FS = { if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) { return 10; } - } else { - if (FS.isDir(node.mode)) { - return 31; - } + } else if (FS.isDir(node.mode)) { + return 31; } return 0; }, @@ -1693,13 +1693,16 @@ var FS = { } if (FS.isLink(node.mode)) { return 32; - } else if (FS.isDir(node.mode)) { - if (FS.flagsToPermissionString(flags) !== "r" || (flags & (512 | 64))) { - // TODO: check for O_SEARCH? (== search for dir only) + } + var mode = FS.flagsToPermissionString(flags); + if (FS.isDir(node.mode)) { + // opening for write + // TODO: check for O_SEARCH? (== search for dir only) + if (mode !== "r" || (flags & (512 | 64))) { return 31; } } - return FS.nodePermissions(node, FS.flagsToPermissionString(flags)); + return FS.nodePermissions(node, mode); }, checkOpExists(op, err) { if (!op) { diff --git a/test/codesize/test_codesize_file_preload.json b/test/codesize/test_codesize_file_preload.json index f3f9b8b4c2060..63eb5b217a6c2 100644 --- a/test/codesize/test_codesize_file_preload.json +++ b/test/codesize/test_codesize_file_preload.json @@ -1,10 +1,10 @@ { - "a.out.js": 22571, - "a.out.js.gz": 9339, + "a.out.js": 22509, + "a.out.js.gz": 9332, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 24252, - "total_gz": 10299, + "total": 24190, + "total_gz": 10292, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_files_js_fs.json b/test/codesize/test_codesize_files_js_fs.json index 394c9faa62526..d9f4d69cd1c85 100644 --- a/test/codesize/test_codesize_files_js_fs.json +++ b/test/codesize/test_codesize_files_js_fs.json @@ -1,10 +1,10 @@ { - "a.out.js": 18283, - "a.out.js.gz": 7464, + "a.out.js": 18220, + "a.out.js.gz": 7450, "a.out.nodebug.wasm": 381, "a.out.nodebug.wasm.gz": 260, - "total": 18664, - "total_gz": 7724, + "total": 18601, + "total_gz": 7710, "sent": [ "a (fd_write)", "b (fd_read)", diff --git a/test/codesize/test_codesize_hello_dylink.json b/test/codesize/test_codesize_hello_dylink.json index e3faee66565a1..2b1d5222fed76 100644 --- a/test/codesize/test_codesize_hello_dylink.json +++ b/test/codesize/test_codesize_hello_dylink.json @@ -1,10 +1,10 @@ { - "a.out.js": 26705, - "a.out.js.gz": 11396, + "a.out.js": 26642, + "a.out.js.gz": 11380, "a.out.nodebug.wasm": 17730, "a.out.nodebug.wasm.gz": 8957, - "total": 44435, - "total_gz": 20353, + "total": 44372, + "total_gz": 20337, "sent": [ "__syscall_stat64", "emscripten_resize_heap", diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 6cef4a1d3e01e..c4b3e1e6026d8 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 244882, + "a.out.js": 244819, "a.out.nodebug.wasm": 577863, - "total": 822745, + "total": 822682, "sent": [ "IMG_Init", "IMG_Load",