Skip to content

Commit d862445

Browse files
committed
Use __wasi_fd_is_valid in fstatat.c
1 parent 39d5adb commit d862445

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

system/lib/libc/musl/src/stat/fstatat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restric
7979

8080
if (flag==AT_EMPTY_PATH && fd>=0 && !*path) {
8181
ret = __syscall(SYS_fstat, fd, &kst);
82+
#ifdef __EMSCRIPTEN__
83+
if (ret==-EBADF && __wasi_fd_is_valid(fd)) {
84+
#else
8285
if (ret==-EBADF && __syscall(SYS_fcntl, fd, F_GETFD)>=0) {
86+
#endif
8387
ret = __syscall(SYS_fstatat, fd, path, &kst, flag);
8488
if (ret==-EINVAL) {
8589
char buf[15+3*sizeof(int)];

0 commit comments

Comments
 (0)