From f1db79e6e5c383cf76f3bf0dd42115d19591a72b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:08:03 +0200 Subject: Adding upstream version 0.0~git20240411.9e8c542. Signed-off-by: Daniel Baumann --- libc-bottom-half/sources/preopens.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'libc-bottom-half/sources/preopens.c') 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); +} -- cgit v1.2.3