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 | d53be633495379df577148d121a9cf52246b0c5e (patch) | |
tree | bbc827718e0859af4dc7332e03e2e8ddc56cc09c /libc-bottom-half/sources/preopens.c | |
parent | Adding debian version 0.0~git20230821.ec4566b-2. (diff) | |
download | wasi-libc-d53be633495379df577148d121a9cf52246b0c5e.tar.xz wasi-libc-d53be633495379df577148d121a9cf52246b0c5e.zip |
Merging upstream version 0.0~git20240411.9e8c542.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-bottom-half/sources/preopens.c')
-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); +} |