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
23 changes: 13 additions & 10 deletions src/lib/libfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
},
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors1.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors2.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm_legacy.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_lto.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_mangle.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_noexcept.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 13 additions & 10 deletions test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
},
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_file_preload.json
Original file line number Diff line number Diff line change
@@ -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)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_files_js_fs.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down