-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
Rust stdlib already has a concept of path prefixes (std::path::Prefix
, std::path::PrefixComponent
etc.), although they are applied only to Windows paths.
WASI paths are currently treated as starting with a root /
(e.g. path.components()
returns each level starting from Component::RootDir
aka /
), even though WASI recognises only paths starting with a specific prefix that matches one of the preopen directories specified at startup. The levels above those prefixes don't "exist", and most APIs under WASI don't permit crossing boundaries and resolving relative paths or symlinks from a path rooted under one preopen directory to another.
The question of exposing an API corresponding to the (currently private) open_parent
arisen several times in the past, as it's important to split the preopen dir from the relative path whenever dealing with lower-level WASI syscalls.
Given the above, I feel like there is a lot of conceptual similarity between WASI preopen dirs and the std::path::Prefix
, and the latter would be a natural API to use for exposing the former. We'd only need to add another variant to std::path::Prefix
as well as check against the preopened dirs when splitting Path
into components
.
@alexcrichton @sunfishcode would love your thoughts on this idea.