Skip to content

Commit a85d3d5

Browse files
committed
wasi: allow to close preopens
cf. WebAssembly/WASI#522
1 parent 570edf6 commit a85d3d5

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

libwasi/wasi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ wasi_fd_close(struct exec_context *ctx, struct host_instance *hi,
880880
toywasm_mutex_unlock(&wasi->lock);
881881
goto fail;
882882
}
883-
if (fdinfo->hostfd == -1) {
883+
if (wasi_fdinfo_unused(fdinfo)) {
884884
toywasm_mutex_unlock(&wasi->lock);
885885
ret = EBADF;
886886
goto fail;
@@ -1576,11 +1576,7 @@ wasi_fd_renumber(struct exec_context *ctx, struct host_instance *hi,
15761576
if (ret != 0) {
15771577
goto fail_locked;
15781578
}
1579-
if (wasi_fdinfo_is_prestat(fdinfo_from)) {
1580-
ret = ENOTSUP;
1581-
goto fail_locked;
1582-
}
1583-
if (fdinfo_from->hostfd == -1) {
1579+
if (!wasi_fdinfo_is_prestat(fdinfo_from) && fdinfo_from->hostfd == -1) {
15841580
ret = EBADF;
15851581
goto fail_locked;
15861582
}

libwasi/wasi_fdtable.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ wasi_fd_lookup_locked_for_close(struct exec_context *ctx,
153153
if (ret != 0) {
154154
goto fail;
155155
}
156-
if (wasi_fdinfo_is_prestat(fdinfo)) {
157-
ret = ENOTSUP;
158-
goto fail;
159-
}
160156

161157
/*
162158
* it should have at least two references for

test/wasi-testsuite-skip.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"fd_filestat_get": "https://github.com/WebAssembly/wasi-testsuite/pull/59",
44
"fd_filestat_set": "intentional limitations due to the use of legacy (non openat family) functions.",
55
"fd_flags_set": "rights system not implemented.",
6-
"close_preopen": "https://github.com/WebAssembly/WASI/pull/522",
76
"interesting_paths": "loose implementation of path_open."
87
}
98
}

test/wasmtime-wasi-tests-blacklist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ interesting_paths
2020
# Note: wasmtime behavior is intentional:
2121
# https://github.com/bytecodealliance/wasmtime/commit/b84c4d748826837fb532fa64bf32ac6b50690d77
2222
poll_oneoff_files
23+
24+
# https://github.com/WebAssembly/WASI/pull/522
25+
close_preopen

0 commit comments

Comments
 (0)