WASI spec does not support absolute paths in path_open
. But wasmtime allows me to use --mapdir
and open a file with absolute path. My question is how is that accomplished. This doc mentions a "technique based on libpreopen."
Every --mapdir
usage will cause a file descriptor to be opened just before running the wasi program. Using a certain wasi function (i believe it is called something like fd_prestat) the wasi program can get the path it should appear as to the user code. When opening an absolute path, libpreopen will lookup the right file descriptor based on this information and then use path_open with the right relative path.
@Yage Hu
Gotcha. So wasmtime stores a mapping of absolute paths to directory fds and looks up the fd with the absolute path. Am I right? Is this completely handled by libpreopen?
Last updated: Dec 23 2024 at 13:07 UTC