about summary refs log tree commit diff
path: root/library/std/src/sys/unix/kernel_copy.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-730/+0
2023-09-21added support for GNU/HurdSamuel Thibault-2/+2
2023-08-03unix/kernel_copy.rs: copy_file_range_candidate allows empty output filesxstaticxgpx-4/+14
This is for https://github.com/rust-lang/rust/issues/114341 The `meta.len() > 0` condition here is intended for inputs only, ie. when input is in the `/proc` filesystem as documented. That inaccurately included empty output files which are then shunted to the sendfile() routine leading to higher than nescessary IO util in some cases, specifically with CoW filesystems like btrfs. Further, `NoneObtained` is not relevant in this context, so remove it. Simply, determine what is input or output given the passed enum Unit.
2023-05-01Relax implicit `W: Sized` bound on `BufWriter<W>`Maybe Waffle-1/+1
2023-05-01Relax implicit `R: Sized` bound on `BufReader<R>`Maybe Waffle-1/+1
2023-04-03avoid zero-copy ops for File->Pipe and File->Socket in io::copyThe 8472-16/+46
2023-01-14Remove various double spaces in source comments.André Vennberg-1/+1
2022-12-22std: only use LFS function on glibcmochaaP-2/+2
see #94173 and commit 27011b4185f5341e579d2a02cabd3dc7d7aa7149.
2022-12-07Use more LFS functions.Michael Benfield-1/+5
On Linux, use mmap64, open64, openat64, and sendfile64 in place of their non-LFS counterparts. This is relevant to #94173. With these changes (together with rust-lang/backtrace-rs#501), the simple binaries I produce with rustc seem to have no non-LFS functions, so maybe #94173 is fixed. But I can't be sure if I've missed something and maybe some non-LFS functions could sneak in somehow.
2022-10-13fix small word dupe typosRageking8-1/+1
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-1/+0
2021-12-14Fix a bunch of typosFrank Steffahn-1/+1
2021-11-27Auto merge of #90846 - cuviper:weak, r=dtolnaybors-0/+6
Refactor weak symbols in std::sys::unix This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
2021-11-23kernel_copy: avoid panic on unexpected OS errorGeorg Brandl-2/+4
According to documentation, the listed errnos should only occur if the `copy_file_range` call cannot be made at all, so the assert be correct. However, since in practice file system drivers (incl. FUSE etc.) can return any errno they want, we should not panic here. Fixes #91152
2021-11-12Refactor weak symbols in std::sys::unixJosh Stone-0/+6
This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
2021-07-10Change `weak!` and `linkat!` to macros 2.0Aris Merchant-0/+1
`weak!` is needed in a test in another module. With macros 1.0, importing `weak!` would require reordering module declarations in `std/src/lib.rs`, which is a bit too evil.
2021-02-22fix io::copy specialization when writer was opened with O_APPENDThe8472-8/+10
2020-12-09Improve comment grammarThe8472-2/+2
2020-12-09implement better availability probing for copy_file_rangeThe8472-34/+48
previously any attempt to copy to an immutable file (EPERM) would disable copy_file_range support for the whole process.
2020-12-03fix copy specialization not updating Take wrappersThe8472-12/+42
2020-12-01Leverage kernel copy for UnixStreamNicolas Koch-0/+29
UDS can be a sendfile destination, just like TCP sockets.
2020-11-16Use syscall! for copy_file_range tooJosh Stone-9/+9
2020-11-13Always handle EOVERFLOW by falling back to the generic copy loopThe8472-5/+5
Previously EOVERFLOW handling was only applied for io::copy specialization but not for fs::copy sharing the same code. Additionally we lower the chunk size to 1GB since we have a user report that older kernels may return EINVAL when passing 0x8000_0000 but smaller values succeed.
2020-11-13do direct splice syscall and probe availability to get android builds to workThe8472-4/+38
Android builds use feature level 14, the libc wrapper for splice is gated on feature level 21+ so we have to invoke the syscall directly. Additionally the emulator doesn't seem to support it so we also have to add ENOSYS checks.
2020-11-13move sendfile/splice/copy_file_range into kernel_copy moduleThe8472-2/+146
2020-11-13limit visibility of copy offload helpers to sys::unix moduleThe8472-0/+3
2020-11-13move copy specialization into sys::unix moduleThe8472-0/+422