From fe1e70e6c1927ba04cb9e34df1ec871310024637 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 10 Jan 2025 16:54:18 +0100 Subject: [PATCH 1/7] [FS] Make fstat work on file descriptors with no name in memfs This makes fstat work on anonymous memfs file descriptors. It is split off from #23058. --- src/lib/libfs.js | 62 +++++++++++++++++++++++++++++++++++------------ test/test_core.py | 7 +++--- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/lib/libfs.js b/src/lib/libfs.js index e446b5791d060..9821a72d762f3 100644 --- a/src/lib/libfs.js +++ b/src/lib/libfs.js @@ -487,6 +487,24 @@ FS.staticInit(); stream.stream_ops?.dup?.(stream); return stream; }, + streamGetAttr(stream) { + var node = stream.node; + var res = stream.stream_ops?.getattr?.(stream) ?? node.node_ops?.getattr?.(node); + if (res) { + return res; + } + throw new FS.ErrnoError({{{ cDefs.EPERM }}}); + }, + streamSetAttr(stream, attr) { + var node = stream.node; + var set; + if (set = stream.stream_ops.setattr) { + return set(stream, attr); + } else if (set = node.node_ops.setattr) { + return set(node, attr); + } + throw new FS.ErrnoError({{{ cDefs.EPERM }}}); + }, // // devices @@ -966,7 +984,8 @@ FS.staticInit(); return getattr(node); }, fstat(fd) { - return FS.stat(FS.getStreamChecked(fd).path); + var stream = FS.getStreamChecked(fd); + return FS.streamGetAttr(stream); }, lstat(path) { return FS.stat(path, true); @@ -991,7 +1010,10 @@ FS.staticInit(); }, fchmod(fd, mode) { var stream = FS.getStreamChecked(fd); - FS.chmod(stream.node, mode); + FS.streamSetAttr(stream, { + mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (stream.node.mode & ~{{{ cDefs.S_IALLUGO }}}), + ctime: Date.now() + }); }, chown(path, uid, gid, dontFollow) { var node; @@ -1013,7 +1035,22 @@ FS.staticInit(); }, fchown(fd, uid, gid) { var stream = FS.getStreamChecked(fd); - FS.chown(stream.node, uid, gid); + FS.streamSetAttr(stream, { + timestamp: Date.now() + // we ignore the uid / gid for now + }); + }, + truncateChecks(node) { + if (FS.isDir(node.mode)) { + throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); + } + if (!FS.isFile(node.mode)) { + throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); + } + var errCode = FS.nodePermissions(node, 'w'); + if (errCode) { + throw new FS.ErrnoError(errCode); + } }, truncate(path, len) { if (len < 0) { @@ -1026,16 +1063,7 @@ FS.staticInit(); } else { node = path; } - if (FS.isDir(node.mode)) { - throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); - } - if (!FS.isFile(node.mode)) { - throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); - } - var errCode = FS.nodePermissions(node, 'w'); - if (errCode) { - throw new FS.ErrnoError(errCode); - } + FS.truncateChecks(node); var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); setattr(node, { size: len, @@ -1044,10 +1072,14 @@ FS.staticInit(); }, ftruncate(fd, len) { var stream = FS.getStreamChecked(fd); - if ((stream.flags & {{{ cDefs.O_ACCMODE }}}) === {{{ cDefs.O_RDONLY}}}) { + if (len < 0 || (stream.flags & {{{ cDefs.O_ACCMODE }}}) === {{{ cDefs.O_RDONLY}}}) { throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); } - FS.truncate(stream.node, len); + FS.truncateChecks(stream.node); + FS.streamSetAttr(stream, { + size: len, + timestamp: Date.now() + }); }, utime(path, atime, mtime) { var lookup = FS.lookupPath(path, { follow: true }); diff --git a/test/test_core.py b/test/test_core.py index ad64bda589ce2..f38eb27f25ac7 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5845,10 +5845,9 @@ def test_fs_64bit(self): @crossplatform @with_all_fs def test_fs_stat_unnamed_file_descriptor(self): - noderawfs = '-DNODERAWFS' in self.emcc_args - wasmfs = self.get_setting('WASMFS') - if not (noderawfs or wasmfs): - self.skipTest('TODO: doesnt work in memfs or nodefs') + nodefs = '-DNODEFS' in self.emcc_args + if nodefs: + self.skipTest('TODO: doesnt work in nodefs') self.do_runf('fs/test_stat_unnamed_file_descriptor.c', 'success') @requires_node From 0ff1aa0fad08b8aa7b2bf391ca09c2b9d8084642 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 22 Jan 2025 19:43:44 +0100 Subject: [PATCH 2/7] Rebaseline --- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_legacy.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/codesize/test_codesize_minimal_pthreads.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index a3b5de60e54aa..59ec2c640a663 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129218 +129211 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 0ee50d8f96ee0..37ec3b55a7a82 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128630 +128623 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 1bae0e2d633b9..5dab383a3c420 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -170886 +170879 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index b122612579300..c7d57a3be3df7 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -144715 +144708 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size index cdbcd17b502d1..28cf96ad77953 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size @@ -1 +1 @@ -142169 +142162 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 8e8b38b5c13b0..004d7d333c79a 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232731 +232724 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index 232be2fc5f578..c0e3f17ce269c 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131781 +131774 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index b592a30c75210..3b73c05a4a345 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169188 +169181 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index 96b0a1d19abf4..aa9255e00128e 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -15113 +15101 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.size b/test/other/codesize/test_codesize_minimal_pthreads.size index 0f60aa5d0b843..5f7ea76a0569f 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.size +++ b/test/other/codesize/test_codesize_minimal_pthreads.size @@ -1 +1 @@ -19405 +19394 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index 96b0a1d19abf4..aa9255e00128e 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -15113 +15101 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index 59029a8227a5f..e15b709b7d237 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -12194 +12182 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index 96b0a1d19abf4..aa9255e00128e 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -15113 +15101 From 7869eda0d686e2eef5becbb645f7d125515f45f4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 22 Jan 2025 21:47:24 +0100 Subject: [PATCH 3/7] Revert "Rebaseline" This reverts commit 0ff1aa0fad08b8aa7b2bf391ca09c2b9d8084642. --- test/other/codesize/test_codesize_cxx_ctors1.size | 2 +- test/other/codesize/test_codesize_cxx_ctors2.size | 2 +- test/other/codesize/test_codesize_cxx_except.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.size | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_legacy.size | 2 +- test/other/codesize/test_codesize_cxx_mangle.size | 2 +- test/other/codesize/test_codesize_cxx_noexcept.size | 2 +- test/other/codesize/test_codesize_cxx_wasmfs.size | 2 +- test/other/codesize/test_codesize_hello_O0.size | 2 +- test/other/codesize/test_codesize_minimal_pthreads.size | 2 +- test/other/test_unoptimized_code_size.wasm.size | 2 +- test/other/test_unoptimized_code_size_no_asserts.wasm.size | 2 +- test/other/test_unoptimized_code_size_strict.wasm.size | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.size b/test/other/codesize/test_codesize_cxx_ctors1.size index 59ec2c640a663..a3b5de60e54aa 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.size +++ b/test/other/codesize/test_codesize_cxx_ctors1.size @@ -1 +1 @@ -129211 +129218 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.size b/test/other/codesize/test_codesize_cxx_ctors2.size index 37ec3b55a7a82..0ee50d8f96ee0 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.size +++ b/test/other/codesize/test_codesize_cxx_ctors2.size @@ -1 +1 @@ -128623 +128630 diff --git a/test/other/codesize/test_codesize_cxx_except.size b/test/other/codesize/test_codesize_cxx_except.size index 5dab383a3c420..1bae0e2d633b9 100644 --- a/test/other/codesize/test_codesize_cxx_except.size +++ b/test/other/codesize/test_codesize_cxx_except.size @@ -1 +1 @@ -170879 +170886 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.size b/test/other/codesize/test_codesize_cxx_except_wasm.size index c7d57a3be3df7..b122612579300 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm.size @@ -1 +1 @@ -144708 +144715 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size index 28cf96ad77953..cdbcd17b502d1 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size +++ b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.size @@ -1 +1 @@ -142162 +142169 diff --git a/test/other/codesize/test_codesize_cxx_mangle.size b/test/other/codesize/test_codesize_cxx_mangle.size index 004d7d333c79a..8e8b38b5c13b0 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.size +++ b/test/other/codesize/test_codesize_cxx_mangle.size @@ -1 +1 @@ -232724 +232731 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.size b/test/other/codesize/test_codesize_cxx_noexcept.size index c0e3f17ce269c..232be2fc5f578 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.size +++ b/test/other/codesize/test_codesize_cxx_noexcept.size @@ -1 +1 @@ -131774 +131781 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.size b/test/other/codesize/test_codesize_cxx_wasmfs.size index 3b73c05a4a345..b592a30c75210 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.size +++ b/test/other/codesize/test_codesize_cxx_wasmfs.size @@ -1 +1 @@ -169181 +169188 diff --git a/test/other/codesize/test_codesize_hello_O0.size b/test/other/codesize/test_codesize_hello_O0.size index aa9255e00128e..96b0a1d19abf4 100644 --- a/test/other/codesize/test_codesize_hello_O0.size +++ b/test/other/codesize/test_codesize_hello_O0.size @@ -1 +1 @@ -15101 +15113 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.size b/test/other/codesize/test_codesize_minimal_pthreads.size index 5f7ea76a0569f..0f60aa5d0b843 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.size +++ b/test/other/codesize/test_codesize_minimal_pthreads.size @@ -1 +1 @@ -19394 +19405 diff --git a/test/other/test_unoptimized_code_size.wasm.size b/test/other/test_unoptimized_code_size.wasm.size index aa9255e00128e..96b0a1d19abf4 100644 --- a/test/other/test_unoptimized_code_size.wasm.size +++ b/test/other/test_unoptimized_code_size.wasm.size @@ -1 +1 @@ -15101 +15113 diff --git a/test/other/test_unoptimized_code_size_no_asserts.wasm.size b/test/other/test_unoptimized_code_size_no_asserts.wasm.size index e15b709b7d237..59029a8227a5f 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.wasm.size +++ b/test/other/test_unoptimized_code_size_no_asserts.wasm.size @@ -1 +1 @@ -12182 +12194 diff --git a/test/other/test_unoptimized_code_size_strict.wasm.size b/test/other/test_unoptimized_code_size_strict.wasm.size index aa9255e00128e..96b0a1d19abf4 100644 --- a/test/other/test_unoptimized_code_size_strict.wasm.size +++ b/test/other/test_unoptimized_code_size_strict.wasm.size @@ -1 +1 @@ -15101 +15113 From 99207da1dc7666ccd99c90141fa82d2070029dc7 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 22 Jan 2025 21:47:43 +0100 Subject: [PATCH 4/7] Simplify test code --- test/test_core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index f38eb27f25ac7..0af90dd86f384 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5845,8 +5845,7 @@ def test_fs_64bit(self): @crossplatform @with_all_fs def test_fs_stat_unnamed_file_descriptor(self): - nodefs = '-DNODEFS' in self.emcc_args - if nodefs: + if '-DNODEFS' in self.emcc_args: self.skipTest('TODO: doesnt work in nodefs') self.do_runf('fs/test_stat_unnamed_file_descriptor.c', 'success') From db0dcf3903209cf4734ad0739dd50d096ea2eac9 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 22 Jan 2025 22:13:01 +0100 Subject: [PATCH 5/7] Address review comments --- src/lib/libfs.js | 84 ++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 49 deletions(-) diff --git a/src/lib/libfs.js b/src/lib/libfs.js index 9821a72d762f3..1972cc59e5f57 100644 --- a/src/lib/libfs.js +++ b/src/lib/libfs.js @@ -487,23 +487,12 @@ FS.staticInit(); stream.stream_ops?.dup?.(stream); return stream; }, - streamGetAttr(stream) { - var node = stream.node; - var res = stream.stream_ops?.getattr?.(stream) ?? node.node_ops?.getattr?.(node); - if (res) { - return res; - } - throw new FS.ErrnoError({{{ cDefs.EPERM }}}); - }, - streamSetAttr(stream, attr) { - var node = stream.node; - var set; - if (set = stream.stream_ops.setattr) { - return set(stream, attr); - } else if (set = node.node_ops.setattr) { - return set(node, attr); - } - throw new FS.ErrnoError({{{ cDefs.EPERM }}}); + doSetAttr(stream, node, attr) { + var setattr = stream?.stream_ops.setattr; + var arg = setattr ? stream : node; + setattr ??= node.node_ops.setattr; + FS.checkOpExists(setattr, {{{ cDefs.EPERM }}}) + setattr(arg, attr); }, // @@ -985,11 +974,22 @@ FS.staticInit(); }, fstat(fd) { var stream = FS.getStreamChecked(fd); - return FS.streamGetAttr(stream); + var getattr = stream.stream_ops.getattr; + var arg = getattr ? stream : node; + getattr ??= node.node_ops.getattr; + FS.checkOpExists(getattr, {{{ cDefs.EPERM }}}) + return getattr(arg); }, lstat(path) { return FS.stat(path, true); }, + doChmod(stream, node, mode, dontFollow) { + FS.doSetAttr(stream, node, { + mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}), + ctime: Date.now(), + dontFollow + }); + }, chmod(path, mode, dontFollow) { var node; if (typeof path == 'string') { @@ -998,21 +998,20 @@ FS.staticInit(); } else { node = path; } - var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); - setattr(node, { - mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}), - ctime: Date.now(), - dontFollow - }); + FS.doChmod(null, node, dontFollow); }, lchmod(path, mode) { FS.chmod(path, mode, true); }, fchmod(fd, mode) { var stream = FS.getStreamChecked(fd); - FS.streamSetAttr(stream, { - mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (stream.node.mode & ~{{{ cDefs.S_IALLUGO }}}), - ctime: Date.now() + FS.doChmod(stream, stream.node, false); + }, + doChown(stream, node, dontFollow) { + FS.doSetAttr(stream, node, { + timestamp: Date.now(), + dontFollow + // we ignore the uid / gid for now }); }, chown(path, uid, gid, dontFollow) { @@ -1023,24 +1022,16 @@ FS.staticInit(); } else { node = path; } - var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); - setattr(node, { - timestamp: Date.now(), - dontFollow - // we ignore the uid / gid for now - }); + FS.doChown(null, node, dontFollow); }, lchown(path, uid, gid) { FS.chown(path, uid, gid, true); }, fchown(fd, uid, gid) { var stream = FS.getStreamChecked(fd); - FS.streamSetAttr(stream, { - timestamp: Date.now() - // we ignore the uid / gid for now - }); + FS.doChown(stream, stream.node, dontFollow); }, - truncateChecks(node) { + doTruncate(stream, node, len) { if (FS.isDir(node.mode)) { throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); } @@ -1051,6 +1042,10 @@ FS.staticInit(); if (errCode) { throw new FS.ErrnoError(errCode); } + FS.doSetAttr(stream, node, { + size: len, + timestamp: Date.now() + }); }, truncate(path, len) { if (len < 0) { @@ -1063,23 +1058,14 @@ FS.staticInit(); } else { node = path; } - FS.truncateChecks(node); - var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); - setattr(node, { - size: len, - timestamp: Date.now() - }); + FS.doTruncate(null, node, len); }, ftruncate(fd, len) { var stream = FS.getStreamChecked(fd); if (len < 0 || (stream.flags & {{{ cDefs.O_ACCMODE }}}) === {{{ cDefs.O_RDONLY}}}) { throw new FS.ErrnoError({{{ cDefs.EINVAL }}}); } - FS.truncateChecks(stream.node); - FS.streamSetAttr(stream, { - size: len, - timestamp: Date.now() - }); + FS.doTruncate(stream, stream.node, len); }, utime(path, atime, mtime) { var lookup = FS.lookupPath(path, { follow: true }); From 464f80ac00b2292eb842c295ea53c06ebe9571a5 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 23 Jan 2025 11:52:43 +0100 Subject: [PATCH 6/7] Fix some typos --- src/lib/libfs.js | 7 ++++--- test/unistd/dup.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/libfs.js b/src/lib/libfs.js index 1972cc59e5f57..024629adf6df1 100644 --- a/src/lib/libfs.js +++ b/src/lib/libfs.js @@ -974,6 +974,7 @@ FS.staticInit(); }, fstat(fd) { var stream = FS.getStreamChecked(fd); + var node = stream.node; var getattr = stream.stream_ops.getattr; var arg = getattr ? stream : node; getattr ??= node.node_ops.getattr; @@ -998,14 +999,14 @@ FS.staticInit(); } else { node = path; } - FS.doChmod(null, node, dontFollow); + FS.doChmod(null, node, mode, dontFollow); }, lchmod(path, mode) { FS.chmod(path, mode, true); }, fchmod(fd, mode) { var stream = FS.getStreamChecked(fd); - FS.doChmod(stream, stream.node, false); + FS.doChmod(stream, stream.node, mode, false); }, doChown(stream, node, dontFollow) { FS.doSetAttr(stream, node, { @@ -1029,7 +1030,7 @@ FS.staticInit(); }, fchown(fd, uid, gid) { var stream = FS.getStreamChecked(fd); - FS.doChown(stream, stream.node, dontFollow); + FS.doChown(stream, stream.node, false); }, doTruncate(stream, node, len) { if (FS.isDir(node.mode)) { diff --git a/test/unistd/dup.c b/test/unistd/dup.c index 7447ac46dcb2b..dcc737c3b819c 100644 --- a/test/unistd/dup.c +++ b/test/unistd/dup.c @@ -102,8 +102,8 @@ int main() { printf("DUP truncate\n"); f = open("./blah.txt", O_RDWR, 0600); - f2 = dup(f); assert(f != -1); + f2 = dup(f); assert(f2 != -1); rtn = ftruncate(f2, 0); assert(rtn == 0); From 204242e709dd080dc37e572b03b50dd3a1f19b60 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 23 Jan 2025 12:14:01 +0100 Subject: [PATCH 7/7] Automatic rebaseline of codesize expectations. NFC This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (18) test expectation files were updated by running the tests with `--rebaseline`: ``` other/codesize/test_codesize_cxx_ctors1.gzsize: 8343 => 8359 [+16 bytes / +0.19%] other/codesize/test_codesize_cxx_ctors1.jssize: 20273 => 20296 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_ctors2.gzsize: 8327 => 8341 [+14 bytes / +0.17%] other/codesize/test_codesize_cxx_ctors2.jssize: 20241 => 20264 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_except.gzsize: 9343 => 9358 [+15 bytes / +0.16%] other/codesize/test_codesize_cxx_except.jssize: 24041 => 24064 [+23 bytes / +0.10%] other/codesize/test_codesize_cxx_except_wasm.gzsize: 8294 => 8303 [+9 bytes / +0.11%] other/codesize/test_codesize_cxx_except_wasm.jssize: 20166 => 20189 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize: 8294 => 8303 [+9 bytes / +0.11%] other/codesize/test_codesize_cxx_except_wasm_legacy.jssize: 20166 => 20189 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_lto.gzsize: 8357 => 8372 [+15 bytes / +0.18%] other/codesize/test_codesize_cxx_lto.jssize: 20348 => 20371 [+23 bytes / +0.11%] other/codesize/test_codesize_cxx_mangle.gzsize: 9349 => 9364 [+15 bytes / +0.16%] other/codesize/test_codesize_cxx_mangle.jssize: 24041 => 24064 [+23 bytes / +0.10%] other/codesize/test_codesize_cxx_noexcept.gzsize: 8343 => 8359 [+16 bytes / +0.19%] other/codesize/test_codesize_cxx_noexcept.jssize: 20273 => 20296 [+23 bytes / +0.11%] other/codesize/test_codesize_files_js_fs.gzsize: 7647 => 7669 [+22 bytes / +0.29%] other/codesize/test_codesize_files_js_fs.jssize: 18820 => 18843 [+23 bytes / +0.12%] Average change: +0.14% (+0.10% - +0.29%) ``` --- test/other/codesize/test_codesize_cxx_ctors1.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors1.jssize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.gzsize | 2 +- test/other/codesize/test_codesize_cxx_ctors2.jssize | 2 +- test/other/codesize/test_codesize_cxx_except.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm.jssize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize | 2 +- test/other/codesize/test_codesize_cxx_except_wasm_legacy.jssize | 2 +- test/other/codesize/test_codesize_cxx_lto.gzsize | 2 +- test/other/codesize/test_codesize_cxx_lto.jssize | 2 +- test/other/codesize/test_codesize_cxx_mangle.gzsize | 2 +- test/other/codesize/test_codesize_cxx_mangle.jssize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.gzsize | 2 +- test/other/codesize/test_codesize_cxx_noexcept.jssize | 2 +- test/other/codesize/test_codesize_files_js_fs.gzsize | 2 +- test/other/codesize/test_codesize_files_js_fs.jssize | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index cbcd6490a2762..665f0801b8460 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8343 +8359 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index cfadcdff8168b..dcd85c88b6894 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -20273 +20296 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index 09ccded12e2c4..66e7b083aee8d 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8327 +8341 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index 27ff70803812b..6ddb211dca615 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20241 +20264 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index a14be756fbbb7..1e8ce7e708846 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9343 +9358 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 37b5c20b7dff5..0e228646c0b6b 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24041 +24064 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index 116ecc04e8d72..fdfce512935fd 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8294 +8303 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index e2819c5beac21..d5ae56906ffd8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20166 +20189 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize index 116ecc04e8d72..fdfce512935fd 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.gzsize @@ -1 +1 @@ -8294 +8303 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.jssize index e2819c5beac21..d5ae56906ffd8 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_legacy.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_legacy.jssize @@ -1 +1 @@ -20166 +20189 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index b57252391c66a..838456015747a 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8357 +8372 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index e5351bb2b3ec6..6525ff13db521 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20348 +20371 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 217ff0cc7646e..703c19eb3e692 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9349 +9364 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 37b5c20b7dff5..0e228646c0b6b 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24041 +24064 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index cbcd6490a2762..665f0801b8460 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8343 +8359 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index cfadcdff8168b..dcd85c88b6894 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -20273 +20296 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index c9ebb127902ab..ba670482b35ee 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7647 +7669 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index 1862f08cb9bd4..2b8c85f745e99 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18820 +18843