-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Expose WASI symlink helper #68574
Copy link
Copy link
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.
Currently, Unix and Windows expose
std::os::unix::symlinkandstd::os::windows::fs::symlink_filecorrespondingly, which both simply accept source and destination byPath.However, the currently exposed WASI method -
std::os::wasi::fs::symlinkis lower-level and requires user to have a file descriptor of the preopened directory in addition to the file paths:rust/src/libstd/sys/wasi/ext/fs.rs
Lines 397 to 405 in 8a79d08
This is different from all other
fsmethods and not ideal, because it requires calling even more lower-level methods to find and retrieve that preopened directory by file path first, and libpreopen isn't exposed to users, so they have to do this all manually.Moreover, the codebase already contains a higher-level helper for symlinking files by path and hiding these syscall details, it's just not currently exposed to users:
rust/src/libstd/sys/wasi/fs.rs
Lines 538 to 541 in a605441
If this is not too late in terms of backwards compatibility, it would be better to remove the currently exposed low-level syscall and expose this helper instead, so that users could work on paths more easily like they do on other platforms.
Alternatively, it's necessary to at least expose helpers for retrieving the preopen directory from a file path, as otherwise it's not possible to construct symlinks from userland without invoking raw syscalls.