Skip to content

Commit 260278f

Browse files
committed
Fix node rawfs
1 parent f3f36d5 commit 260278f

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/library_fs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,10 @@ FS.staticInit();
938938
}
939939
return node.node_ops.getattr(node);
940940
},
941+
fstat(fd) {
942+
var stream = SYSCALLS.getStreamFromFD(fd);
943+
return stream.node.node_ops.getattr(stream.node);
944+
},
941945
lstat(path) {
942946
return FS.stat(path, true);
943947
},

src/library_noderawfs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ addToLibrary({
7979
}
8080
return stat;
8181
},
82+
fstat(fd) {
83+
var stream = SYSCALLS.getStreamFromFD(fd);
84+
return fs.fstatSync(stream.nfd);
85+
},
8286
chmod(path, mode, dontFollow) {
8387
mode &= {{{ cDefs.S_IALLUGO }}};
8488
if (NODEFS.isWindows) {

src/library_syscall.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ var SyscallsLibrary = {
679679
return SYSCALLS.doStat(FS.lstat, path, buf);
680680
},
681681
__syscall_fstat64: (fd, buf) => {
682-
var stream = SYSCALLS.getStreamFromFD(fd);
683-
return SYSCALLS.doStat(stream.node.node_ops.getattr, stream.node, buf);
682+
return SYSCALLS.doStat(FS.fstat, fd, buf);
684683
},
685684
__syscall_fchown32: (fd, owner, group) => {
686685
FS.fchown(fd, owner, group);

test/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5921,6 +5921,7 @@ def test_fs_64bit(self):
59215921
self.set_setting('FORCE_FILESYSTEM')
59225922
self.do_runf('fs/test_64bit.c', 'success')
59235923

5924+
@also_with_noderawfs
59245925
def test_fs_stat_unnamed_file_descriptor(self):
59255926
if self.get_setting('WASMFS'):
59265927
self.set_setting('FORCE_FILESYSTEM')

0 commit comments

Comments
 (0)