Skip to content

Commit 5e39e52

Browse files
committed
Make fstat work on file descriptor with no name
1 parent 06cebfc commit 5e39e52

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/library_syscall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ var SyscallsLibrary = {
680680
},
681681
__syscall_fstat64: (fd, buf) => {
682682
var stream = SYSCALLS.getStreamFromFD(fd);
683-
return SYSCALLS.doStat(FS.stat, stream.path, buf);
683+
return SYSCALLS.doStat(stream.node.node_ops.getattr, stream.node, buf);
684684
},
685685
__syscall_fchown32: (fd, owner, group) => {
686686
FS.fchown(fd, owner, group);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <fcntl.h>
2+
#include <unistd.h>
3+
#include <sys/stat.h>
4+
#include <assert.h>
5+
#include "stdio.h"
6+
7+
int main() {
8+
int fd = open("file.txt", O_RDWR | O_CREAT, 0666);
9+
unlink("file.txt");
10+
int res;
11+
struct stat buf;
12+
res = fstat(fd, &buf);
13+
assert(res == 0);
14+
assert(buf.st_atime > 1000000000);
15+
printf("success\n");
16+
}

0 commit comments

Comments
 (0)