diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:08:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:08:03 +0000 |
commit | f1db79e6e5c383cf76f3bf0dd42115d19591a72b (patch) | |
tree | 3f9509008e8a130c45b7e31b1520d66d720493ec /libc-bottom-half/sources/preopens.c | |
parent | Adding upstream version 0.0~git20230821.ec4566b. (diff) | |
download | wasi-libc-f1db79e6e5c383cf76f3bf0dd42115d19591a72b.tar.xz wasi-libc-f1db79e6e5c383cf76f3bf0dd42115d19591a72b.zip |
Adding upstream version 0.0~git20240411.9e8c542.upstream/0.0_git20240411.9e8c542upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | libc-bottom-half/sources/preopens.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libc-bottom-half/sources/preopens.c b/libc-bottom-half/sources/preopens.c index b495433..3386ca4 100644 --- a/libc-bottom-half/sources/preopens.c +++ b/libc-bottom-half/sources/preopens.c @@ -260,7 +260,7 @@ void __wasilibc_populate_preopens(void) { if (prefix == NULL) goto software; - // TODO: Remove the cast on `path` once the witx is updated with + // TODO: Remove the cast on `prefix` once the witx is updated with // char8 support. ret = __wasi_fd_prestat_dir_name(fd, (uint8_t *)prefix, prestat.u.dir.pr_name_len); @@ -290,3 +290,23 @@ oserr: software: _Exit(EX_SOFTWARE); } + +void __wasilibc_reset_preopens(void) { + LOCK(lock); + + if (num_preopens) { + for (int i = 0; i < num_preopens; ++i) { + free((void*) preopens[i].prefix); + } + free(preopens); + } + + preopens_populated = false; + preopens = NULL; + num_preopens = 0; + preopen_capacity = 0; + + assert_invariants(); + + UNLOCK(lock); +} |