diff options
| author | Michael Benfield <mbenfield@google.com> | 2022-12-06 20:58:33 +0000 |
|---|---|---|
| committer | Michael Benfield <mbenfield@google.com> | 2022-12-07 19:58:04 +0000 |
| commit | 27011b4185f5341e579d2a02cabd3dc7d7aa7149 (patch) | |
| tree | 0642739ee1b9c6315c2b7ae89c8f328bf1ca95f4 /library/std/src/sys/unix/mod.rs | |
| parent | 01fbc5ae789fc0c7a2da71d3cd908451f175e4eb (diff) | |
| download | rust-27011b4185f5341e579d2a02cabd3dc7d7aa7149.tar.gz rust-27011b4185f5341e579d2a02cabd3dc7d7aa7149.zip | |
Use more LFS functions.
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.
Diffstat (limited to 'library/std/src/sys/unix/mod.rs')
| -rw-r--r-- | library/std/src/sys/unix/mod.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 9055a011c51..3d60941e84e 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -95,6 +95,10 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { )))] 'poll: { use crate::sys::os::errno; + #[cfg(not(target_os = "linux"))] + use libc::open as open64; + #[cfg(target_os = "linux")] + use libc::open64; let pfds: &mut [_] = &mut [ libc::pollfd { fd: 0, events: 0, revents: 0 }, libc::pollfd { fd: 1, events: 0, revents: 0 }, @@ -116,7 +120,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { if pfd.revents & libc::POLLNVAL == 0 { continue; } - if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { + if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { // If the stream is closed but we failed to reopen it, abort the // process. Otherwise we wouldn't preserve the safety of // operations on the corresponding Rust object Stdin, Stdout, or @@ -139,9 +143,13 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { )))] { use crate::sys::os::errno; + #[cfg(not(target_os = "linux"))] + use libc::open as open64; + #[cfg(target_os = "linux")] + use libc::open64; for fd in 0..3 { if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF { - if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { + if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { // If the stream is closed but we failed to reopen it, abort the // process. Otherwise we wouldn't preserve the safety of // operations on the corresponding Rust object Stdin, Stdout, or |
