-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Suggestion: treat WASI preopen dirs as path prefixes #82339
Copy link
Copy link
Open
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Rust stdlib already has a concept of path prefixes (
std::path::Prefix,std::path::PrefixComponentetc.), 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 fromComponent::RootDiraka/), 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_parentarisen 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 tostd::path::Prefixas well as check against the preopened dirs when splittingPathintocomponents.@alexcrichton @sunfishcode would love your thoughts on this idea.