Skip to content
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

Fix std::fs::copy on WASI target #69106

Merged
merged 1 commit into from
Feb 15, 2020
Merged

Conversation

RReverser
Copy link
Contributor

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 #68560.

@rust-highfive
Copy link
Collaborator

r? @KodrAus

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 12, 2020
@RReverser RReverser changed the title Fix std::fs::copy on WASI target [WIP] Fix std::fs::copy on WASI target Feb 12, 2020
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.
@RReverser
Copy link
Contributor Author

I wanted to verify that this actually compiles as expected, since CI doesn't seem to try to do that on a PR; now verified and should be good to go (well, at least ready for review 😊).

r? @alexcrichton

@RReverser RReverser changed the title [WIP] Fix std::fs::copy on WASI target Fix std::fs::copy on WASI target Feb 13, 2020
@KodrAus
Copy link
Contributor

KodrAus commented Feb 15, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Feb 15, 2020

📌 Commit 8fb8bb4 has been approved by KodrAus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 15, 2020
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.
bors added a commit that referenced this pull request Feb 15, 2020
Rollup of 6 pull requests

Successful merges:

 - #64069 (Added From<Vec<NonZeroU8>> for CString)
 - #66721 (implement LowerExp and UpperExp for integers)
 - #69106 (Fix std::fs::copy on WASI target)
 - #69154 (Avoid calling `fn_sig` on closures)
 - #69166 (Check `has_typeck_tables` before calling `typeck_tables_of`)
 - #69180 (Suggest a comma if a struct initializer field fails to parse)

Failed merges:

r? @ghost
@bors bors merged commit 8fb8bb4 into rust-lang:master Feb 15, 2020
@RReverser
Copy link
Contributor Author

Thanks @KodrAus!

@RReverser RReverser deleted the wasi-fs-copy branch February 16, 2020 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: no-op set_permissions for WASI
5 participants