diff --git a/src/library_fs.js b/src/library_fs.js index 15da9944615b5..7ba5ebec5aa9f 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -972,7 +972,8 @@ FS.staticInit(); } node.node_ops.setattr(node, { mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}), - ctime: Date.now() + ctime: Date.now(), + dontFollow }); }, lchmod(path, mode) { @@ -994,7 +995,8 @@ FS.staticInit(); throw new FS.ErrnoError({{{ cDefs.EPERM }}}); } node.node_ops.setattr(node, { - timestamp: Date.now() + timestamp: Date.now(), + dontFollow // we ignore the uid / gid for now }); }, diff --git a/src/library_nodefs.js b/src/library_nodefs.js index bdbfbe6cab863..b5d893f5a6355 100644 --- a/src/library_nodefs.js +++ b/src/library_nodefs.js @@ -156,6 +156,9 @@ addToLibrary({ var path = NODEFS.realPath(node); NODEFS.tryFSOperation(() => { if (attr.mode !== undefined) { + if (attr.dontFollow) { + throw new FS.ErrnoError({{{ cDefs.ENOSYS }}}); + } var mode = attr.mode; if (NODEFS.isWindows) { // Windows only supports S_IREAD / S_IWRITE (S_IRUSR / S_IWUSR) diff --git a/test/stat/test_chmod.c b/test/stat/test_chmod.c index b9428255efdbf..261d247c32270 100644 --- a/test/stat/test_chmod.c +++ b/test/stat/test_chmod.c @@ -93,6 +93,15 @@ void test() { err = fchmodat(AT_FDCWD, "otherfile", S_IXUSR, 0); assert(!err); + assert(symlink("otherfile", "link") == 0); + err = fchmodat(AT_FDCWD, "link", S_IXGRP, AT_SYMLINK_NOFOLLOW); +#if defined(NODEFS) || defined(NODERAWFS) + assert(err == -1); + assert(errno == ENOTSUP); +#else + assert(err == 0); +#endif + memset(&s, 0, sizeof s); stat("otherfile", &s); assert(s.st_mode == (S_IXUSR | S_IFREG)); diff --git a/test/test_core.py b/test/test_core.py index 5a1783ed6f82d..f22252f32ce66 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5524,10 +5524,10 @@ def test_fstatat(self): self.do_runf('stat/test_fstatat.c', 'success') @crossplatform - @also_with_wasmfs - @also_with_noderawfs + @with_all_fs def test_stat_chmod(self): - if self.get_setting('NODERAWFS') and WINDOWS: + nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args + if nodefs and WINDOWS: self.skipTest('mode bits work differently on windows') if self.get_setting('WASMFS') and self.get_setting('NODERAWFS'): self.skipTest('test requires symlink creation which currently missing from wasmfs+noderawfs')