-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: no-op set_permissions for WASI #68560
Comments
Ping @alexcrichton @fitzgen? |
I would personally prefer to ensure that wasi-libc for C stays in sync with Rust's libstd, so I think that this is probably best a question for the wasi group as opposed to Rust's libstd specifically. |
I see; WASI SDK conditionally excludes In that case, would you be open to adding a specific implementation of |
Fix std::fs::copy on WASI target Previously `std::fs::copy` on wasm32-wasi would reuse code from the `sys_common` module and would successfully copy contents of the file just to fail right before closing it. This was happening because `sys_common::copy` tries to copy permissions of the file, but permissions are not a thing in WASI (at least yet) and `set_permissions` is implemented as an unconditional runtime error. This change instead adds a custom working implementation of `std::fs::copy` (like Rust already has on some other targets) that doesn't try to call `set_permissions` and is essentially a thin wrapper around `std::io::copy`. Fixes rust-lang#68560.
Currently, WASI target implements retrieving permissions with a no-op and just returning a default value:
rust/src/libstd/sys/wasi/fs.rs
Lines 75 to 78 in a237641
However, the corresponding setter method is instead implemented by returning an error:
rust/src/libstd/sys/wasi/fs.rs
Lines 424 to 428 in a237641
This is unfortunate and breaks higher-level APIs like
std::fs::copy
which currently manages to successfully copy contents of file on a WASI target but then fails because the default implementation unconditionally callsset_permissions
:rust/src/libstd/sys_common/fs.rs
Lines 19 to 21 in d8bdb3f
To both fix such issues and from a semantic point of view, too, it seems it would be better to mirror the behaviour of the getter (
permissions
method) and just perform no-op inset_permissions
on a WASI target, at least until WASI specification decides to extend support and add real permissions model.Would the team be open to this?
The text was updated successfully, but these errors were encountered: