summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2021-03-19Rollup merge of #82500 - CDirkx:hermit-pipe, r=joshtriplettDylan DPC-38/+1
Reuse `std::sys::unsupported::pipe` on `hermit` Pipes are not supported on `hermit` and `hermit/pipe.rs` is identical to `unsupported/pipe.rs`. This PR reduces duplication between the two by doing the following on `hermit`: ```rust #[path = "../unsupported/pipe.rs"] pub mod pipe; ```
2021-03-17Display error details when a `mmap` call failsYuki Okushi-4/+6
2021-03-14Revert "Revert "use RWlock when accessing os::env #81850""The8472-12/+13
This reverts commit acdca316c3d42299d31c1b47eb792006ffdfc29c.
2021-03-14Rollup merge of #82804 - alexcrichton:fix-wasi, r=pnkfelixYuki Okushi-4/+2
std: Fix a bug on the wasm32-wasi target opening files This commit fixes an issue pointed out in #82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
2021-03-11Auto merge of #82417 - the8472:fix-copy_file_range-append, r=m-ou-sebors-8/+28
Fix io::copy specialization using copy_file_range when writer was opened with O_APPEND fixes #82410 While `sendfile()` returns `EINVAL` when the output was opened with O_APPEND, `copy_file_range()` does not and returns `EBADF` instead, which – unlike other `EBADF` causes – is not fatal for this operation since a regular `write()` will likely succeed. We now treat `EBADF` as a non-fatal error for `copy_file_range` and fall back to a read-write copy as we already did for several other errors.
2021-03-10Rollup merge of #82949 - the8472:forget-envlock-on-fork, r=joshtriplettDylan DPC-7/+19
Do not attempt to unlock envlock in child process after a fork. This implements the first two points from https://github.com/rust-lang/rust/issues/64718#issuecomment-793030479 This is a breaking change for cases where the environment is accessed in a Command::pre_exec closure. Except for single-threaded programs these uses were not correct anyway since they aren't async-signal safe. Note that we had a ui test that explicitly tried `env::set_var` in `pre_exec`. As expected it failed with these changes when I tested locally.
2021-03-10Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnayYuki Okushi-4/+57
Fixes to ExitStatus and its docs * On Unix, properly display every possible wait status (and don't panic on weird values) * In the documentation, be clear and consistent about "exit status" vs "wait status".
2021-03-09Do not attempt to unlock envlock in child process after a fork.The8472-7/+19
This is a breaking change for cases where the environment is accessed in a Command::pre_exec closure. Except for single-threaded programs these uses were not correct anyway since they aren't async-signal safe.
2021-03-09Always compile the fragile wait status test cases, just run them conditionallyIan Jackson-6/+7
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2021-03-07Revert "use RWlock when accessing os::env #81850"Eric Huss-13/+12
This reverts commit 354f19cf2475148994954b6783341620c7445071, reversing changes made to 0cfba2fd090834c909d5ed9deccdee8170da791b.
2021-03-05std: Fix a bug on the wasm32-wasi target opening filesAlex Crichton-4/+2
This commit fixes an issue pointed out in #82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
2021-03-04ExitStatus tests: Make less legible to satisfy "tidy"Ian Jackson-2/+4
I strongly disagree with tidy in this case but AIUI there is no way to override it. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-04ExitStatus unknown wait status test: Make it Linux onlyIan Jackson-1/+1
If different unices have different bit patterns for WIFSTOPPED and WIFCONTINUED then simply being glibc is probably not good enough for this rather ad-hoc test to work. Do it on Linux only. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-04ExitStatus stop signal display test: Make it Linux onlyIan Jackson-2/+7
MacOS uses a different representation. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-03Auto merge of #82718 - JohnTitor:rollup-vpfx3j2, r=JohnTitorbors-45/+48
Rollup of 10 pull requests Successful merges: - #81223 ([rustdoc] Generate redirect map file) - #82439 (BTree: fix untrue safety) - #82469 (Use a crate to produce rustdoc tree comparisons instead of the `diff` command) - #82589 (unix: Non-mutable bufs in send_vectored_with_ancillary_to) - #82689 (meta: Notify Zulip for rustdoc nominated issues) - #82695 (Revert non-power-of-two vector restriction) - #82706 (use outer_expn_data() instead of outer_expn().expn_data()) - #82710 (FloatToInit: Replacing round_unchecked_to --> to_int_unchecked) - #82712 (Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`) - #82713 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-03Rollup merge of #82589 - LinkTed:master, r=joshtriplettYuki Okushi-45/+48
unix: Non-mutable bufs in send_vectored_with_ancillary_to This is the same PR as [#79753](https://github.com/rust-lang/rust/pull/79753). It was closed because of inactivity. Therefore, I create a new one. ````@lukaslihotzki````
2021-03-03Auto merge of #76345 - okready:sgx-mem-range-overflow-checks, r=joshtriplettbors-8/+34
Add is_enclave_range/is_user_range overflow checks Fixes #76343. This adds overflow checking to `is_enclave_range` and `is_user_range` in `sgx::os::fortanix_sgx::mem` in order to mitigate possible security issues with enclave code. It also accounts for an edge case where the memory range provided ends exactly at the end of the address space, where calculating `p + len` would overflow back to zero despite the range potentially being valid.
2021-03-02Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514Guillaume Gomez-1/+2
Check stability and feature attributes in rustdoc Fixes #82588. cc `@Nemo157` `@camelid` r? `@jyn514`
2021-03-01Add missing stability attributes in libstdGuillaume Gomez-1/+2
2021-02-28unix: Non-mutable bufs in send_vectored_with_ancillary_toLinkTed-45/+48
Change the arguments of `send_vectored_with_ancillary` and `send_vectored_with_ancillary_to` to take an non-mutable bufs.
2021-02-27Remove the x86_64-rumprun-netbsd targetSimonas Kazlauskas-4/+4
Closes #81514
2021-02-27Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-seDylan DPC-7/+1
Use libc::accept4 on Android instead of raw syscall. This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed. `@rustbot` label +O-android +T-libs-impl
2021-02-27Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichtonDylan DPC-0/+5
Add a `size()` function to WASI's `MetadataExt`. WASI's `filestat` type includes a size field, so expose it in `MetadataExt` via a `size()` function, similar to the corresponding Unix function. r? ``````@alexcrichton``````
2021-02-27Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichtonDylan DPC-26/+83
Enable API documentation for `std::os::wasi`. This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it. r? ```@alexcrichton```
2021-02-25Rollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytmAaron Hill-2/+4
library: Normalize safety-for-unsafe-block comments Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-24Reuse `std::sys::unsupported::pipe` on `hermit`Christiaan Dirkx-38/+1
2021-02-24x.py fmtDan Gohman-3/+3
2021-02-24Use `super::` to refer to WASI-specific names.Dan Gohman-7/+7
This ensures that these names resolve to the right place even when building the WASI support on other platforms for generating the documentation.
2021-02-24Cast `libc::STDIN_FILENO` to `RawFd`.Dan Gohman-6/+6
WASI's `RawFd` is a `u32`, while `libc` uses `c_int`.
2021-02-24Use libc::accept4 on Android instead of raw syscall.Maarten de Vries-7/+1
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-2/+4
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-23Update outdated comment in unix Command.Eric Huss-17/+7
2021-02-23Enable API documentation for `std::os::wasi`.Dan Gohman-19/+76
This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it.
2021-02-23Rollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichtonDylan DPC-6/+2
Make WASI's `hard_link` behavior match other platforms. Following #78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks. r? ```@alexcrichton```
2021-02-23ExitStatus: Improve documentation re wait status vs exit statusIan Jackson-2/+12
The use of `ExitStatus` as the Rust type name for a Unix *wait status*, not an *exit status*, is very confusing, but sadly probably too late to change. This area is confusing enough in Unix already (and many programmers are already confuxed). We can at least document it. I chose *not* to mention the way shells like to exit with signal numbers, thus turning signal numbers into exit statuses. This is only relevant for Rust programs using `std::process` if they run shells. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-23process::unix: Test wait status formattingIan Jackson-0/+26
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-22Add a `size()` function to WASI's `MetadataExt`.Dan Gohman-0/+5
WASI's `filestat` type includes a size field, so expose it in `MetadataExt` via a `size()` function, similar to the corresponding Unix function.
2021-02-22fix io::copy specialization when writer was opened with O_APPENDThe8472-8/+10
2021-02-22add test for failing io::copy specializationThe8472-0/+18
2021-02-22process::unix: Handle other wait statuses in ExitStatus as DisplayIan Jackson-2/+11
Currently, on Nightly, this panics: ``` use std::process::ExitStatus; use std::os::unix::process::ExitStatusExt; fn main() { let st = ExitStatus::from_raw(0x007f); println!("st = {}", st); } ``` This is because the impl of Display assumes that if .code() is None, .signal() must be Some. That was a false assumption, although it was true with buggy code before 5b1316f78152a9c066b357ea9addf803d48e114a unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED This is not likely to have affected many people in practice, because `Command` will never produce such a wait status (`ExitStatus`). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-19x.py fmtDan Gohman-6/+1
2021-02-17Expose force_quotes on Windows.Yonggang Luo-10/+49
Quotes the arg and not quotes the arg have different effect on Windows when the program called are msys2/cygwin program. Refer to https://github.com/msys2/MSYS2-packages/issues/2176 Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2021-02-15Rollup merge of #82119 - m-ou-se:typo, r=dtolnayJonas Schievink-1/+1
Fix typo in link to CreateSymbolicLinkW documentation.
2021-02-15Rollup merge of #81975 - Amanieu:seal2, r=m-ou-seJonas Schievink-28/+21
Seal the CommandExt, OsStrExt and OsStringExt traits A crater run (https://github.com/rust-lang/rust/pull/81213#issuecomment-767651811) has shown that this does not break any existing code. This also unblocks #77728. Based on #81213. r? ````@m-ou-se```` cc ````@lygstate````
2021-02-14Fix typo in link to CreateSymbolicLinkW documentation.Mara Bos-1/+1
2021-02-12Rollup merge of #81850 - the8472:env-rwlock, r=m-ou-seDylan DPC-12/+13
use RWlock when accessing os::env Multiple threads modifying the current process environment is fairly uncommon. Optimize for the more common read case. r? ````@m-ou-se````
2021-02-10Make WASI's `hard_link` behavior match other platforms.Dan Gohman-1/+2
Following #78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks.
2021-02-10Seal the CommandExt, OsStrExt and OsStringExt traitsAmanieu d'Antras-28/+21
2021-02-09split guard into read and write typesThe8472-2/+2
2021-02-08introduce StaticRWLock wrapper to make methods safeThe8472-11/+12