From ae7bb24ca56f1769529121393866d50588153d85 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 12 Dec 2024 12:40:50 +0100 Subject: [PATCH 01/15] Make sure the ino that we give to readdir matches the ino we give to stat --- src/library_syscall.js | 26 +++---- .../fs/test_fs_readdir_ino_matches_stat_ino.c | 68 +++++++++++++++++++ test/test_core.py | 11 +++ 3 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 test/fs/test_fs_readdir_ino_matches_stat_ino.c diff --git a/src/library_syscall.js b/src/library_syscall.js index 80e616408bac6..39bc984f03b3d 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -697,23 +697,22 @@ var SyscallsLibrary = { var startIdx = Math.floor(off / struct_size); var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count/struct_size)) + var node; for (var idx = startIdx; idx < endIdx; idx++) { - var id; var type; var name = stream.getdents[idx]; if (name === '.') { - id = stream.node.id; + node = stream.node; type = 4; // DT_DIR } else if (name === '..') { var lookup = FS.lookupPath(stream.path, { parent: true }); - id = lookup.node.id; + node = lookup.node; type = 4; // DT_DIR } else { - var child; try { - child = FS.lookupNode(stream.node, name); + node = FS.lookupNode(stream.node, name); } catch (e) { // If the entry is not a directory, file, or symlink, nodefs // lookupNode will raise EINVAL. Skip these and continue. @@ -722,16 +721,17 @@ var SyscallsLibrary = { } throw e; } - id = child.id; - type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device. - FS.isDir(child.mode) ? 4 : // DT_DIR, directory. - FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link. + type = FS.isChrdev(node.mode) ? 2 : // DT_CHR, character device. + FS.isDir(node.mode) ? 4 : // DT_DIR, directory. + FS.isLink(node.mode) ? 10 : // DT_LNK, symbolic link. 8; // DT_REG, regular file. } -#if ASSERTIONS - assert(id); -#endif - {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'id', 'i64') }}}; + // We use getattr to decide which ino we return to stat, so make sure to + // use it to decide which ino we return to readdir too. noderawfs puts the + // native inode into node.id and doesn't define node_ops.getattr so use + // that as a fallback. + var ino = node.node_ops.getattr?.(node).ino ?? node.id; + {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'ino', 'i64') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_off, '(idx + 1) * struct_size', 'i64') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_reclen, C_STRUCTS.dirent.__size__, 'i16') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_type, 'type', 'i8') }}}; diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c new file mode 100644 index 0000000000000..233ece9249816 --- /dev/null +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#if defined(__EMSCRIPTEN__) +#include +#endif + +void makedir(const char *dir) { + int rtn = mkdir(dir, 0777); + assert(rtn == 0); +} + +void changedir(const char *dir) { + int rtn = chdir(dir); + assert(rtn == 0); +} + +void setup() { +#if defined(__EMSCRIPTEN__) && defined(NODEFS) + makedir("working"); + emscripten_debugger(); + EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); + changedir("working"); +#endif +} + +int main() { + setup(); + int res = open("b", O_CREAT, 0777); + assert(res >= 0); + assert(close(res) == 0); + assert(symlink("b", "a") == 0); + int dirfd = open(".", O_RDONLY); + assert(dirfd > 0); + DIR *dirp; + dirp = fdopendir(dirfd); + assert(dirp != NULL); + struct dirent *ep; + int a_ino = -1; + int b_ino = -1; + while ((ep = readdir(dirp))) { + if (strcmp(ep->d_name, "a") == 0) { + a_ino = ep->d_ino; + } + if (strcmp(ep->d_name, "b") == 0) { + b_ino = ep->d_ino; + } + } + assert(a_ino >= 0); + assert(b_ino >= 0); + struct stat sta, stb; + assert(lstat("a", &sta) == 0); + assert(lstat("b", &stb) == 0); + printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); + printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); + assert(a_ino == sta.st_ino); + assert(b_ino == stb.st_ino); + printf("success\n"); +} diff --git a/test/test_core.py b/test/test_core.py index d3fff94c5a8ec..a8a411389e858 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5900,6 +5900,17 @@ def test_fs_rename_on_existing(self, args): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_rename_on_existing.c', 'success', emcc_args=args) + @parameterized({ + '': ([],), + 'nodefs': (['-DNODEFS', '-lnodefs.js'],), + 'noderawfs': (['-sNODERAWFS'],) + }) + def test_fs_readdir_ino_matches_stat_ino(self, args): + if self.get_setting('WASMFS'): + self.set_setting('FORCE_FILESYSTEM') + self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success', emcc_args=args) + + def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') self.set_setting('EXIT_RUNTIME') From 9068d8719124133fff5d64bf42caf4a9acab51cf Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 13 Dec 2024 10:25:10 +0100 Subject: [PATCH 02/15] Some formatting fixes --- .../fs/test_fs_readdir_ino_matches_stat_ino.c | 60 +++++++++---------- test/test_core.py | 1 - 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 233ece9249816..2af027d214461 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -34,35 +34,35 @@ void setup() { } int main() { - setup(); - int res = open("b", O_CREAT, 0777); - assert(res >= 0); - assert(close(res) == 0); - assert(symlink("b", "a") == 0); - int dirfd = open(".", O_RDONLY); - assert(dirfd > 0); - DIR *dirp; - dirp = fdopendir(dirfd); - assert(dirp != NULL); - struct dirent *ep; - int a_ino = -1; - int b_ino = -1; - while ((ep = readdir(dirp))) { - if (strcmp(ep->d_name, "a") == 0) { - a_ino = ep->d_ino; - } - if (strcmp(ep->d_name, "b") == 0) { - b_ino = ep->d_ino; - } + setup(); + int res = open("b", O_CREAT, 0777); + assert(res >= 0); + assert(close(res) == 0); + assert(symlink("b", "a") == 0); + int dirfd = open(".", O_RDONLY); + assert(dirfd > 0); + DIR *dirp; + dirp = fdopendir(dirfd); + assert(dirp != NULL); + struct dirent *ep; + int a_ino = -1; + int b_ino = -1; + while ((ep = readdir(dirp))) { + if (strcmp(ep->d_name, "a") == 0) { + a_ino = ep->d_ino; } - assert(a_ino >= 0); - assert(b_ino >= 0); - struct stat sta, stb; - assert(lstat("a", &sta) == 0); - assert(lstat("b", &stb) == 0); - printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); - printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); - assert(a_ino == sta.st_ino); - assert(b_ino == stb.st_ino); - printf("success\n"); + if (strcmp(ep->d_name, "b") == 0) { + b_ino = ep->d_ino; + } + } + assert(a_ino >= 0); + assert(b_ino >= 0); + struct stat sta, stb; + assert(lstat("a", &sta) == 0); + assert(lstat("b", &stb) == 0); + printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); + printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); + assert(a_ino == sta.st_ino); + assert(b_ino == stb.st_ino); + printf("success\n"); } diff --git a/test/test_core.py b/test/test_core.py index a8a411389e858..d9c92cb25da7a 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5910,7 +5910,6 @@ def test_fs_readdir_ino_matches_stat_ino(self, args): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success', emcc_args=args) - def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') self.set_setting('EXIT_RUNTIME') From 61762e6084a1d07804fcb2bc24b3af99b3cc47ab Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 13 Dec 2024 11:18:19 +0100 Subject: [PATCH 03/15] Revert --- src/library_syscall.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/library_syscall.js b/src/library_syscall.js index 39bc984f03b3d..80e616408bac6 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -697,22 +697,23 @@ var SyscallsLibrary = { var startIdx = Math.floor(off / struct_size); var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count/struct_size)) - var node; for (var idx = startIdx; idx < endIdx; idx++) { + var id; var type; var name = stream.getdents[idx]; if (name === '.') { - node = stream.node; + id = stream.node.id; type = 4; // DT_DIR } else if (name === '..') { var lookup = FS.lookupPath(stream.path, { parent: true }); - node = lookup.node; + id = lookup.node.id; type = 4; // DT_DIR } else { + var child; try { - node = FS.lookupNode(stream.node, name); + child = FS.lookupNode(stream.node, name); } catch (e) { // If the entry is not a directory, file, or symlink, nodefs // lookupNode will raise EINVAL. Skip these and continue. @@ -721,17 +722,16 @@ var SyscallsLibrary = { } throw e; } - type = FS.isChrdev(node.mode) ? 2 : // DT_CHR, character device. - FS.isDir(node.mode) ? 4 : // DT_DIR, directory. - FS.isLink(node.mode) ? 10 : // DT_LNK, symbolic link. + id = child.id; + type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device. + FS.isDir(child.mode) ? 4 : // DT_DIR, directory. + FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link. 8; // DT_REG, regular file. } - // We use getattr to decide which ino we return to stat, so make sure to - // use it to decide which ino we return to readdir too. noderawfs puts the - // native inode into node.id and doesn't define node_ops.getattr so use - // that as a fallback. - var ino = node.node_ops.getattr?.(node).ino ?? node.id; - {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'ino', 'i64') }}}; +#if ASSERTIONS + assert(id); +#endif + {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_ino, 'id', 'i64') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_off, '(idx + 1) * struct_size', 'i64') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_reclen, C_STRUCTS.dirent.__size__, 'i16') }}}; {{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_type, 'type', 'i8') }}}; From 2d1a04c1f4c929294895c34c286b75c5a77ed48e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 13 Dec 2024 11:03:56 +0100 Subject: [PATCH 04/15] Take two make nodefs inode numbers match Fix problem with directory permissions --- src/library_nodefs.js | 2 +- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/library_nodefs.js b/src/library_nodefs.js index 5570bcc68f5c8..21e0561b783d9 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -138,7 +138,7 @@ addToLibrary({ } return { dev: stat.dev, - ino: stat.ino, + ino: node.id, mode: stat.mode, nlink: stat.nlink, uid: stat.uid, diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 2af027d214461..920ed04771939 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -31,6 +31,8 @@ void setup() { EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); changedir("working"); #endif + mkdir("sub", 0775); + changedir("sub"); } int main() { @@ -45,6 +47,13 @@ int main() { dirp = fdopendir(dirfd); assert(dirp != NULL); struct dirent *ep; + struct stat sta, stb; + assert(lstat("a", &sta) == 0); + assert(lstat("b", &stb) == 0); + // Remove execute permission from directory. This prevents us from stat'ing + // files in the directory in the implementation of readdir which we tried to + // use to fix this. + assert(chmod(".", 0675) == 0); int a_ino = -1; int b_ino = -1; while ((ep = readdir(dirp))) { @@ -55,11 +64,10 @@ int main() { b_ino = ep->d_ino; } } + assert(errno == 0); assert(a_ino >= 0); assert(b_ino >= 0); - struct stat sta, stb; - assert(lstat("a", &sta) == 0); - assert(lstat("b", &stb) == 0); + assert(chmod(".", 0775) == 0); printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); assert(a_ino == sta.st_ino); From 89810023341cc861504a9dd4c9d3a2720cd9be88 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 14 Dec 2024 19:31:25 +0100 Subject: [PATCH 05/15] Fix make_dir_writable --- test/common.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/test/common.py b/test/common.py index b6e958af77107..35d225a232002 100644 --- a/test/common.py +++ b/test/common.py @@ -679,27 +679,16 @@ def make_executable(name): def make_dir_writeable(dirname): - # Ensure all files are readable and writable by the current user. - permission_bits = stat.S_IWRITE | stat.S_IREAD - - def is_writable(path): - return (os.stat(path).st_mode & permission_bits) != permission_bits - - def make_writable(path): - new_mode = os.stat(path).st_mode | permission_bits - os.chmod(path, new_mode) - # Some tests make files and subdirectories read-only, so rmtree/unlink will not delete # them. Force-make everything writable in the subdirectory to make it # removable and re-attempt. - if not is_writable(dirname): - make_writable(dirname) + os.chmod(dirname, 0o777) for directory, subdirs, files in os.walk(dirname): for item in files + subdirs: i = os.path.join(directory, item) if not os.path.islink(i): - make_writable(i) + os.chmod(i, 0o777) def force_delete_dir(dirname): From 57bd2296669b49718cf5321a3f5166158cd79ac9 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sat, 14 Dec 2024 19:31:44 +0100 Subject: [PATCH 06/15] Remove subdir --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 920ed04771939..92caa58b9a9c0 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -31,8 +31,6 @@ void setup() { EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); changedir("working"); #endif - mkdir("sub", 0775); - changedir("sub"); } int main() { From c3f896e2c28f4c68cf3f4ff633e1539a911ac86c Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 11:59:39 +0100 Subject: [PATCH 07/15] Update --- .../fs/test_fs_readdir_ino_matches_stat_ino.c | 24 ------------------- test/test_core.py | 10 ++------ 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 92caa58b9a9c0..096ef33cb51c6 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -10,31 +10,7 @@ #include -#if defined(__EMSCRIPTEN__) -#include -#endif - -void makedir(const char *dir) { - int rtn = mkdir(dir, 0777); - assert(rtn == 0); -} - -void changedir(const char *dir) { - int rtn = chdir(dir); - assert(rtn == 0); -} - -void setup() { -#if defined(__EMSCRIPTEN__) && defined(NODEFS) - makedir("working"); - emscripten_debugger(); - EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); - changedir("working"); -#endif -} - int main() { - setup(); int res = open("b", O_CREAT, 0777); assert(res >= 0); assert(close(res) == 0); diff --git a/test/test_core.py b/test/test_core.py index 8561e786fbda6..3c8fe0c2540bd 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5858,15 +5858,9 @@ def test_fs_rename_on_existing(self): self.set_setting('FORCE_FILESYSTEM') self.do_runf('fs/test_fs_rename_on_existing.c', 'success') - @parameterized({ - '': ([],), - 'nodefs': (['-DNODEFS', '-lnodefs.js'],), - 'noderawfs': (['-sNODERAWFS'],) - }) + @also_with_nodefs_both def test_fs_readdir_ino_matches_stat_ino(self, args): - if self.get_setting('WASMFS'): - self.set_setting('FORCE_FILESYSTEM') - self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success', emcc_args=args) + self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success') def test_sigalrm(self): self.do_runf('test_sigalrm.c', 'Received alarm!') From 088b2539f52f250afe5cea54b8d9990017db6e2d Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 16:39:22 +0100 Subject: [PATCH 08/15] Apply review comments to test --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 096ef33cb51c6..19261ca75edf2 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -9,18 +9,19 @@ #include #include - -int main() { +void setup() { int res = open("b", O_CREAT, 0777); assert(res >= 0); assert(close(res) == 0); assert(symlink("b", "a") == 0); +} + +int main() { + setup(); int dirfd = open(".", O_RDONLY); assert(dirfd > 0); - DIR *dirp; - dirp = fdopendir(dirfd); + DIR *dirp = fdopendir(dirfd); assert(dirp != NULL); - struct dirent *ep; struct stat sta, stb; assert(lstat("a", &sta) == 0); assert(lstat("b", &stb) == 0); @@ -30,6 +31,7 @@ int main() { assert(chmod(".", 0675) == 0); int a_ino = -1; int b_ino = -1; + struct dirent *ep; while ((ep = readdir(dirp))) { if (strcmp(ep->d_name, "a") == 0) { a_ino = ep->d_ino; @@ -41,10 +43,10 @@ int main() { assert(errno == 0); assert(a_ino >= 0); assert(b_ino >= 0); - assert(chmod(".", 0775) == 0); printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino); printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino); assert(a_ino == sta.st_ino); assert(b_ino == stb.st_ino); printf("success\n"); + return 0; } From 7afc9653ff78cc4145f4d4d02ed0262910c11daa Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 19:24:33 +0100 Subject: [PATCH 09/15] Add TODO comment about merging tests --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 19261ca75edf2..29d20448e89a7 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -9,6 +9,10 @@ #include #include +// TODO: Consider merging this with test/dirent/test_readdir.c? +// That test doesn't work on nodefs, which has to be fixed before these two +// tests can be merged . + void setup() { int res = open("b", O_CREAT, 0777); assert(res >= 0); From c49936872831a8165518a5070375e11861b3d0be Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 19:26:07 +0100 Subject: [PATCH 10/15] Clearer comment explaining chmod --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 29d20448e89a7..c46d7204c0573 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -29,9 +29,8 @@ int main() { struct stat sta, stb; assert(lstat("a", &sta) == 0); assert(lstat("b", &stb) == 0); - // Remove execute permission from directory. This prevents us from stat'ing - // files in the directory in the implementation of readdir which we tried to - // use to fix this. + // Test that removing permissions from the directory does not effect the + // already open directory handle that we have (dirp). assert(chmod(".", 0675) == 0); int a_ino = -1; int b_ino = -1; From 6265dd615b7f6a76db3ab22c7003e90ab42cefeb Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 19:27:01 +0100 Subject: [PATCH 11/15] effect => affect --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index c46d7204c0573..2ec7b9561ace9 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -29,7 +29,7 @@ int main() { struct stat sta, stb; assert(lstat("a", &sta) == 0); assert(lstat("b", &stb) == 0); - // Test that removing permissions from the directory does not effect the + // Test that removing permissions from the directory does not affect the // already open directory handle that we have (dirp). assert(chmod(".", 0675) == 0); int a_ino = -1; From 11f13949ad78ebe48fbe4530f6a78b6b7ca7f26e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 20:11:30 +0100 Subject: [PATCH 12/15] Fix test --- test/test_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_core.py b/test/test_core.py index 3c8fe0c2540bd..eb09aeb48d217 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5859,7 +5859,7 @@ def test_fs_rename_on_existing(self): self.do_runf('fs/test_fs_rename_on_existing.c', 'success') @also_with_nodefs_both - def test_fs_readdir_ino_matches_stat_ino(self, args): + def test_fs_readdir_ino_matches_stat_ino(self): self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success') def test_sigalrm(self): From 042f8aed67f02f3f11840df7e68f09bef3fb05f4 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 21:51:45 +0100 Subject: [PATCH 13/15] Add subdirectory again --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index 2ec7b9561ace9..fadb32a61353d 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -14,6 +14,11 @@ // tests can be merged . void setup() { + // If the node working directory does not have execute permissions, then + // `fs.readdir` will fail. For that reason we have to work in a subdirectory + // and remove execute permissions from that. + mkdir("sub", 0775); + assert(chdir("sub") == 0); int res = open("b", O_CREAT, 0777); assert(res >= 0); assert(close(res) == 0); From 6ed84c19d4e10d8afd5d9c841d5fd8b095d6a5d1 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 18 Dec 2024 22:00:17 +0100 Subject: [PATCH 14/15] Update minimal_esm codesize --- test/other/codesize/test_codesize_minimal_esm.gzsize | 2 +- test/other/codesize/test_codesize_minimal_esm.jssize | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize index 50989ffea157c..84abd852d3092 100644 --- a/test/other/codesize/test_codesize_minimal_esm.gzsize +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -1 +1 @@ -1400 +1487 diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize index 9b860457fa607..1877dcdd8387c 100644 --- a/test/other/codesize/test_codesize_minimal_esm.jssize +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -1 +1 @@ -2865 +3095 From 238a3bcdcd50a26e40980b3a8c134664e4884f92 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Dec 2024 15:17:39 +0100 Subject: [PATCH 15/15] Don't do chmod in noderawfs --- test/fs/test_fs_readdir_ino_matches_stat_ino.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fs/test_fs_readdir_ino_matches_stat_ino.c b/test/fs/test_fs_readdir_ino_matches_stat_ino.c index fadb32a61353d..68e1f1da4e55d 100644 --- a/test/fs/test_fs_readdir_ino_matches_stat_ino.c +++ b/test/fs/test_fs_readdir_ino_matches_stat_ino.c @@ -36,7 +36,9 @@ int main() { assert(lstat("b", &stb) == 0); // Test that removing permissions from the directory does not affect the // already open directory handle that we have (dirp). +#ifndef NODERAWFS assert(chmod(".", 0675) == 0); +#endif int a_ino = -1; int b_ino = -1; struct dirent *ep;