summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/linux_raw
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/rustix/src/backend/linux_raw
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/linux_raw')
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/aarch64.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/aarch64.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/arm.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/arm.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/asm/mod.rs24
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/mips.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/mips.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/mips32r6.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/mips32r6.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/mips64.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/mips64.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/mips64r6.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/mips64r6.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/mod.rs19
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/powerpc64.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/powerpc64.rs)4
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/riscv64.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/riscv64.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/thumb.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/thumb.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/x86.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/x86.rs)7
-rw-r--r--vendor/rustix/src/backend/linux_raw/arch/x86_64.rs (renamed from vendor/rustix/src/backend/linux_raw/arch/asm/x86_64.rs)2
-rw-r--r--vendor/rustix/src/backend/linux_raw/c.rs34
-rw-r--r--vendor/rustix/src/backend/linux_raw/conv.rs20
-rw-r--r--vendor/rustix/src/backend/linux_raw/elf.rs181
-rw-r--r--vendor/rustix/src/backend/linux_raw/event/epoll.rs22
-rw-r--r--vendor/rustix/src/backend/linux_raw/event/mod.rs1
-rw-r--r--vendor/rustix/src/backend/linux_raw/event/poll_fd.rs5
-rw-r--r--vendor/rustix/src/backend/linux_raw/event/syscalls.rs24
-rw-r--r--vendor/rustix/src/backend/linux_raw/event/types.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/inotify.rs13
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/mod.rs8
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/syscalls.rs135
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/types.rs55
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/errno.rs28
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/syscalls.rs70
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/types.rs9
-rw-r--r--vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/mm/types.rs21
-rw-r--r--vendor/rustix/src/backend/linux_raw/mod.rs11
-rw-r--r--vendor/rustix/src/backend/linux_raw/mount/types.rs31
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/addr.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/msghdr.rs39
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/send_recv.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/syscalls.rs139
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/write_sockaddr.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/auxv.rs258
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/init.rs149
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs47
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/mod.rs11
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs159
-rw-r--r--vendor/rustix/src/backend/linux_raw/pid/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/pipe/syscalls.rs15
-rw-r--r--vendor/rustix/src/backend/linux_raw/pipe/types.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/prctl/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/process/syscalls.rs37
-rw-r--r--vendor/rustix/src/backend/linux_raw/process/types.rs10
-rw-r--r--vendor/rustix/src/backend/linux_raw/pty/syscalls.rs38
-rw-r--r--vendor/rustix/src/backend/linux_raw/rand/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/rand/types.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/runtime/syscalls.rs17
-rw-r--r--vendor/rustix/src/backend/linux_raw/runtime/tls.rs39
-rw-r--r--vendor/rustix/src/backend/linux_raw/system/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/termios/syscalls.rs39
-rw-r--r--vendor/rustix/src/backend/linux_raw/thread/futex.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/thread/mod.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/thread/syscalls.rs5
-rw-r--r--vendor/rustix/src/backend/linux_raw/time/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/time/types.rs14
-rw-r--r--vendor/rustix/src/backend/linux_raw/ugid/syscalls.rs3
-rw-r--r--vendor/rustix/src/backend/linux_raw/vdso.rs27
-rw-r--r--vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs9
63 files changed, 925 insertions, 922 deletions
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/aarch64.rs b/vendor/rustix/src/backend/linux_raw/arch/aarch64.rs
index 0f4465d51..d4cf2472e 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/aarch64.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/aarch64.rs
@@ -53,7 +53,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"svc 0",
in("x8") nr.to_asm(),
in("x0") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/arm.rs b/vendor/rustix/src/backend/linux_raw/arch/arm.rs
index 9695c6028..77c1f82f4 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/arm.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/arm.rs
@@ -50,7 +50,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"svc 0",
in("r7") nr.to_asm(),
in("r0") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/mod.rs b/vendor/rustix/src/backend/linux_raw/arch/asm/mod.rs
deleted file mode 100644
index 3ea8eb74d..000000000
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/mod.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-//! Inline asm for making system calls.
-//!
-//! Compilers should really have intrinsics for making system calls. They're
-//! much like regular calls, with custom calling conventions, and calling
-//! conventions are otherwise the compiler's job. But for now, use inline asm.
-//!
-//! The calling conventions for Linux syscalls are [documented here].
-//!
-//! [documented here]: https://man7.org/linux/man-pages/man2/syscall.2.html
-
-#[cfg_attr(target_arch = "aarch64", path = "aarch64.rs")]
-#[cfg_attr(all(target_arch = "arm", not(thumb_mode)), path = "arm.rs")]
-#[cfg_attr(all(target_arch = "arm", thumb_mode), path = "thumb.rs")]
-#[cfg_attr(target_arch = "mips", path = "mips.rs")]
-#[cfg_attr(target_arch = "mips32r6", path = "mips32r6.rs")]
-#[cfg_attr(target_arch = "mips64", path = "mips64.rs")]
-#[cfg_attr(target_arch = "mips64r6", path = "mips64r6.rs")]
-#[cfg_attr(target_arch = "powerpc64", path = "powerpc64.rs")]
-#[cfg_attr(target_arch = "riscv64", path = "riscv64.rs")]
-#[cfg_attr(target_arch = "x86", path = "x86.rs")]
-#[cfg_attr(target_arch = "x86_64", path = "x86_64.rs")]
-mod target_arch;
-
-pub(in crate::backend) use target_arch::*;
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/mips.rs b/vendor/rustix/src/backend/linux_raw/arch/mips.rs
index b39a16847..37932e02b 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/mips.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/mips.rs
@@ -103,7 +103,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"syscall",
in("$2" /*$v0*/) nr.to_asm(),
in("$4" /*$a0*/) a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/mips32r6.rs b/vendor/rustix/src/backend/linux_raw/arch/mips32r6.rs
index 718e94fa7..c2d92447b 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/mips32r6.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/mips32r6.rs
@@ -103,7 +103,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"syscall",
in("$2" /*$v0*/) nr.to_asm(),
in("$4" /*$a0*/) a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/mips64.rs b/vendor/rustix/src/backend/linux_raw/arch/mips64.rs
index d3c7d341f..244daf3ef 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/mips64.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/mips64.rs
@@ -103,7 +103,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"syscall",
in("$2" /*$v0*/) nr.to_asm(),
in("$4" /*$a0*/) a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/mips64r6.rs b/vendor/rustix/src/backend/linux_raw/arch/mips64r6.rs
index 0a2ebebce..8c06d9ee9 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/mips64r6.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/mips64r6.rs
@@ -107,7 +107,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"syscall",
in("$2" /*$v0*/) nr.to_asm(),
in("$4" /*$a0*/) a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/mod.rs b/vendor/rustix/src/backend/linux_raw/arch/mod.rs
index 31a8c11f9..ac9e25fa7 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/mod.rs
@@ -3,6 +3,14 @@
//! This module also has a `choose` submodule which chooses a scheme and is
//! what most of the `rustix` syscalls use.
//!
+//! Compilers should really have intrinsics for making system calls. They're
+//! much like regular calls, with custom calling conventions, and calling
+//! conventions are otherwise the compiler's job. But for now, use inline asm.
+//!
+//! The calling conventions for Linux syscalls are [documented here].
+//!
+//! [documented here]: https://man7.org/linux/man-pages/man2/syscall.2.html
+//!
//! # Safety
//!
//! This contains the inline `asm` statements performing the syscall
@@ -15,6 +23,17 @@
// These functions always use the machine's syscall instruction, even when it
// isn't the fastest option available.
+#[cfg_attr(target_arch = "aarch64", path = "aarch64.rs")]
+#[cfg_attr(all(target_arch = "arm", not(thumb_mode)), path = "arm.rs")]
+#[cfg_attr(all(target_arch = "arm", thumb_mode), path = "thumb.rs")]
+#[cfg_attr(target_arch = "mips", path = "mips.rs")]
+#[cfg_attr(target_arch = "mips32r6", path = "mips32r6.rs")]
+#[cfg_attr(target_arch = "mips64", path = "mips64.rs")]
+#[cfg_attr(target_arch = "mips64r6", path = "mips64r6.rs")]
+#[cfg_attr(target_arch = "powerpc64", path = "powerpc64.rs")]
+#[cfg_attr(target_arch = "riscv64", path = "riscv64.rs")]
+#[cfg_attr(target_arch = "x86", path = "x86.rs")]
+#[cfg_attr(target_arch = "x86_64", path = "x86_64.rs")]
pub(in crate::backend) mod asm;
// On most architectures, the architecture syscall instruction is fast, so use
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/powerpc64.rs b/vendor/rustix/src/backend/linux_raw/arch/powerpc64.rs
index 8cca7dca7..14866c2dd 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/powerpc64.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/powerpc64.rs
@@ -15,7 +15,7 @@ use crate::backend::reg::{
use core::arch::asm;
#[inline]
-pub(in crate::backend) unsafe fn syscall0_readonly(nr: SyscallNumber) -> RetReg<R0> {
+pub(in crate::backend) unsafe fn syscall0_readonly(nr: SyscallNumber<'_>) -> RetReg<R0> {
let r0;
asm!(
"sc",
@@ -98,7 +98,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"sc",
in("r0") nr.to_asm(),
in("r3") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/riscv64.rs b/vendor/rustix/src/backend/linux_raw/arch/riscv64.rs
index b1e306266..7b8533d75 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/riscv64.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/riscv64.rs
@@ -50,7 +50,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"ecall",
in("a7") nr.to_asm(),
in("a0") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
);
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/thumb.rs b/vendor/rustix/src/backend/linux_raw/arch/thumb.rs
index 398a73dfe..73f9c1c26 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/thumb.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/thumb.rs
@@ -67,7 +67,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"svc 0",
nr = in(reg) nr.to_asm(),
in("r0") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/x86.rs b/vendor/rustix/src/backend/linux_raw/arch/x86.rs
index ddef4a854..581cde278 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/x86.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/x86.rs
@@ -144,8 +144,8 @@ pub(in crate::backend) unsafe fn indirect_syscall5(
let r0;
// Oof. a3 should go in esi, and `asm!` won't let us use that register as
// an operand. And we can't request stack slots. And there are no other
- // registers free. Use eax as a temporary pointer to a slice, since it
- // gets clobbered as the return value anyway.
+ // registers free. Use eax as a temporary pointer to a slice, since it gets
+ // clobbered as the return value anyway.
asm!(
"push esi",
"push DWORD PTR [eax + 0]",
@@ -163,7 +163,6 @@ pub(in crate::backend) unsafe fn indirect_syscall5(
FromAsm::from_asm(r0)
}
-#[allow(clippy::too_many_arguments)]
#[inline]
pub(in crate::backend) unsafe fn indirect_syscall6(
callee: SyscallType,
@@ -248,7 +247,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"int $$0x80",
in("eax") nr.to_asm(),
in("ebx") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/arch/asm/x86_64.rs b/vendor/rustix/src/backend/linux_raw/arch/x86_64.rs
index 084f5fee4..62f35d90f 100644
--- a/vendor/rustix/src/backend/linux_raw/arch/asm/x86_64.rs
+++ b/vendor/rustix/src/backend/linux_raw/arch/x86_64.rs
@@ -58,7 +58,7 @@ pub(in crate::backend) unsafe fn syscall1_noreturn(nr: SyscallNumber<'_>, a0: Ar
"syscall",
in("rax") nr.to_asm(),
in("rdi") a0.to_asm(),
- options(noreturn)
+ options(nostack, noreturn)
)
}
diff --git a/vendor/rustix/src/backend/linux_raw/c.rs b/vendor/rustix/src/backend/linux_raw/c.rs
index f336392bb..65ddb1466 100644
--- a/vendor/rustix/src/backend/linux_raw/c.rs
+++ b/vendor/rustix/src/backend/linux_raw/c.rs
@@ -9,6 +9,7 @@
pub type size_t = usize;
pub(crate) use linux_raw_sys::ctypes::*;
pub(crate) use linux_raw_sys::errno::EINVAL;
+pub(crate) use linux_raw_sys::ioctl::{FIONBIO, FIONREAD};
// Import the kernel's `uid_t` and `gid_t` if they're 32-bit.
#[cfg(not(any(target_arch = "arm", target_arch = "sparc", target_arch = "x86")))]
pub(crate) use linux_raw_sys::general::{__kernel_gid_t as gid_t, __kernel_uid_t as uid_t};
@@ -25,7 +26,7 @@ pub(crate) use linux_raw_sys::general::epoll_event;
feature = "fs",
all(
not(feature = "use-libc-auxv"),
- not(target_vendor = "mustang"),
+ not(feature = "use-explicitly-provided-auxv"),
any(
feature = "param",
feature = "runtime",
@@ -39,6 +40,8 @@ pub(crate) use linux_raw_sys::general::{
XATTR_REPLACE,
};
+pub(crate) use linux_raw_sys::ioctl::{BLKPBSZGET, BLKSSZGET, FICLONE};
+
#[cfg(feature = "io_uring")]
pub(crate) use linux_raw_sys::{general::open_how, io_uring::*};
@@ -65,10 +68,10 @@ pub(crate) use linux_raw_sys::{
IP_MULTICAST_TTL, IP_TTL, MSG_CMSG_CLOEXEC, MSG_CONFIRM, MSG_DONTROUTE, MSG_DONTWAIT,
MSG_EOR, MSG_ERRQUEUE, MSG_MORE, MSG_NOSIGNAL, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL,
SCM_CREDENTIALS, SCM_RIGHTS, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_RAW, SOCK_RDM,
- SOCK_SEQPACKET, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_LINGER,
- SO_PASSCRED, SO_RCVBUF, SO_RCVTIMEO_NEW, SO_RCVTIMEO_NEW as SO_RCVTIMEO, SO_RCVTIMEO_OLD,
- SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO_NEW, SO_SNDTIMEO_NEW as SO_SNDTIMEO, SO_SNDTIMEO_OLD,
- SO_TYPE, TCP_NODELAY,
+ SOCK_SEQPACKET, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_DOMAIN, SO_ERROR, SO_KEEPALIVE,
+ SO_LINGER, SO_PASSCRED, SO_RCVBUF, SO_RCVTIMEO_NEW, SO_RCVTIMEO_NEW as SO_RCVTIMEO,
+ SO_RCVTIMEO_OLD, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO_NEW, SO_SNDTIMEO_NEW as SO_SNDTIMEO,
+ SO_SNDTIMEO_OLD, SO_TYPE, TCP_NODELAY,
},
netlink::*,
};
@@ -76,12 +79,25 @@ pub(crate) use linux_raw_sys::{
#[cfg(any(feature = "process", feature = "runtime"))]
pub(crate) use linux_raw_sys::general::siginfo_t;
+#[cfg(any(feature = "process", feature = "runtime"))]
+pub(crate) const EXIT_SUCCESS: c_int = 0;
+#[cfg(any(feature = "process", feature = "runtime"))]
+pub(crate) const EXIT_FAILURE: c_int = 1;
#[cfg(feature = "process")]
-pub(crate) use linux_raw_sys::general::{
- CLD_CONTINUED, CLD_DUMPED, CLD_EXITED, CLD_KILLED, CLD_STOPPED, CLD_TRAPPED,
- O_NONBLOCK as PIDFD_NONBLOCK, P_ALL, P_PID, P_PIDFD,
+pub(crate) const EXIT_SIGNALED_SIGABRT: c_int = 128 + linux_raw_sys::general::SIGABRT as c_int;
+
+#[cfg(feature = "process")]
+pub(crate) use linux_raw_sys::{
+ general::{
+ CLD_CONTINUED, CLD_DUMPED, CLD_EXITED, CLD_KILLED, CLD_STOPPED, CLD_TRAPPED,
+ O_NONBLOCK as PIDFD_NONBLOCK, P_ALL, P_PID, P_PIDFD,
+ },
+ ioctl::TIOCSCTTY,
};
+#[cfg(feature = "pty")]
+pub(crate) use linux_raw_sys::ioctl::TIOCGPTPEER;
+
#[cfg(feature = "termios")]
pub(crate) use linux_raw_sys::{
general::{
@@ -99,7 +115,7 @@ pub(crate) use linux_raw_sys::{
VKILL, VLNEXT, VMIN, VQUIT, VREPRINT, VSTART, VSTOP, VSUSP, VSWTC, VT0, VT1, VTDLY, VTIME,
VWERASE, XCASE, XTABS,
},
- ioctl::{TCGETS2, TCSETS2, TCSETSF2, TCSETSW2},
+ ioctl::{TCGETS2, TCSETS2, TCSETSF2, TCSETSW2, TIOCEXCL, TIOCNXCL},
};
// On MIPS, `TCSANOW` et al have `TCSETS` added to them, so we need it to
diff --git a/vendor/rustix/src/backend/linux_raw/conv.rs b/vendor/rustix/src/backend/linux_raw/conv.rs
index c87136f8f..f915db140 100644
--- a/vendor/rustix/src/backend/linux_raw/conv.rs
+++ b/vendor/rustix/src/backend/linux_raw/conv.rs
@@ -186,45 +186,45 @@ pub(super) fn no_fd<'a, Num: ArgNumber>() -> ArgReg<'a, Num> {
}
#[inline]
-pub(super) fn slice_just_addr<T: Sized, Num: ArgNumber>(v: &[T]) -> ArgReg<Num> {
+pub(super) fn slice_just_addr<T: Sized, Num: ArgNumber>(v: &[T]) -> ArgReg<'_, Num> {
let mut_ptr = v.as_ptr() as *mut T;
raw_arg(mut_ptr.cast())
}
#[inline]
-pub(super) fn slice_just_addr_mut<T: Sized, Num: ArgNumber>(v: &mut [T]) -> ArgReg<Num> {
+pub(super) fn slice_just_addr_mut<T: Sized, Num: ArgNumber>(v: &mut [T]) -> ArgReg<'_, Num> {
raw_arg(v.as_mut_ptr().cast())
}
#[inline]
pub(super) fn slice<T: Sized, Num0: ArgNumber, Num1: ArgNumber>(
v: &[T],
-) -> (ArgReg<Num0>, ArgReg<Num1>) {
+) -> (ArgReg<'_, Num0>, ArgReg<'_, Num1>) {
(slice_just_addr(v), pass_usize(v.len()))
}
#[inline]
pub(super) fn slice_mut<T: Sized, Num0: ArgNumber, Num1: ArgNumber>(
v: &mut [T],
-) -> (ArgReg<Num0>, ArgReg<Num1>) {
+) -> (ArgReg<'_, Num0>, ArgReg<'_, Num1>) {
(raw_arg(v.as_mut_ptr().cast()), pass_usize(v.len()))
}
#[inline]
-pub(super) fn by_ref<T: Sized, Num: ArgNumber>(t: &T) -> ArgReg<Num> {
+pub(super) fn by_ref<T: Sized, Num: ArgNumber>(t: &T) -> ArgReg<'_, Num> {
let mut_ptr = as_ptr(t) as *mut T;
raw_arg(mut_ptr.cast())
}
#[inline]
-pub(super) fn by_mut<T: Sized, Num: ArgNumber>(t: &mut T) -> ArgReg<Num> {
+pub(super) fn by_mut<T: Sized, Num: ArgNumber>(t: &mut T) -> ArgReg<'_, Num> {
raw_arg(as_mut_ptr(t).cast())
}
/// Convert an optional mutable reference into a `usize` for passing to a
/// syscall.
#[inline]
-pub(super) fn opt_mut<T: Sized, Num: ArgNumber>(t: Option<&mut T>) -> ArgReg<Num> {
+pub(super) fn opt_mut<T: Sized, Num: ArgNumber>(t: Option<&mut T>) -> ArgReg<'_, Num> {
// This optimizes into the equivalent of `transmute(t)`, and has the
// advantage of not requiring `unsafe`.
match t {
@@ -237,7 +237,7 @@ pub(super) fn opt_mut<T: Sized, Num: ArgNumber>(t: Option<&mut T>) -> ArgReg<Num
/// syscall.
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
#[inline]
-pub(super) fn opt_ref<T: Sized, Num: ArgNumber>(t: Option<&T>) -> ArgReg<Num> {
+pub(super) fn opt_ref<T: Sized, Num: ArgNumber>(t: Option<&T>) -> ArgReg<'_, Num> {
// This optimizes into the equivalent of `transmute(t)`, and has the
// advantage of not requiring `unsafe`.
match t {
@@ -300,7 +300,7 @@ pub(super) fn socklen_t<'a, Num: ArgNumber>(i: socklen_t) -> ArgReg<'a, Num> {
feature = "fs",
all(
not(feature = "use-libc-auxv"),
- not(target_vendor = "mustang"),
+ not(feature = "use-explicitly-provided-auxv"),
any(
feature = "param",
feature = "runtime",
@@ -581,7 +581,7 @@ impl<'a, Num: ArgNumber> From<crate::event::EventfdFlags> for ArgReg<'a, Num> {
}
}
-#[cfg(feature = "event")]
+#[cfg(all(feature = "alloc", feature = "event"))]
impl<'a, Num: ArgNumber> From<crate::event::epoll::CreateFlags> for ArgReg<'a, Num> {
#[inline]
fn from(flags: crate::event::epoll::CreateFlags) -> Self {
diff --git a/vendor/rustix/src/backend/linux_raw/elf.rs b/vendor/rustix/src/backend/linux_raw/elf.rs
deleted file mode 100644
index 415f79f88..000000000
--- a/vendor/rustix/src/backend/linux_raw/elf.rs
+++ /dev/null
@@ -1,181 +0,0 @@
-//! The ELF ABI. 🧝
-
-#![allow(non_snake_case)]
-#![cfg_attr(
- all(not(target_vendor = "mustang"), feature = "use-libc-auxv"),
- allow(dead_code)
-)]
-
-pub(super) const SELFMAG: usize = 4;
-pub(super) const ELFMAG: [u8; SELFMAG] = [0x7f, b'E', b'L', b'F'];
-pub(super) const EI_CLASS: usize = 4;
-pub(super) const EI_DATA: usize = 5;
-pub(super) const EI_VERSION: usize = 6;
-pub(super) const EI_OSABI: usize = 7;
-pub(super) const EI_ABIVERSION: usize = 8;
-pub(super) const EV_CURRENT: u8 = 1;
-#[cfg(target_pointer_width = "32")]
-pub(super) const ELFCLASS: u8 = 1; // ELFCLASS32
-#[cfg(target_pointer_width = "64")]
-pub(super) const ELFCLASS: u8 = 2; // ELFCLASS64
-#[cfg(target_endian = "little")]
-pub(super) const ELFDATA: u8 = 1; // ELFDATA2LSB
-#[cfg(target_endian = "big")]
-pub(super) const ELFDATA: u8 = 2; // ELFDATA2MSB
-pub(super) const ELFOSABI_SYSV: u8 = 0;
-pub(super) const ELFOSABI_LINUX: u8 = 3;
-// At present all of our supported platforms use 0.
-pub(super) const ELFABIVERSION: u8 = 0;
-pub(super) const ET_DYN: u16 = 3;
-pub(super) const EI_NIDENT: usize = 16;
-pub(super) const SHN_UNDEF: u16 = 0;
-pub(super) const SHN_ABS: u16 = 0xfff1;
-pub(super) const PN_XNUM: u16 = 0xffff;
-pub(super) const PT_LOAD: u32 = 1;
-pub(super) const PT_DYNAMIC: u32 = 2;
-pub(super) const PT_INTERP: u32 = 3;
-pub(super) const PT_PHDR: u32 = 6;
-pub(super) const PT_TLS: u32 = 7;
-pub(super) const PT_GNU_STACK: u32 = 0x6474_e551;
-pub(super) const PT_GNU_RELRO: u32 = 0x6474_e552;
-pub(super) const PF_X: u32 = 1;
-pub(super) const PF_W: u32 = 2;
-pub(super) const PF_R: u32 = 4;
-pub(super) const DT_NULL: i32 = 0;
-pub(super) const DT_HASH: i32 = 4;
-pub(super) const DT_STRTAB: i32 = 5;
-pub(super) const DT_SYMTAB: i32 = 6;
-pub(super) const DT_SYMENT: i32 = 11;
-pub(super) const DT_VERSYM: i32 = 0x6fff_fff0;
-pub(super) const DT_VERDEF: i32 = 0x6fff_fffc;
-pub(super) const STB_WEAK: u8 = 2;
-pub(super) const STB_GLOBAL: u8 = 1;
-pub(super) const STT_NOTYPE: u8 = 0;
-pub(super) const STT_FUNC: u8 = 2;
-pub(super) const STN_UNDEF: u32 = 0;
-pub(super) const VER_FLG_BASE: u16 = 0x1;
-pub(super) const VER_DEF_CURRENT: u16 = 1;
-pub(super) const STV_DEFAULT: u8 = 0;
-#[cfg(target_arch = "arm")]
-pub(super) const EM_CURRENT: u16 = 40; // EM_ARM
-#[cfg(target_arch = "x86")]
-pub(super) const EM_CURRENT: u16 = 3; // EM_386
-#[cfg(target_arch = "powerpc64")]
-pub(super) const EM_CURRENT: u16 = 21; // EM_PPC64
-#[cfg(any(
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "mips64",
- target_arch = "mips64r6"
-))]
-pub(super) const EM_CURRENT: u16 = 8; // EM_MIPS
-#[cfg(target_arch = "x86_64")]
-pub(super) const EM_CURRENT: u16 = 62; // EM_X86_64
-#[cfg(target_arch = "aarch64")]
-pub(super) const EM_CURRENT: u16 = 183; // EM_AARCH64
-#[cfg(target_arch = "riscv64")]
-pub(super) const EM_CURRENT: u16 = 243; // EM_RISCV
-
-#[inline]
-pub(super) const fn ELF_ST_VISIBILITY(o: u8) -> u8 {
- o & 0x03
-}
-
-#[inline]
-pub(super) const fn ELF_ST_BIND(val: u8) -> u8 {
- val >> 4
-}
-
-#[inline]
-pub(super) const fn ELF_ST_TYPE(val: u8) -> u8 {
- val & 0xf
-}
-
-#[repr(C)]
-pub(super) struct Elf_Ehdr {
- pub(super) e_ident: [u8; EI_NIDENT],
- pub(super) e_type: u16,
- pub(super) e_machine: u16,
- pub(super) e_version: u32,
- pub(super) e_entry: usize,
- pub(super) e_phoff: usize,
- pub(super) e_shoff: usize,
- pub(super) e_flags: u32,
- pub(super) e_ehsize: u16,
- pub(super) e_phentsize: u16,
- pub(super) e_phnum: u16,
- pub(super) e_shentsize: u16,
- pub(super) e_shnum: u16,
- pub(super) e_shstrndx: u16,
-}
-
-#[cfg(target_pointer_width = "32")]
-#[repr(C)]
-pub(super) struct Elf_Phdr {
- pub(super) p_type: u32,
- pub(super) p_offset: usize,
- pub(super) p_vaddr: usize,
- pub(super) p_paddr: usize,
- pub(super) p_filesz: usize,
- pub(super) p_memsz: usize,
- pub(super) p_flags: u32,
- pub(super) p_align: usize,
-}
-
-#[cfg(target_pointer_width = "64")]
-#[repr(C)]
-pub(super) struct Elf_Phdr {
- pub(super) p_type: u32,
- pub(super) p_flags: u32,
- pub(super) p_offset: usize,
- pub(super) p_vaddr: usize,
- pub(super) p_paddr: usize,
- pub(super) p_filesz: usize,
- pub(super) p_memsz: usize,
- pub(super) p_align: usize,
-}
-
-#[cfg(target_pointer_width = "32")]
-#[repr(C)]
-pub(super) struct Elf_Sym {
- pub(super) st_name: u32,
- pub(super) st_value: usize,
- pub(super) st_size: usize,
- pub(super) st_info: u8,
- pub(super) st_other: u8,
- pub(super) st_shndx: u16,
-}
-
-#[cfg(target_pointer_width = "64")]
-#[repr(C)]
-pub(super) struct Elf_Sym {
- pub(super) st_name: u32,
- pub(super) st_info: u8,
- pub(super) st_other: u8,
- pub(super) st_shndx: u16,
- pub(super) st_value: usize,
- pub(super) st_size: usize,
-}
-
-#[repr(C)]
-pub(super) struct Elf_Dyn {
- pub(super) d_tag: i32,
- pub(super) d_val: usize,
-}
-
-#[repr(C)]
-pub(super) struct Elf_Verdef {
- pub(super) vd_version: u16,
- pub(super) vd_flags: u16,
- pub(super) vd_ndx: u16,
- pub(super) vd_cnt: u16,
- pub(super) vd_hash: u32,
- pub(super) vd_aux: u32,
- pub(super) vd_next: u32,
-}
-
-#[repr(C)]
-pub(super) struct Elf_Verdaux {
- pub(super) vda_name: u32,
- pub(super) _vda_next: u32,
-}
diff --git a/vendor/rustix/src/backend/linux_raw/event/epoll.rs b/vendor/rustix/src/backend/linux_raw/event/epoll.rs
index 6577feb51..ecd48b784 100644
--- a/vendor/rustix/src/backend/linux_raw/event/epoll.rs
+++ b/vendor/rustix/src/backend/linux_raw/event/epoll.rs
@@ -92,6 +92,9 @@ bitflags! {
pub struct CreateFlags: c::c_uint {
/// `EPOLL_CLOEXEC`
const CLOEXEC = linux_raw_sys::general::EPOLL_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -144,6 +147,9 @@ bitflags! {
/// `EPOLLEXCLUSIVE`
const EXCLUSIVE = linux_raw_sys::general::EPOLLEXCLUSIVE as u32;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -160,8 +166,8 @@ pub fn create(flags: CreateFlags) -> io::Result<OwnedFd> {
/// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
/// epoll object.
///
-/// This registers interest in any of the events set in `events` occurring
-/// on the file descriptor associated with `data`.
+/// This registers interest in any of the events set in `events` occurring on
+/// the file descriptor associated with `data`.
///
/// If [`delete`] is not called on the I/O source passed into this function
/// before the I/O source is `close`d, then the `epoll` will act as if the I/O
@@ -191,8 +197,8 @@ pub fn add(
}
}
-/// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in
-/// a given epoll object.
+/// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in a
+/// given epoll object.
///
/// This sets the events of interest with `target` to `events`.
#[doc(alias = "epoll_ctl")]
@@ -218,8 +224,8 @@ pub fn modify(
}
}
-/// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in
-/// a given epoll object.
+/// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in a
+/// given epoll object.
#[doc(alias = "epoll_ctl")]
#[inline]
pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
@@ -317,8 +323,8 @@ impl EventData {
/// Return the value as a `u64`.
///
- /// If the stored value was a pointer, the pointer is zero-extended to
- /// a `u64`.
+ /// If the stored value was a pointer, the pointer is zero-extended to a
+ /// `u64`.
#[inline]
pub fn u64(self) -> u64 {
unsafe { self.as_u64 }
diff --git a/vendor/rustix/src/backend/linux_raw/event/mod.rs b/vendor/rustix/src/backend/linux_raw/event/mod.rs
index 605de2538..4148a8c7f 100644
--- a/vendor/rustix/src/backend/linux_raw/event/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/event/mod.rs
@@ -1,3 +1,4 @@
+#[cfg(feature = "alloc")]
pub mod epoll;
pub(crate) mod poll_fd;
pub(crate) mod syscalls;
diff --git a/vendor/rustix/src/backend/linux_raw/event/poll_fd.rs b/vendor/rustix/src/backend/linux_raw/event/poll_fd.rs
index 906efe0ef..c56c9152d 100644
--- a/vendor/rustix/src/backend/linux_raw/event/poll_fd.rs
+++ b/vendor/rustix/src/backend/linux_raw/event/poll_fd.rs
@@ -30,6 +30,9 @@ bitflags! {
const NVAL = linux_raw_sys::general::POLLNVAL as u16;
/// `POLLRDHUP`
const RDHUP = linux_raw_sys::general::POLLRDHUP as u16;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -81,7 +84,7 @@ impl<'fd> PollFd<'fd> {
/// Returns the ready events.
#[inline]
pub fn revents(&self) -> PollFlags {
- // Use `unwrap()` here because in theory we know we know all the bits
+ // Use `.unwrap()` here because in theory we know we know all the bits
// the OS might set here, but OS's have added extensions in the past.
PollFlags::from_bits(self.revents).unwrap()
}
diff --git a/vendor/rustix/src/backend/linux_raw/event/syscalls.rs b/vendor/rustix/src/backend/linux_raw/event/syscalls.rs
index 6d6b35d75..a8003b004 100644
--- a/vendor/rustix/src/backend/linux_raw/event/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/event/syscalls.rs
@@ -3,17 +3,20 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
-use crate::backend::conv::{
- by_ref, c_int, c_uint, pass_usize, raw_fd, ret, ret_owned_fd, ret_usize, slice_mut, zero,
-};
-use crate::event::{epoll, EventfdFlags, PollFd};
-use crate::fd::{BorrowedFd, OwnedFd};
+use crate::backend::conv::{c_int, c_uint, ret_owned_fd, ret_usize, slice_mut};
+use crate::event::{EventfdFlags, PollFd};
+use crate::fd::OwnedFd;
use crate::io;
-use linux_raw_sys::general::{EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD};
+#[cfg(feature = "alloc")]
+use {
+ crate::backend::conv::{by_ref, pass_usize, raw_fd, ret, zero},
+ crate::event::epoll,
+ crate::fd::BorrowedFd,
+ linux_raw_sys::general::{EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD},
+};
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
use {
crate::backend::conv::{opt_ref, size_of},
@@ -49,11 +52,13 @@ pub(crate) fn poll(fds: &mut [PollFd<'_>], timeout: c::c_int) -> io::Result<usiz
}
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn epoll_create(flags: epoll::CreateFlags) -> io::Result<OwnedFd> {
unsafe { ret_owned_fd(syscall_readonly!(__NR_epoll_create1, flags)) }
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) unsafe fn epoll_add(
epfd: BorrowedFd<'_>,
@@ -69,6 +74,7 @@ pub(crate) unsafe fn epoll_add(
))
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) unsafe fn epoll_mod(
epfd: BorrowedFd<'_>,
@@ -84,6 +90,7 @@ pub(crate) unsafe fn epoll_mod(
))
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) unsafe fn epoll_del(epfd: BorrowedFd<'_>, fd: c::c_int) -> io::Result<()> {
ret(syscall_readonly!(
@@ -95,6 +102,7 @@ pub(crate) unsafe fn epoll_del(epfd: BorrowedFd<'_>, fd: c::c_int) -> io::Result
))
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn epoll_wait(
epfd: BorrowedFd<'_>,
diff --git a/vendor/rustix/src/backend/linux_raw/event/types.rs b/vendor/rustix/src/backend/linux_raw/event/types.rs
index e6273959c..3821f8f64 100644
--- a/vendor/rustix/src/backend/linux_raw/event/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/event/types.rs
@@ -14,5 +14,8 @@ bitflags! {
const NONBLOCK = linux_raw_sys::general::EFD_NONBLOCK;
/// `EFD_SEMAPHORE`
const SEMAPHORE = linux_raw_sys::general::EFD_SEMAPHORE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/fs/inotify.rs b/vendor/rustix/src/backend/linux_raw/fs/inotify.rs
index cb9d87b82..ef205ffdf 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/inotify.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/inotify.rs
@@ -17,6 +17,9 @@ bitflags! {
const CLOEXEC = linux_raw_sys::general::IN_CLOEXEC;
/// `IN_NONBLOCK`
const NONBLOCK = linux_raw_sys::general::IN_NONBLOCK;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -71,6 +74,9 @@ bitflags! {
const ONESHOT = linux_raw_sys::general::IN_ONESHOT;
/// `IN_ONLYDIR`
const ONLYDIR = linux_raw_sys::general::IN_ONLYDIR;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -99,14 +105,13 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
path: P,
flags: WatchFlags,
) -> io::Result<i32> {
- let path = path.as_cow_c_str().unwrap();
- syscalls::inotify_add_watch(inot, &path, flags)
+ path.into_with_c_str(|path| syscalls::inotify_add_watch(inot, path, flags))
}
/// `inotify_rm_watch(self, wd)`—Removes a watch from this inotify
///
-/// The watch descriptor provided should have previously been returned
-/// by [`inotify_add_watch`] and not previously have been removed.
+/// The watch descriptor provided should have previously been returned by
+/// [`inotify_add_watch`] and not previously have been removed.
#[doc(alias = "inotify_rm_watch")]
#[inline]
pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
diff --git a/vendor/rustix/src/backend/linux_raw/fs/mod.rs b/vendor/rustix/src/backend/linux_raw/fs/mod.rs
index acf43ce4f..ba72c5b6d 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/mod.rs
@@ -1,5 +1,13 @@
+#[cfg(feature = "alloc")]
pub(crate) mod dir;
pub mod inotify;
pub(crate) mod makedev;
pub(crate) mod syscalls;
pub(crate) mod types;
+
+// TODO: Fix linux-raw-sys to define ioctl codes for sparc.
+#[cfg(all(linux_kernel, any(target_arch = "sparc", target_arch = "sparc64")))]
+pub(crate) const EXT4_IOC_RESIZE_FS: u32 = 0x8008_6610;
+
+#[cfg(all(linux_kernel, not(any(target_arch = "sparc", target_arch = "sparc64"))))]
+pub(crate) use linux_raw_sys::ioctl::EXT4_IOC_RESIZE_FS;
diff --git a/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs b/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
index b3d4cd66c..e72afb8ab 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
@@ -32,15 +32,14 @@ use crate::fs::{
StatVfsMountFlags, StatxFlags, Timestamps, Uid, XattrFlags,
};
use crate::io;
-use core::mem::{transmute, zeroed, MaybeUninit};
+use core::mem::MaybeUninit;
#[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))]
use linux_raw_sys::general::stat as linux_stat64;
use linux_raw_sys::general::{
- __kernel_fsid_t, __kernel_timespec, open_how, statx, AT_EACCESS, AT_FDCWD, AT_REMOVEDIR,
- AT_SYMLINK_NOFOLLOW, F_ADD_SEALS, F_GETFL, F_GET_SEALS, F_SETFL, SEEK_CUR, SEEK_DATA, SEEK_END,
- SEEK_HOLE, SEEK_SET, STATX__RESERVED,
+ __kernel_fsid_t, open_how, statx, AT_EACCESS, AT_FDCWD, AT_REMOVEDIR, AT_SYMLINK_NOFOLLOW,
+ F_ADD_SEALS, F_GETFL, F_GET_SEALS, F_SETFL, SEEK_CUR, SEEK_DATA, SEEK_END, SEEK_HOLE, SEEK_SET,
+ STATX__RESERVED,
};
-use linux_raw_sys::ioctl::{BLKPBSZGET, BLKSSZGET, EXT4_IOC_RESIZE_FS, FICLONE};
#[cfg(target_pointer_width = "32")]
use {
crate::backend::conv::{hi, lo, slice_just_addr},
@@ -160,6 +159,30 @@ pub(crate) fn chownat(
}
#[inline]
+pub(crate) fn chown(path: &CStr, owner: Option<Uid>, group: Option<Gid>) -> io::Result<()> {
+ // Most architectures have a `chown` syscall.
+ #[cfg(not(any(target_arch = "aarch64", target_arch = "riscv64")))]
+ unsafe {
+ let (ow, gr) = crate::ugid::translate_fchown_args(owner, group);
+ ret(syscall_readonly!(__NR_chown, path, c_uint(ow), c_uint(gr)))
+ }
+
+ // Aarch64 and RISC-V don't, so use `fchownat`.
+ #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
+ unsafe {
+ let (ow, gr) = crate::ugid::translate_fchown_args(owner, group);
+ ret(syscall_readonly!(
+ __NR_fchownat,
+ raw_fd(AT_FDCWD),
+ path,
+ c_uint(ow),
+ c_uint(gr),
+ zero()
+ ))
+ }
+}
+
+#[inline]
pub(crate) fn fchown(fd: BorrowedFd<'_>, owner: Option<Uid>, group: Option<Gid>) -> io::Result<()> {
unsafe {
let (ow, gr) = crate::ugid::translate_fchown_args(owner, group);
@@ -207,9 +230,7 @@ pub(crate) fn seek(fd: BorrowedFd<'_>, pos: SeekFrom) -> io::Result<u64> {
}
SeekFrom::End(offset) => (SEEK_END, offset),
SeekFrom::Current(offset) => (SEEK_CUR, offset),
- #[cfg(target_os = "linux")]
SeekFrom::Data(offset) => (SEEK_DATA, offset),
- #[cfg(target_os = "linux")]
SeekFrom::Hole(offset) => (SEEK_HOLE, offset),
};
_seek(fd, offset, whence)
@@ -915,6 +936,7 @@ fn statfs_to_statvfs(statfs: StatFs) -> StatVfs {
}
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
let (buf_addr_mut, buf_len) = slice_mut(buf);
@@ -929,6 +951,7 @@ pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
}
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn readlinkat(
dirfd: BorrowedFd<'_>,
@@ -1028,38 +1051,37 @@ pub(crate) fn fcntl_lock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::R
FlockOperation::NonBlockingUnlock => (F_SETLK, F_UNLCK),
};
- unsafe {
- let lock = flock {
- l_type: l_type as _,
+ let lock = flock {
+ l_type: l_type as _,
- // When `l_len` is zero, this locks all the bytes from
- // `l_whence`/`l_start` to the end of the file, even as the
- // file grows dynamically.
- l_whence: SEEK_SET as _,
- l_start: 0,
- l_len: 0,
+ // When `l_len` is zero, this locks all the bytes from
+ // `l_whence`/`l_start` to the end of the file, even as the
+ // file grows dynamically.
+ l_whence: SEEK_SET as _,
+ l_start: 0,
+ l_len: 0,
- ..zeroed()
- };
+ // Unused.
+ l_pid: 0,
+ };
- #[cfg(target_pointer_width = "32")]
- {
- ret(syscall_readonly!(
- __NR_fcntl64,
- fd,
- c_uint(cmd),
- by_ref(&lock)
- ))
- }
- #[cfg(target_pointer_width = "64")]
- {
- ret(syscall_readonly!(
- __NR_fcntl,
- fd,
- c_uint(cmd),
- by_ref(&lock)
- ))
- }
+ #[cfg(target_pointer_width = "32")]
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_fcntl64,
+ fd,
+ c_uint(cmd),
+ by_ref(&lock)
+ ))
+ }
+ #[cfg(target_pointer_width = "64")]
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_fcntl,
+ fd,
+ c_uint(cmd),
+ by_ref(&lock)
+ ))
}
}
@@ -1235,6 +1257,7 @@ pub(crate) fn mkdirat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Res
unsafe { ret(syscall_readonly!(__NR_mkdirat, dirfd, path, mode)) }
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn getdents(fd: BorrowedFd<'_>, dirent: &mut [u8]) -> io::Result<usize> {
let (dirent_addr_mut, dirent_len) = slice_mut(dirent);
@@ -1269,9 +1292,6 @@ fn _utimensat(
times: &Timestamps,
flags: AtFlags,
) -> io::Result<()> {
- // Assert that `Timestamps` has the expected layout.
- let _ = unsafe { transmute::<Timestamps, [__kernel_timespec; 2]>(times.clone()) };
-
// `utimensat_time64` was introduced in Linux 5.1. The old `utimensat`
// syscall is not y2038-compatible on 32-bit architectures.
#[cfg(target_pointer_width = "32")]
@@ -1626,37 +1646,10 @@ pub(crate) fn fremovexattr(fd: BorrowedFd<'_>, name: &CStr) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_fremovexattr, fd, name)) }
}
-#[inline]
-pub(crate) fn ioctl_blksszget(fd: BorrowedFd) -> io::Result<u32> {
- let mut result = MaybeUninit::<c::c_uint>::uninit();
- unsafe {
- ret(syscall!(__NR_ioctl, fd, c_uint(BLKSSZGET), &mut result))?;
- Ok(result.assume_init() as u32)
- }
-}
-
-#[inline]
-pub(crate) fn ioctl_blkpbszget(fd: BorrowedFd) -> io::Result<u32> {
- let mut result = MaybeUninit::<c::c_uint>::uninit();
- unsafe {
- ret(syscall!(__NR_ioctl, fd, c_uint(BLKPBSZGET), &mut result))?;
- Ok(result.assume_init() as u32)
- }
-}
-
-#[inline]
-pub(crate) fn ioctl_ficlone(fd: BorrowedFd<'_>, src_fd: BorrowedFd<'_>) -> io::Result<()> {
- unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(FICLONE), src_fd)) }
-}
+#[test]
+fn test_sizes() {
+ assert_eq_size!(linux_raw_sys::general::__kernel_loff_t, u64);
-#[inline]
-pub(crate) fn ext4_ioc_resize_fs(fd: BorrowedFd<'_>, blocks: u64) -> io::Result<()> {
- unsafe {
- ret(syscall_readonly!(
- __NR_ioctl,
- fd,
- c_uint(EXT4_IOC_RESIZE_FS),
- by_ref(&blocks)
- ))
- }
+ // Assert that `Timestamps` has the expected layout.
+ assert_eq_size!([linux_raw_sys::general::__kernel_timespec; 2], Timestamps);
}
diff --git a/vendor/rustix/src/backend/linux_raw/fs/types.rs b/vendor/rustix/src/backend/linux_raw/fs/types.rs
index e18dc0b4d..6e2e14f1e 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/types.rs
@@ -19,6 +19,9 @@ bitflags! {
/// `F_OK`
const EXISTS = linux_raw_sys::general::F_OK;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -57,6 +60,9 @@ bitflags! {
/// `AT_STATX_DONT_SYNC`
const STATX_DONT_SYNC = linux_raw_sys::general::AT_STATX_DONT_SYNC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -113,6 +119,9 @@ bitflags! {
/// `S_ISVTX`
const SVTX = linux_raw_sys::general::S_ISVTX;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -210,6 +219,8 @@ bitflags! {
const WRONLY = linux_raw_sys::general::O_WRONLY;
/// `O_RDWR`
+ ///
+ /// This is not equal to `RDONLY | WRONLY`. It's a distinct flag.
const RDWR = linux_raw_sys::general::O_RDWR;
/// `O_NOCTTY`
@@ -238,6 +249,9 @@ bitflags! {
/// `O_DIRECT`
const DIRECT = linux_raw_sys::general::O_DIRECT;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -265,6 +279,9 @@ bitflags! {
/// `RESOLVE_CACHED` (since Linux 5.12)
const CACHED = linux_raw_sys::general::RESOLVE_CACHED as u64;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -283,6 +300,9 @@ bitflags! {
/// `RENAME_WHITEOUT`
const WHITEOUT = linux_raw_sys::general::RENAME_WHITEOUT;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -432,6 +452,9 @@ bitflags! {
const HUGE_2GB = linux_raw_sys::general::MFD_HUGE_2GB;
/// `MFD_HUGE_16GB`
const HUGE_16GB = linux_raw_sys::general::MFD_HUGE_16GB;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -444,16 +467,19 @@ bitflags! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct SealFlags: u32 {
- /// `F_SEAL_SEAL`.
- const SEAL = linux_raw_sys::general::F_SEAL_SEAL;
- /// `F_SEAL_SHRINK`.
- const SHRINK = linux_raw_sys::general::F_SEAL_SHRINK;
- /// `F_SEAL_GROW`.
- const GROW = linux_raw_sys::general::F_SEAL_GROW;
- /// `F_SEAL_WRITE`.
- const WRITE = linux_raw_sys::general::F_SEAL_WRITE;
- /// `F_SEAL_FUTURE_WRITE` (since Linux 5.1)
- const FUTURE_WRITE = linux_raw_sys::general::F_SEAL_FUTURE_WRITE;
+ /// `F_SEAL_SEAL`.
+ const SEAL = linux_raw_sys::general::F_SEAL_SEAL;
+ /// `F_SEAL_SHRINK`.
+ const SHRINK = linux_raw_sys::general::F_SEAL_SHRINK;
+ /// `F_SEAL_GROW`.
+ const GROW = linux_raw_sys::general::F_SEAL_GROW;
+ /// `F_SEAL_WRITE`.
+ const WRITE = linux_raw_sys::general::F_SEAL_WRITE;
+ /// `F_SEAL_FUTURE_WRITE` (since Linux 5.1)
+ const FUTURE_WRITE = linux_raw_sys::general::F_SEAL_FUTURE_WRITE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -511,6 +537,9 @@ bitflags! {
/// `STATX_ALL`
const ALL = linux_raw_sys::general::STATX_ALL;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -535,6 +564,9 @@ bitflags! {
const INSERT_RANGE = linux_raw_sys::general::FALLOC_FL_INSERT_RANGE;
/// `FALLOC_FL_UNSHARE_RANGE`
const UNSHARE_RANGE = linux_raw_sys::general::FALLOC_FL_UNSHARE_RANGE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -569,6 +601,9 @@ bitflags! {
/// `ST_SYNCHRONOUS`
const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS as u64;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/io/errno.rs b/vendor/rustix/src/backend/linux_raw/io/errno.rs
index af057e2da..7730a7237 100644
--- a/vendor/rustix/src/backend/linux_raw/io/errno.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/errno.rs
@@ -16,10 +16,32 @@ use crate::backend::reg::{RetNumber, RetReg};
use crate::io;
use linux_raw_sys::errno;
-/// The error type for `rustix` APIs.
+/// `errno`—An error code.
///
-/// This is similar to `std::io::Error`, but only holds an OS error code,
-/// and no extra error value.
+/// The error type for `rustix` APIs. This is similar to [`std::io::Error`],
+/// but only holds an OS error code, and no extra error value.
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+/// - [Winsock2]
+/// - [FreeBSD]
+/// - [NetBSD]
+/// - [OpenBSD]
+/// - [DragonFly BSD]
+/// - [illumos]
+/// - [glibc]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
+/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
+/// [Winsock2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
+/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
+/// [NetBSD]: https://man.netbsd.org/errno.2
+/// [OpenBSD]: https://man.openbsd.org/errno.2
+/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=errno&section=2
+/// [illumos]: https://illumos.org/man/3C/errno
+/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
+/// [`std::io::Error`]: Result
#[repr(transparent)]
#[doc(alias = "errno")]
#[derive(Eq, PartialEq, Hash, Copy, Clone)]
diff --git a/vendor/rustix/src/backend/linux_raw/io/syscalls.rs b/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
index 88eed3d72..d2cbba0c3 100644
--- a/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
@@ -10,16 +10,11 @@
use crate::backend::conv::loff_t_from_u64;
#[cfg(all(
target_pointer_width = "32",
- any(
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "power"
- ),
+ any(target_arch = "arm", target_arch = "mips", target_arch = "mips32r6"),
))]
use crate::backend::conv::zero;
use crate::backend::conv::{
- by_ref, c_uint, raw_fd, ret, ret_c_uint, ret_discarded_fd, ret_owned_fd, ret_usize, slice,
+ c_uint, raw_fd, ret, ret_c_int, ret_c_uint, ret_discarded_fd, ret_owned_fd, ret_usize, slice,
slice_mut,
};
#[cfg(target_pointer_width = "32")]
@@ -27,12 +22,11 @@ use crate::backend::conv::{hi, lo};
use crate::backend::{c, MAX_IOV};
use crate::fd::{AsFd, BorrowedFd, OwnedFd, RawFd};
use crate::io::{self, DupFlags, FdFlags, IoSlice, IoSliceMut, ReadWriteFlags};
+use crate::ioctl::{IoctlOutput, RawOpcode};
#[cfg(all(feature = "fs", feature = "net"))]
use crate::net::{RecvFlags, SendFlags};
use core::cmp;
-use core::mem::MaybeUninit;
use linux_raw_sys::general::{F_DUPFD_CLOEXEC, F_GETFD, F_SETFD};
-use linux_raw_sys::ioctl::{FIONBIO, FIONREAD};
#[inline]
pub(crate) fn read(fd: BorrowedFd<'_>, buf: &mut [u8]) -> io::Result<usize> {
@@ -48,12 +42,7 @@ pub(crate) fn pread(fd: BorrowedFd<'_>, buf: &mut [u8], pos: u64) -> io::Result<
// <https://github.com/torvalds/linux/blob/fcadab740480e0e0e9fa9bd272acd409884d431a/arch/arm64/kernel/sys32.c#L75>
#[cfg(all(
target_pointer_width = "32",
- any(
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "power"
- ),
+ any(target_arch = "arm", target_arch = "mips", target_arch = "mips32r6"),
))]
unsafe {
ret_usize(syscall!(
@@ -68,12 +57,7 @@ pub(crate) fn pread(fd: BorrowedFd<'_>, buf: &mut [u8], pos: u64) -> io::Result<
}
#[cfg(all(
target_pointer_width = "32",
- not(any(
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "power"
- )),
+ not(any(target_arch = "arm", target_arch = "mips", target_arch = "mips32r6")),
))]
unsafe {
ret_usize(syscall!(
@@ -183,12 +167,7 @@ pub(crate) fn pwrite(fd: BorrowedFd<'_>, buf: &[u8], pos: u64) -> io::Result<usi
// <https://github.com/torvalds/linux/blob/fcadab740480e0e0e9fa9bd272acd409884d431a/arch/arm64/kernel/sys32.c#L81-L83>
#[cfg(all(
target_pointer_width = "32",
- any(
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "power"
- ),
+ any(target_arch = "arm", target_arch = "mips", target_arch = "mips32r6"),
))]
unsafe {
ret_usize(syscall_readonly!(
@@ -203,12 +182,7 @@ pub(crate) fn pwrite(fd: BorrowedFd<'_>, buf: &[u8], pos: u64) -> io::Result<usi
}
#[cfg(all(
target_pointer_width = "32",
- not(any(
- target_arch = "arm",
- target_arch = "mips",
- target_arch = "mips32r6",
- target_arch = "power"
- )),
+ not(any(target_arch = "arm", target_arch = "mips", target_arch = "mips32r6")),
))]
unsafe {
ret_usize(syscall_readonly!(
@@ -307,25 +281,21 @@ pub(crate) unsafe fn close(fd: RawFd) {
}
#[inline]
-pub(crate) fn ioctl_fionread(fd: BorrowedFd<'_>) -> io::Result<u64> {
- unsafe {
- let mut result = MaybeUninit::<c::c_int>::uninit();
- ret(syscall!(__NR_ioctl, fd, c_uint(FIONREAD), &mut result))?;
- Ok(result.assume_init() as u64)
- }
+pub(crate) unsafe fn ioctl(
+ fd: BorrowedFd<'_>,
+ request: RawOpcode,
+ arg: *mut c::c_void,
+) -> io::Result<IoctlOutput> {
+ ret_c_int(syscall!(__NR_ioctl, fd, c_uint(request), arg))
}
#[inline]
-pub(crate) fn ioctl_fionbio(fd: BorrowedFd<'_>, value: bool) -> io::Result<()> {
- unsafe {
- let data = c::c_int::from(value);
- ret(syscall_readonly!(
- __NR_ioctl,
- fd,
- c_uint(FIONBIO),
- by_ref(&data)
- ))
- }
+pub(crate) unsafe fn ioctl_readonly(
+ fd: BorrowedFd<'_>,
+ request: RawOpcode,
+ arg: *mut c::c_void,
+) -> io::Result<IoctlOutput> {
+ ret_c_int(syscall_readonly!(__NR_ioctl, fd, c_uint(request), arg))
}
#[cfg(all(feature = "fs", feature = "net"))]
@@ -376,6 +346,7 @@ pub(crate) fn dup(fd: BorrowedFd<'_>) -> io::Result<OwnedFd> {
unsafe { ret_owned_fd(syscall_readonly!(__NR_dup, fd)) }
}
+#[allow(clippy::needless_pass_by_ref_mut)]
#[inline]
pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &mut OwnedFd) -> io::Result<()> {
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
@@ -392,6 +363,7 @@ pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &mut OwnedFd) -> io::Result<()> {
}
}
+#[allow(clippy::needless_pass_by_ref_mut)]
#[inline]
pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, flags: DupFlags) -> io::Result<()> {
unsafe { ret_discarded_fd(syscall_readonly!(__NR_dup3, fd, new.as_fd(), flags)) }
diff --git a/vendor/rustix/src/backend/linux_raw/io/types.rs b/vendor/rustix/src/backend/linux_raw/io/types.rs
index c06134440..fb7e913a0 100644
--- a/vendor/rustix/src/backend/linux_raw/io/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/types.rs
@@ -11,6 +11,9 @@ bitflags! {
pub struct FdFlags: c::c_uint {
/// `FD_CLOEXEC`
const CLOEXEC = linux_raw_sys::general::FD_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -32,6 +35,9 @@ bitflags! {
const NOWAIT = linux_raw_sys::general::RWF_NOWAIT;
/// `RWF_APPEND` (since Linux 4.16)
const APPEND = linux_raw_sys::general::RWF_APPEND;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -44,5 +50,8 @@ bitflags! {
pub struct DupFlags: c::c_uint {
/// `O_CLOEXEC`
const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs b/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs
index 90c82c129..d10cd1395 100644
--- a/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend::syscalls` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::{by_mut, c_uint, pass_usize, ret_c_uint, ret_owned_fd};
use crate::fd::{BorrowedFd, OwnedFd};
diff --git a/vendor/rustix/src/backend/linux_raw/mm/types.rs b/vendor/rustix/src/backend/linux_raw/mm/types.rs
index 2d5eebc58..0dfb41050 100644
--- a/vendor/rustix/src/backend/linux_raw/mm/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/mm/types.rs
@@ -16,6 +16,9 @@ bitflags! {
const WRITE = linux_raw_sys::general::PROT_WRITE;
/// `PROT_EXEC`
const EXEC = linux_raw_sys::general::PROT_EXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -52,6 +55,9 @@ bitflags! {
/// `PROT_ADI`
#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
const ADI = linux_raw_sys::general::PROT_ADI;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -99,6 +105,9 @@ bitflags! {
/// `MAP_UNINITIALIZED`
#[cfg(not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "mips64", target_arch = "mips64r6")))]
const UNINITIALIZED = linux_raw_sys::general::MAP_UNINITIALIZED;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -116,6 +125,9 @@ bitflags! {
const MAYMOVE = linux_raw_sys::general::MREMAP_MAYMOVE;
/// `MREMAP_DONTUNMAP` (since Linux 5.7)
const DONTUNMAP = linux_raw_sys::general::MREMAP_DONTUNMAP;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -135,6 +147,9 @@ bitflags! {
/// file (so that they can be updated with the fresh values just
/// written).
const INVALIDATE = linux_raw_sys::general::MS_INVALIDATE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -147,6 +162,9 @@ bitflags! {
pub struct MlockFlags: u32 {
/// `MLOCK_ONFAULT`
const ONFAULT = linux_raw_sys::general::MLOCK_ONFAULT;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -239,5 +257,8 @@ bitflags! {
const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
/// `O_NONBLOCK`
const NONBLOCK = linux_raw_sys::general::O_NONBLOCK;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/mod.rs b/vendor/rustix/src/backend/linux_raw/mod.rs
index c3018930f..9a07467f4 100644
--- a/vendor/rustix/src/backend/linux_raw/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/mod.rs
@@ -17,13 +17,6 @@
#[macro_use]
mod arch;
mod conv;
-#[cfg(any(
- feature = "param",
- feature = "runtime",
- feature = "time",
- target_arch = "x86"
-))]
-mod elf;
mod reg;
#[cfg(any(feature = "time", target_arch = "x86"))]
mod vdso;
@@ -36,7 +29,7 @@ pub(crate) mod event;
feature = "fs",
all(
not(feature = "use-libc-auxv"),
- not(target_vendor = "mustang"),
+ not(feature = "use-explicitly-provided-auxv"),
any(
feature = "param",
feature = "runtime",
@@ -104,7 +97,7 @@ pub(crate) mod prctl;
feature = "thread",
all(
not(feature = "use-libc-auxv"),
- not(target_vendor = "mustang"),
+ not(feature = "use-explicitly-provided-auxv"),
any(
feature = "param",
feature = "runtime",
diff --git a/vendor/rustix/src/backend/linux_raw/mount/types.rs b/vendor/rustix/src/backend/linux_raw/mount/types.rs
index 808710c13..221f8f315 100644
--- a/vendor/rustix/src/backend/linux_raw/mount/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/mount/types.rs
@@ -56,6 +56,9 @@ bitflags! {
/// `MS_NOSYMFOLLOW`
const NOSYMFOLLOW = linux_raw_sys::general::MS_NOSYMFOLLOW;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -74,6 +77,9 @@ bitflags! {
const EXPIRE = linux_raw_sys::general::MNT_EXPIRE;
/// `UMOUNT_NOFOLLOW`
const NOFOLLOW = linux_raw_sys::general::UMOUNT_NOFOLLOW;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -85,9 +91,11 @@ bitflags! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FsOpenFlags: c::c_uint {
-
/// `FSOPEN_CLOEXEC`
const FSOPEN_CLOEXEC = linux_raw_sys::general::FSOPEN_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -101,6 +109,9 @@ bitflags! {
pub struct FsMountFlags: c::c_uint {
/// `FSMOUNT_CLOEXEC`
const FSMOUNT_CLOEXEC = linux_raw_sys::general::FSMOUNT_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -177,6 +188,9 @@ bitflags! {
/// `MOUNT_ATTR__ATIME_FLAGS`
const MOUNT_ATTR_SIZE_VER0 = linux_raw_sys::general::MOUNT_ATTR_SIZE_VER0;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -215,6 +229,9 @@ bitflags! {
/// `MOVE_MOUNT__MASK`
const MOVE_MOUNT__MASK = linux_raw_sys::general::MOVE_MOUNT__MASK;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -243,6 +260,9 @@ bitflags! {
/// `AT_SYMLINK_NOFOLLOW`
const AT_SYMLINK_NOFOLLOW = linux_raw_sys::general::AT_SYMLINK_NOFOLLOW;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -265,6 +285,9 @@ bitflags! {
/// `FSPICK_EMPTY_PATH`
const FSPICK_EMPTY_PATH = linux_raw_sys::general::FSPICK_EMPTY_PATH;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -287,6 +310,9 @@ bitflags! {
const UNBINDABLE = linux_raw_sys::general::MS_UNBINDABLE;
/// `MS_REC`
const REC = linux_raw_sys::general::MS_REC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -296,6 +322,9 @@ bitflags! {
pub(crate) struct InternalMountFlags: c::c_uint {
const REMOUNT = linux_raw_sys::general::MS_REMOUNT;
const MOVE = linux_raw_sys::general::MS_MOVE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/net/addr.rs b/vendor/rustix/src/backend/linux_raw/net/addr.rs
index 4a203ed16..e6b307a16 100644
--- a/vendor/rustix/src/backend/linux_raw/net/addr.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/addr.rs
@@ -117,9 +117,7 @@ impl Eq for SocketAddrUnix {}
impl PartialOrd for SocketAddrUnix {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
- let self_len = self.len() - offsetof_sun_path();
- let other_len = other.len() - offsetof_sun_path();
- self.unix.sun_path[..self_len].partial_cmp(&other.unix.sun_path[..other_len])
+ Some(self.cmp(other))
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/net/msghdr.rs b/vendor/rustix/src/backend/linux_raw/net/msghdr.rs
index 3c435bcfa..659093920 100644
--- a/vendor/rustix/src/backend/linux_raw/net/msghdr.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/msghdr.rs
@@ -12,7 +12,7 @@ use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{RecvAncillaryBuffer, SendAncillaryBuffer, SocketAddrV4, SocketAddrV6};
use crate::utils::as_ptr;
-use core::mem::{size_of, zeroed, MaybeUninit};
+use core::mem::{size_of, MaybeUninit};
use core::ptr::null_mut;
fn msg_iov_len(len: usize) -> c::size_t {
@@ -42,9 +42,7 @@ pub(crate) fn with_recv_msghdr<R>(
msg_iovlen: msg_iov_len(iov.len()),
msg_control: control.as_control_ptr().cast(),
msg_controllen: msg_control_len(control.control_len()),
-
- // Zero-initialize any padding bytes.
- ..unsafe { zeroed() }
+ msg_flags: 0,
};
let res = f(&mut msghdr);
@@ -72,9 +70,7 @@ pub(crate) fn with_noaddr_msghdr<R>(
msg_iovlen: msg_iov_len(iov.len()),
msg_control: control.as_control_ptr().cast(),
msg_controllen: msg_control_len(control.control_len()),
-
- // Zero-initialize any padding bytes.
- ..unsafe { zeroed() }
+ msg_flags: 0,
})
}
@@ -85,7 +81,7 @@ pub(crate) fn with_v4_msghdr<R>(
control: &mut SendAncillaryBuffer<'_, '_, '_>,
f: impl FnOnce(c::msghdr) -> R,
) -> R {
- let encoded = unsafe { encode_sockaddr_v4(addr) };
+ let encoded = encode_sockaddr_v4(addr);
f(c::msghdr {
msg_name: as_ptr(&encoded) as _,
@@ -94,9 +90,7 @@ pub(crate) fn with_v4_msghdr<R>(
msg_iovlen: msg_iov_len(iov.len()),
msg_control: control.as_control_ptr().cast(),
msg_controllen: msg_control_len(control.control_len()),
-
- // Zero-initialize any padding bytes.
- ..unsafe { zeroed() }
+ msg_flags: 0,
})
}
@@ -107,7 +101,7 @@ pub(crate) fn with_v6_msghdr<R>(
control: &mut SendAncillaryBuffer<'_, '_, '_>,
f: impl FnOnce(c::msghdr) -> R,
) -> R {
- let encoded = unsafe { encode_sockaddr_v6(addr) };
+ let encoded = encode_sockaddr_v6(addr);
f(c::msghdr {
msg_name: as_ptr(&encoded) as _,
@@ -116,9 +110,7 @@ pub(crate) fn with_v6_msghdr<R>(
msg_iovlen: msg_iov_len(iov.len()),
msg_control: control.as_control_ptr().cast(),
msg_controllen: msg_control_len(control.control_len()),
-
- // Zero-initialize any padding bytes.
- ..unsafe { zeroed() }
+ msg_flags: 0,
})
}
@@ -136,8 +128,19 @@ pub(crate) fn with_unix_msghdr<R>(
msg_iovlen: msg_iov_len(iov.len()),
msg_control: control.as_control_ptr().cast(),
msg_controllen: msg_control_len(control.control_len()),
-
- // Zero-initialize any padding bytes.
- ..unsafe { zeroed() }
+ msg_flags: 0,
})
}
+
+/// Create a zero-initialized message header struct value.
+pub(crate) fn zero_msghdr() -> c::msghdr {
+ c::msghdr {
+ msg_name: null_mut(),
+ msg_namelen: 0,
+ msg_iov: null_mut(),
+ msg_iovlen: 0,
+ msg_control: null_mut(),
+ msg_controllen: 0,
+ msg_flags: 0,
+ }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/net/send_recv.rs b/vendor/rustix/src/backend/linux_raw/net/send_recv.rs
index 6e39a13aa..43b35341a 100644
--- a/vendor/rustix/src/backend/linux_raw/net/send_recv.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/send_recv.rs
@@ -23,6 +23,9 @@ bitflags! {
const NOSIGNAL = c::MSG_NOSIGNAL;
/// `MSG_OOB`
const OOB = c::MSG_OOB;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -48,5 +51,8 @@ bitflags! {
const TRUNC = c::MSG_TRUNC;
/// `MSG_WAITALL`
const WAITALL = c::MSG_WAITALL;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/net/syscalls.rs b/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
index df35e63c8..e5ebcc1dd 100644
--- a/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use super::msghdr::{
with_noaddr_msghdr, with_recv_msghdr, with_unix_msghdr, with_v4_msghdr, with_v6_msghdr,
@@ -51,7 +50,7 @@ pub(crate) fn socket(
ret_owned_fd(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SOCKET),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
family.into(),
type_.into(),
protocol.into(),
@@ -81,7 +80,7 @@ pub(crate) fn socket_with(
ret_owned_fd(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SOCKET),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
family.into(),
(type_, flags).into(),
protocol.into(),
@@ -116,7 +115,7 @@ pub(crate) fn socketpair(
ret(syscall!(
__NR_socketcall,
x86_sys(SYS_SOCKETPAIR),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
family.into(),
(type_, flags).into(),
protocol.into(),
@@ -140,7 +139,7 @@ pub(crate) fn accept(fd: BorrowedFd<'_>) -> io::Result<OwnedFd> {
let fd = ret_owned_fd(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_ACCEPT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[fd.into(), zero(), zero()])
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[fd.into(), zero(), zero()])
))?;
Ok(fd)
}
@@ -158,7 +157,7 @@ pub(crate) fn accept_with(fd: BorrowedFd<'_>, flags: SocketFlags) -> io::Result<
let fd = ret_owned_fd(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_ACCEPT4),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[fd.into(), zero(), zero(), flags.into()])
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[fd.into(), zero(), zero(), flags.into()])
))?;
Ok(fd)
}
@@ -188,7 +187,7 @@ pub(crate) fn acceptfrom(fd: BorrowedFd<'_>) -> io::Result<(OwnedFd, Option<Sock
let fd = ret_owned_fd(syscall!(
__NR_socketcall,
x86_sys(SYS_ACCEPT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
(&mut storage).into(),
by_mut(&mut addrlen),
@@ -229,7 +228,7 @@ pub(crate) fn acceptfrom_with(
let fd = ret_owned_fd(syscall!(
__NR_socketcall,
x86_sys(SYS_ACCEPT4),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
(&mut storage).into(),
by_mut(&mut addrlen),
@@ -262,7 +261,7 @@ pub(crate) fn recvmsg(
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_RECVMSG),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
sockfd.into(),
by_mut(msghdr),
msg_flags.into(),
@@ -301,7 +300,7 @@ pub(crate) fn sendmsg(
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_SENDMSG),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
sockfd.into(),
by_ref(&msghdr),
msg_flags.into()
@@ -331,7 +330,7 @@ pub(crate) fn sendmsg_v4(
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_SENDMSG),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
sockfd.into(),
by_ref(&msghdr),
msg_flags.into(),
@@ -361,7 +360,7 @@ pub(crate) fn sendmsg_v6(
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_SENDMSG),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
sockfd.into(),
by_ref(&msghdr),
msg_flags.into()
@@ -391,7 +390,7 @@ pub(crate) fn sendmsg_unix(
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_SENDMSG),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
sockfd.into(),
by_ref(&msghdr),
msg_flags.into()
@@ -418,7 +417,7 @@ pub(crate) fn shutdown(fd: BorrowedFd<'_>, how: Shutdown) -> io::Result<()> {
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SHUTDOWN),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[fd.into(), c_uint(how as c::c_uint)])
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[fd.into(), c_uint(how as c::c_uint)])
))
}
}
@@ -461,7 +460,12 @@ pub(crate) fn send(fd: BorrowedFd<'_>, buf: &[u8], flags: SendFlags) -> io::Resu
ret_usize(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SEND),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[fd.into(), buf_addr, buf_len, flags.into()])
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
+ fd.into(),
+ buf_addr,
+ buf_len,
+ flags.into()
+ ])
))
}
}
@@ -492,7 +496,7 @@ pub(crate) fn sendto_v4(
ret_usize(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SENDTO),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
buf_addr,
buf_len,
@@ -530,7 +534,7 @@ pub(crate) fn sendto_v6(
ret_usize(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SENDTO),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
buf_addr,
buf_len,
@@ -568,7 +572,7 @@ pub(crate) fn sendto_unix(
ret_usize(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SENDTO),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
buf_addr,
buf_len,
@@ -618,7 +622,7 @@ pub(crate) fn recv(fd: BorrowedFd<'_>, buf: &mut [u8], flags: RecvFlags) -> io::
ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_RECV),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
buf_addr_mut,
buf_len,
@@ -659,7 +663,7 @@ pub(crate) fn recvfrom(
let nread = ret_usize(syscall!(
__NR_socketcall,
x86_sys(SYS_RECVFROM),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
buf_addr_mut,
buf_len,
@@ -700,7 +704,7 @@ pub(crate) fn getpeername(fd: BorrowedFd<'_>) -> io::Result<Option<SocketAddrAny
ret(syscall!(
__NR_socketcall,
x86_sys(SYS_GETPEERNAME),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
(&mut storage).into(),
by_mut(&mut addrlen),
@@ -737,7 +741,7 @@ pub(crate) fn getsockname(fd: BorrowedFd<'_>) -> io::Result<SocketAddrAny> {
ret(syscall!(
__NR_socketcall,
x86_sys(SYS_GETSOCKNAME),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
(&mut storage).into(),
by_mut(&mut addrlen),
@@ -766,7 +770,7 @@ pub(crate) fn bind_v4(fd: BorrowedFd<'_>, addr: &SocketAddrV4) -> io::Result<()>
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_BIND),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&encode_sockaddr_v4(addr)),
size_of::<sockaddr_in, _>(),
@@ -791,7 +795,7 @@ pub(crate) fn bind_v6(fd: BorrowedFd<'_>, addr: &SocketAddrV6) -> io::Result<()>
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_BIND),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&encode_sockaddr_v6(addr)),
size_of::<sockaddr_in6, _>(),
@@ -816,7 +820,7 @@ pub(crate) fn bind_unix(fd: BorrowedFd<'_>, addr: &SocketAddrUnix) -> io::Result
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_BIND),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&addr.unix),
socklen_t(addr.addr_len()),
@@ -841,7 +845,7 @@ pub(crate) fn connect_v4(fd: BorrowedFd<'_>, addr: &SocketAddrV4) -> io::Result<
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_CONNECT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&encode_sockaddr_v4(addr)),
size_of::<sockaddr_in, _>(),
@@ -866,7 +870,7 @@ pub(crate) fn connect_v6(fd: BorrowedFd<'_>, addr: &SocketAddrV6) -> io::Result<
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_CONNECT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&encode_sockaddr_v6(addr)),
size_of::<sockaddr_in6, _>(),
@@ -891,7 +895,7 @@ pub(crate) fn connect_unix(fd: BorrowedFd<'_>, addr: &SocketAddrUnix) -> io::Res
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_CONNECT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
by_ref(&addr.unix),
socklen_t(addr.addr_len()),
@@ -911,7 +915,7 @@ pub(crate) fn listen(fd: BorrowedFd<'_>, backlog: c::c_int) -> io::Result<()> {
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_LISTEN),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[fd.into(), c_int(backlog)])
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[fd.into(), c_int(backlog)])
))
}
}
@@ -920,10 +924,11 @@ pub(crate) mod sockopt {
use super::{c, BorrowedFd};
use crate::io;
use crate::net::sockopt::Timeout;
- use crate::net::{Ipv4Addr, Ipv6Addr, SocketType};
+ use crate::net::{AddressFamily, Ipv4Addr, Ipv6Addr, SocketType};
use c::{SO_RCVTIMEO_NEW, SO_RCVTIMEO_OLD, SO_SNDTIMEO_NEW, SO_SNDTIMEO_OLD};
use core::time::Duration;
use linux_raw_sys::general::{__kernel_timespec, timeval};
+ use linux_raw_sys::net::{SO_ACCEPTCONN, TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL};
#[inline]
fn getsockopt<T: Copy>(fd: BorrowedFd<'_>, level: u32, optname: u32) -> io::Result<T> {
@@ -960,7 +965,7 @@ pub(crate) mod sockopt {
ret(syscall!(
__NR_socketcall,
x86_sys(SYS_GETSOCKOPT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
c_uint(level),
c_uint(optname),
@@ -1008,7 +1013,7 @@ pub(crate) mod sockopt {
ret(syscall_readonly!(
__NR_socketcall,
x86_sys(SYS_SETSOCKOPT),
- slice_just_addr::<ArgReg<SocketArg>, _>(&[
+ slice_just_addr::<ArgReg<'_, SocketArg>, _>(&[
fd.into(),
c_uint(level),
c_uint(optname),
@@ -1035,6 +1040,11 @@ pub(crate) mod sockopt {
}
#[inline]
+ pub(crate) fn get_socket_reuseaddr(fd: BorrowedFd<'_>) -> io::Result<bool> {
+ getsockopt(fd, c::SOL_SOCKET as _, c::SO_REUSEADDR).map(to_bool)
+ }
+
+ #[inline]
pub(crate) fn set_socket_broadcast(fd: BorrowedFd<'_>, broadcast: bool) -> io::Result<()> {
setsockopt(
fd,
@@ -1056,11 +1066,7 @@ pub(crate) mod sockopt {
) -> io::Result<()> {
// Convert `linger` to seconds, rounding up.
let l_linger = if let Some(linger) = linger {
- let mut l_linger = linger.as_secs();
- if linger.subsec_nanos() != 0 {
- l_linger = l_linger.checked_add(1).ok_or(io::Errno::INVAL)?;
- }
- l_linger.try_into().map_err(|_e| io::Errno::INVAL)?
+ duration_to_secs(linger)?
} else {
0
};
@@ -1272,6 +1278,19 @@ pub(crate) mod sockopt {
}
#[inline]
+ pub(crate) fn get_socket_domain(fd: BorrowedFd<'_>) -> io::Result<AddressFamily> {
+ let domain: c::c_int = getsockopt(fd, c::SOL_SOCKET as _, c::SO_DOMAIN)?;
+ Ok(AddressFamily(
+ domain.try_into().map_err(|_| io::Errno::OPNOTSUPP)?,
+ ))
+ }
+
+ #[inline]
+ pub(crate) fn get_socket_acceptconn(fd: BorrowedFd<'_>) -> io::Result<bool> {
+ getsockopt(fd, c::SOL_SOCKET as _, SO_ACCEPTCONN).map(to_bool)
+ }
+
+ #[inline]
pub(crate) fn set_ip_ttl(fd: BorrowedFd<'_>, ttl: u32) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_IP as _, c::IP_TTL, ttl)
}
@@ -1420,6 +1439,40 @@ pub(crate) mod sockopt {
}
#[inline]
+ pub(crate) fn set_tcp_keepcnt(fd: BorrowedFd<'_>, count: u32) -> io::Result<()> {
+ setsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPCNT, count)
+ }
+
+ #[inline]
+ pub(crate) fn get_tcp_keepcnt(fd: BorrowedFd<'_>) -> io::Result<u32> {
+ getsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPCNT)
+ }
+
+ #[inline]
+ pub(crate) fn set_tcp_keepidle(fd: BorrowedFd<'_>, duration: Duration) -> io::Result<()> {
+ let secs: c::c_uint = duration_to_secs(duration)?;
+ setsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPIDLE, secs)
+ }
+
+ #[inline]
+ pub(crate) fn get_tcp_keepidle(fd: BorrowedFd<'_>) -> io::Result<Duration> {
+ let secs: c::c_uint = getsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPIDLE)?;
+ Ok(Duration::from_secs(secs as u64))
+ }
+
+ #[inline]
+ pub(crate) fn set_tcp_keepintvl(fd: BorrowedFd<'_>, duration: Duration) -> io::Result<()> {
+ let secs: c::c_uint = duration_to_secs(duration)?;
+ setsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPINTVL, secs)
+ }
+
+ #[inline]
+ pub(crate) fn get_tcp_keepintvl(fd: BorrowedFd<'_>) -> io::Result<Duration> {
+ let secs: c::c_uint = getsockopt(fd, c::IPPROTO_TCP as _, TCP_KEEPINTVL)?;
+ Ok(Duration::from_secs(secs as u64))
+ }
+
+ #[inline]
fn to_imr(multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> c::ip_mreq {
c::ip_mreq {
imr_multiaddr: to_imr_addr(multiaddr),
@@ -1465,4 +1518,14 @@ pub(crate) mod sockopt {
fn to_bool(value: c::c_uint) -> bool {
value != 0
}
+
+ /// Convert to seconds, rounding up if necessary.
+ #[inline]
+ fn duration_to_secs<T: TryFrom<u64>>(duration: Duration) -> io::Result<T> {
+ let mut secs = duration.as_secs();
+ if duration.subsec_nanos() != 0 {
+ secs = secs.checked_add(1).ok_or(io::Errno::INVAL)?;
+ }
+ T::try_from(secs).map_err(|_e| io::Errno::INVAL)
+ }
}
diff --git a/vendor/rustix/src/backend/linux_raw/net/write_sockaddr.rs b/vendor/rustix/src/backend/linux_raw/net/write_sockaddr.rs
index 28da05cd0..417f76e43 100644
--- a/vendor/rustix/src/backend/linux_raw/net/write_sockaddr.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/write_sockaddr.rs
@@ -17,7 +17,7 @@ pub(crate) unsafe fn write_sockaddr(
}
}
-pub(crate) unsafe fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in {
+pub(crate) fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in {
c::sockaddr_in {
sin_family: c::AF_INET as _,
sin_port: u16::to_be(v4.port()),
@@ -34,7 +34,7 @@ unsafe fn write_sockaddr_v4(v4: &SocketAddrV4, storage: *mut SocketAddrStorage)
size_of::<c::sockaddr_in>()
}
-pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
+pub(crate) fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
c::sockaddr_in6 {
sin6_family: c::AF_INET6 as _,
sin6_port: u16::to_be(v6.port()),
diff --git a/vendor/rustix/src/backend/linux_raw/param/auxv.rs b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
index 144ff10cd..8b0423ae4 100644
--- a/vendor/rustix/src/backend/linux_raw/param/auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
@@ -6,24 +6,23 @@
#![allow(unsafe_code)]
use crate::backend::c;
-use crate::backend::elf::*;
use crate::fd::OwnedFd;
#[cfg(feature = "param")]
use crate::ffi::CStr;
use crate::fs::{Mode, OFlags};
use crate::utils::{as_ptr, check_raw_pointer};
+#[cfg(feature = "alloc")]
use alloc::vec::Vec;
-use core::ffi::c_void;
use core::mem::size_of;
use core::ptr::{null_mut, read_unaligned, NonNull};
-#[cfg(feature = "runtime")]
-use core::slice;
use core::sync::atomic::Ordering::Relaxed;
use core::sync::atomic::{AtomicPtr, AtomicUsize};
+use linux_raw_sys::elf::*;
use linux_raw_sys::general::{
- AT_BASE, AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_NULL, AT_PAGESZ, AT_PHDR, AT_PHENT,
- AT_PHNUM, AT_SYSINFO_EHDR,
+ AT_BASE, AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_NULL, AT_PAGESZ, AT_SYSINFO_EHDR,
};
+#[cfg(feature = "runtime")]
+use linux_raw_sys::general::{AT_ENTRY, AT_PHDR, AT_PHENT, AT_PHNUM};
#[cfg(feature = "param")]
#[inline]
@@ -83,31 +82,23 @@ pub(crate) fn linux_execfn() -> &'static CStr {
#[cfg(feature = "runtime")]
#[inline]
-pub(crate) fn exe_phdrs() -> (*const c::c_void, usize) {
+pub(crate) fn exe_phdrs() -> (*const c::c_void, usize, usize) {
let mut phdr = PHDR.load(Relaxed);
+ let mut phent = PHENT.load(Relaxed);
let mut phnum = PHNUM.load(Relaxed);
if phdr.is_null() || phnum == 0 {
init_auxv();
phdr = PHDR.load(Relaxed);
+ phent = PHENT.load(Relaxed);
phnum = PHNUM.load(Relaxed);
}
- (phdr.cast(), phnum)
+ (phdr.cast(), phent, phnum)
}
-#[cfg(feature = "runtime")]
-#[inline]
-pub(in super::super) fn exe_phdrs_slice() -> &'static [Elf_Phdr] {
- let (phdr, phnum) = exe_phdrs();
-
- // SAFETY: We assume the `AT_PHDR` and `AT_PHNUM` values provided by the
- // kernel form a valid slice.
- unsafe { slice::from_raw_parts(phdr.cast(), phnum) }
-}
-
-/// `AT_SYSINFO_EHDR` isn't present on all platforms in all configurations,
-/// so if we don't see it, this function returns a null pointer.
+/// `AT_SYSINFO_EHDR` isn't present on all platforms in all configurations, so
+/// if we don't see it, this function returns a null pointer.
#[inline]
pub(in super::super) fn sysinfo_ehdr() -> *const Elf_Ehdr {
let mut ehdr = SYSINFO_EHDR.load(Relaxed);
@@ -120,15 +111,35 @@ pub(in super::super) fn sysinfo_ehdr() -> *const Elf_Ehdr {
ehdr
}
+#[cfg(feature = "runtime")]
+#[inline]
+pub(crate) fn entry() -> usize {
+ let mut entry = ENTRY.load(Relaxed);
+
+ if entry == 0 {
+ init_auxv();
+ entry = ENTRY.load(Relaxed);
+ }
+
+ entry
+}
+
static PAGE_SIZE: AtomicUsize = AtomicUsize::new(0);
static CLOCK_TICKS_PER_SECOND: AtomicUsize = AtomicUsize::new(0);
static HWCAP: AtomicUsize = AtomicUsize::new(0);
static HWCAP2: AtomicUsize = AtomicUsize::new(0);
+static EXECFN: AtomicPtr<c::c_char> = AtomicPtr::new(null_mut());
static SYSINFO_EHDR: AtomicPtr<Elf_Ehdr> = AtomicPtr::new(null_mut());
+#[cfg(feature = "runtime")]
static PHDR: AtomicPtr<Elf_Phdr> = AtomicPtr::new(null_mut());
+#[cfg(feature = "runtime")]
+static PHENT: AtomicUsize = AtomicUsize::new(0);
+#[cfg(feature = "runtime")]
static PHNUM: AtomicUsize = AtomicUsize::new(0);
-static EXECFN: AtomicPtr<c::c_char> = AtomicPtr::new(null_mut());
+#[cfg(feature = "runtime")]
+static ENTRY: AtomicUsize = AtomicUsize::new(0);
+#[cfg(feature = "alloc")]
fn pr_get_auxv() -> crate::io::Result<Vec<u8>> {
use super::super::conv::{c_int, pass_usize, ret_usize};
const PR_GET_AUXV: c::c_int = 0x41555856;
@@ -138,7 +149,9 @@ fn pr_get_auxv() -> crate::io::Result<Vec<u8>> {
__NR_prctl,
c_int(PR_GET_AUXV),
buffer.as_ptr(),
- pass_usize(buffer.len())
+ pass_usize(buffer.len()),
+ pass_usize(0),
+ pass_usize(0)
))?
};
if len <= buffer.len() {
@@ -151,28 +164,33 @@ fn pr_get_auxv() -> crate::io::Result<Vec<u8>> {
__NR_prctl,
c_int(PR_GET_AUXV),
buffer.as_ptr(),
- pass_usize(buffer.len())
+ pass_usize(buffer.len()),
+ pass_usize(0),
+ pass_usize(0)
))?
};
assert_eq!(len, buffer.len());
return Ok(buffer);
}
-/// On non-Mustang platforms, we read the aux vector via the `prctl`
-/// `PR_GET_AUXV`, with a fallback to /proc/self/auxv for kernels that don't
-/// support `PR_GET_AUXV`.
+/// If we don't have "use-explicitly-provided-auxv" or "use-libc-auxv", we
+/// read the aux vector via the `prctl` `PR_GET_AUXV`, with a fallback to
+/// /proc/self/auxv for kernels that don't support `PR_GET_AUXV`.
#[cold]
fn init_auxv() {
- match pr_get_auxv() {
- Ok(buffer) => {
- // SAFETY: We assume the kernel returns a valid auxv.
- unsafe {
- init_from_auxp(buffer.as_ptr().cast());
+ #[cfg(feature = "alloc")]
+ {
+ match pr_get_auxv() {
+ Ok(buffer) => {
+ // SAFETY: We assume the kernel returns a valid auxv.
+ unsafe {
+ init_from_aux_iter(AuxPointer(buffer.as_ptr().cast()));
+ }
+ return;
+ }
+ Err(_) => {
+ // Fall back to /proc/self/auxv on error.
}
- return;
- }
- Err(_) => {
- // Fall back to /proc/self/auxv on error.
}
}
@@ -182,10 +200,17 @@ fn init_auxv() {
// auxv records.
let file = crate::fs::open("/proc/self/auxv", OFlags::RDONLY, Mode::empty()).unwrap();
- let _ = init_from_auxv_file(file);
+ #[cfg(feature = "alloc")]
+ init_from_auxv_file(file).unwrap();
+
+ #[cfg(not(feature = "alloc"))]
+ unsafe {
+ init_from_aux_iter(AuxFile(file)).unwrap();
+ }
}
/// Process auxv entries from the open file `auxv`.
+#[cfg(feature = "alloc")]
#[cold]
fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
let mut buffer = Vec::<u8>::with_capacity(512);
@@ -211,7 +236,7 @@ fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
}
// SAFETY: We loaded from an auxv file into the buffer.
- unsafe { init_from_auxp(buffer.as_ptr().cast()) }
+ unsafe { init_from_aux_iter(AuxPointer(buffer.as_ptr().cast())) }
}
/// Process auxv entries from the auxv array pointed to by `auxp`.
@@ -223,37 +248,50 @@ fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
/// The buffer contains `Elf_aux_t` elements, though it need not be aligned;
/// function uses `read_unaligned` to read from it.
#[cold]
-unsafe fn init_from_auxp(mut auxp: *const Elf_auxv_t) -> Option<()> {
+unsafe fn init_from_aux_iter(aux_iter: impl Iterator<Item = Elf_auxv_t>) -> Option<()> {
let mut pagesz = 0;
let mut clktck = 0;
let mut hwcap = 0;
let mut hwcap2 = 0;
- let mut phdr = null_mut();
- let mut phnum = 0;
let mut execfn = null_mut();
let mut sysinfo_ehdr = null_mut();
+ #[cfg(feature = "runtime")]
+ let mut phdr = null_mut();
+ #[cfg(feature = "runtime")]
+ let mut phnum = 0;
+ #[cfg(feature = "runtime")]
let mut phent = 0;
+ #[cfg(feature = "runtime")]
+ let mut entry = 0;
- loop {
- let Elf_auxv_t { a_type, a_val } = read_unaligned(auxp);
-
+ for Elf_auxv_t { a_type, a_val } in aux_iter {
match a_type as _ {
AT_PAGESZ => pagesz = a_val as usize,
AT_CLKTCK => clktck = a_val as usize,
AT_HWCAP => hwcap = a_val as usize,
AT_HWCAP2 => hwcap2 = a_val as usize,
+ AT_EXECFN => execfn = check_raw_pointer::<c::c_char>(a_val as *mut _)?.as_ptr(),
+ AT_SYSINFO_EHDR => sysinfo_ehdr = check_elf_base(a_val as *mut _)?.as_ptr(),
+
+ AT_BASE => {
+ let _ = check_elf_base(a_val.cast())?;
+ }
+
+ #[cfg(feature = "runtime")]
AT_PHDR => phdr = check_raw_pointer::<Elf_Phdr>(a_val as *mut _)?.as_ptr(),
+ #[cfg(feature = "runtime")]
AT_PHNUM => phnum = a_val as usize,
+ #[cfg(feature = "runtime")]
AT_PHENT => phent = a_val as usize,
- AT_EXECFN => execfn = check_raw_pointer::<c::c_char>(a_val as *mut _)?.as_ptr(),
- AT_BASE => check_interpreter_base(a_val.cast())?,
- AT_SYSINFO_EHDR => sysinfo_ehdr = check_vdso_base(a_val as *mut _)?.as_ptr(),
+ #[cfg(feature = "runtime")]
+ AT_ENTRY => entry = a_val as usize,
+
AT_NULL => break,
_ => (),
}
- auxp = auxp.add(1);
}
+ #[cfg(feature = "runtime")]
assert_eq!(phent, size_of::<Elf_Phdr>());
// The base and sysinfo_ehdr (if present) matches our platform. Accept
@@ -262,86 +300,29 @@ unsafe fn init_from_auxp(mut auxp: *const Elf_auxv_t) -> Option<()> {
CLOCK_TICKS_PER_SECOND.store(clktck, Relaxed);
HWCAP.store(hwcap, Relaxed);
HWCAP2.store(hwcap2, Relaxed);
- PHDR.store(phdr, Relaxed);
- PHNUM.store(phnum, Relaxed);
EXECFN.store(execfn, Relaxed);
SYSINFO_EHDR.store(sysinfo_ehdr, Relaxed);
+ #[cfg(feature = "runtime")]
+ PHDR.store(phdr, Relaxed);
+ #[cfg(feature = "runtime")]
+ PHNUM.store(phnum, Relaxed);
+ #[cfg(feature = "runtime")]
+ ENTRY.store(entry, Relaxed);
Some(())
}
-/// Check that `base` is a valid pointer to the program interpreter.
-///
-/// `base` is some value we got from a `AT_BASE` aux record somewhere,
-/// which hopefully holds the value of the program interpreter in memory. Do a
-/// series of checks to be as sure as we can that it's safe to use.
-#[cold]
-unsafe fn check_interpreter_base(base: *const Elf_Ehdr) -> Option<()> {
- check_elf_base(base)?;
- Some(())
-}
-
/// Check that `base` is a valid pointer to the kernel-provided vDSO.
///
/// `base` is some value we got from a `AT_SYSINFO_EHDR` aux record somewhere,
/// which hopefully holds the value of the kernel-provided vDSO in memory. Do a
/// series of checks to be as sure as we can that it's safe to use.
#[cold]
-unsafe fn check_vdso_base(base: *const Elf_Ehdr) -> Option<NonNull<Elf_Ehdr>> {
- // In theory, we could check that we're not attempting to parse our own ELF
- // image, as an additional check. However, older Linux toolchains don't
- // support this, and Rust's `#[linkage = "extern_weak"]` isn't stable yet,
- // so just disable this for now.
- /*
- {
- extern "C" {
- static __ehdr_start: c::c_void;
- }
-
- let ehdr_start: *const c::c_void = &__ehdr_start;
- if base == ehdr_start {
- return None;
- }
- }
- */
-
- let hdr = check_elf_base(base)?;
-
- // Check that the ELF is not writable, since that would indicate that this
- // isn't the ELF we think it is. Here we're just using `clock_getres` just
- // as an arbitrary system call which writes to a buffer and fails with
- // `EFAULT` if the buffer is not writable.
- {
- use crate::backend::conv::{c_uint, ret};
- if ret(syscall!(
- __NR_clock_getres,
- c_uint(linux_raw_sys::general::CLOCK_MONOTONIC),
- base
- )) != Err(crate::io::Errno::FAULT)
- {
- // We can't gracefully fail here because we would seem to have just
- // mutated some unknown memory.
- #[cfg(feature = "std")]
- {
- std::process::abort();
- }
- #[cfg(all(not(feature = "std"), feature = "rustc-dep-of-std"))]
- {
- core::intrinsics::abort();
- }
- }
- }
-
- Some(hdr)
-}
-
-/// Check that `base` is a valid pointer to an ELF image.
-#[cold]
unsafe fn check_elf_base(base: *const Elf_Ehdr) -> Option<NonNull<Elf_Ehdr>> {
- // If we're reading a 64-bit auxv on a 32-bit platform, we'll see
- // a zero `a_val` because `AT_*` values are never greater than
- // `u32::MAX`. Zero is used by libc's `getauxval` to indicate
- // errors, so it should never be a valid value.
+ // If we're reading a 64-bit auxv on a 32-bit platform, we'll see a zero
+ // `a_val` because `AT_*` values are never greater than `u32::MAX`. Zero is
+ // used by libc's `getauxval` to indicate errors, so it should never be a
+ // valid value.
if base.is_null() {
return None;
}
@@ -400,15 +381,46 @@ unsafe fn check_elf_base(base: *const Elf_Ehdr) -> Option<NonNull<Elf_Ehdr>> {
Some(NonNull::new_unchecked(as_ptr(hdr) as *mut _))
}
-// ELF ABI
+// Aux reading utilities
+
+// Read auxv records from an array in memory.
+struct AuxPointer(*const Elf_auxv_t);
-#[repr(C)]
-#[derive(Copy, Clone)]
-struct Elf_auxv_t {
- a_type: usize,
+impl Iterator for AuxPointer {
+ type Item = Elf_auxv_t;
- // Some of the values in the auxv array are pointers, so we make `a_val` a
- // pointer, in order to preserve their provenance. For the values which are
- // integers, we cast this to `usize`.
- a_val: *const c_void,
+ #[cold]
+ fn next(&mut self) -> Option<Self::Item> {
+ unsafe {
+ let value = read_unaligned(self.0);
+ self.0 = self.0.add(1);
+ Some(value)
+ }
+ }
+}
+
+// Read auxv records from a file.
+#[cfg(not(feature = "alloc"))]
+struct AuxFile(OwnedFd);
+
+#[cfg(not(feature = "alloc"))]
+impl Iterator for AuxFile {
+ type Item = Elf_auxv_t;
+
+ // This implementation does lots of `read`s and it isn't amazing, but
+ // hopefully we won't use it often.
+ #[cold]
+ fn next(&mut self) -> Option<Self::Item> {
+ let mut buf = [0_u8; size_of::<Self::Item>()];
+ let mut slice = &mut buf[..];
+ while !slice.is_empty() {
+ match crate::io::read(&self.0, slice) {
+ Ok(0) => panic!("unexpected end of auxv file"),
+ Ok(n) => slice = &mut slice[n..],
+ Err(crate::io::Errno::INTR) => continue,
+ Err(err) => Err(err).unwrap(),
+ }
+ }
+ Some(unsafe { read_unaligned(buf.as_ptr().cast()) })
+ }
}
diff --git a/vendor/rustix/src/backend/linux_raw/param/init.rs b/vendor/rustix/src/backend/linux_raw/param/init.rs
new file mode 100644
index 000000000..46aae009a
--- /dev/null
+++ b/vendor/rustix/src/backend/linux_raw/param/init.rs
@@ -0,0 +1,149 @@
+//! Linux auxv `init` function, for "use-explicitly-provided-auxv" mode.
+//!
+//! # Safety
+//!
+//! This uses raw pointers to locate and read the kernel-provided auxv array.
+#![allow(unsafe_code)]
+
+use crate::backend::c;
+#[cfg(feature = "param")]
+use crate::ffi::CStr;
+use core::ffi::c_void;
+use core::ptr::{null_mut, read, NonNull};
+use core::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
+use linux_raw_sys::elf::*;
+use linux_raw_sys::general::{
+ AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_NULL, AT_PAGESZ, AT_SYSINFO_EHDR,
+};
+#[cfg(feature = "runtime")]
+use linux_raw_sys::general::{AT_ENTRY, AT_PHDR, AT_PHENT, AT_PHNUM};
+
+#[cfg(feature = "param")]
+#[inline]
+pub(crate) fn page_size() -> usize {
+ unsafe { PAGE_SIZE.load(Ordering::Relaxed) }
+}
+
+#[cfg(feature = "param")]
+#[inline]
+pub(crate) fn clock_ticks_per_second() -> u64 {
+ unsafe { CLOCK_TICKS_PER_SECOND.load(Ordering::Relaxed) as u64 }
+}
+
+#[cfg(feature = "param")]
+#[inline]
+pub(crate) fn linux_hwcap() -> (usize, usize) {
+ unsafe {
+ (
+ HWCAP.load(Ordering::Relaxed),
+ HWCAP2.load(Ordering::Relaxed),
+ )
+ }
+}
+
+#[cfg(feature = "param")]
+#[inline]
+pub(crate) fn linux_execfn() -> &'static CStr {
+ let execfn = unsafe { EXECFN.load(Ordering::Relaxed) };
+
+ // SAFETY: We initialize `EXECFN` to a valid `CStr` pointer, and we assume
+ // the `AT_EXECFN` value provided by the kernel points to a valid C string.
+ unsafe { CStr::from_ptr(execfn.cast()) }
+}
+
+#[cfg(feature = "runtime")]
+#[inline]
+pub(crate) fn exe_phdrs() -> (*const c_void, usize, usize) {
+ unsafe {
+ (
+ PHDR.load(Ordering::Relaxed).cast(),
+ PHENT.load(Ordering::Relaxed),
+ PHNUM.load(Ordering::Relaxed),
+ )
+ }
+}
+
+/// `AT_SYSINFO_EHDR` isn't present on all platforms in all configurations, so
+/// if we don't see it, this function returns a null pointer.
+#[inline]
+pub(in super::super) fn sysinfo_ehdr() -> *const Elf_Ehdr {
+ unsafe { SYSINFO_EHDR.load(Ordering::Relaxed) }
+}
+
+#[cfg(feature = "runtime")]
+#[inline]
+pub(crate) fn entry() -> usize {
+ unsafe { ENTRY.load(Ordering::Relaxed) }
+}
+
+static mut PAGE_SIZE: AtomicUsize = AtomicUsize::new(0);
+static mut CLOCK_TICKS_PER_SECOND: AtomicUsize = AtomicUsize::new(0);
+static mut HWCAP: AtomicUsize = AtomicUsize::new(0);
+static mut HWCAP2: AtomicUsize = AtomicUsize::new(0);
+static mut SYSINFO_EHDR: AtomicPtr<Elf_Ehdr> = AtomicPtr::new(null_mut());
+// Initialize `EXECFN` to a valid `CStr` pointer so that we don't need to check
+// for null on every `execfn` call.
+static mut EXECFN: AtomicPtr<c::c_char> = AtomicPtr::new(b"\0".as_ptr() as _);
+// Use `dangling` so that we can always treat it like an empty slice.
+#[cfg(feature = "runtime")]
+static mut PHDR: AtomicPtr<Elf_Phdr> = AtomicPtr::new(NonNull::dangling().as_ptr());
+#[cfg(feature = "runtime")]
+static mut PHENT: AtomicUsize = AtomicUsize::new(0);
+#[cfg(feature = "runtime")]
+static mut PHNUM: AtomicUsize = AtomicUsize::new(0);
+#[cfg(feature = "runtime")]
+static mut ENTRY: AtomicUsize = AtomicUsize::new(0);
+
+/// When "use-explicitly-provided-auxv" is enabled, we export a function to be
+/// called during initialization, and passed a pointer to the original
+/// environment variable block set up by the OS.
+pub(crate) unsafe fn init(envp: *mut *mut u8) {
+ init_from_envp(envp);
+}
+
+/// # Safety
+///
+/// This must be passed a pointer to the environment variable buffer
+/// provided by the kernel, which is followed in memory by the auxv array.
+unsafe fn init_from_envp(mut envp: *mut *mut u8) {
+ while !(*envp).is_null() {
+ envp = envp.add(1);
+ }
+ init_from_auxp(envp.add(1).cast())
+}
+
+/// Process auxv entries from the auxv array pointed to by `auxp`.
+///
+/// # Safety
+///
+/// This must be passed a pointer to an auxv array.
+///
+/// The buffer contains `Elf_aux_t` elements, though it need not be aligned;
+/// function uses `read_unaligned` to read from it.
+unsafe fn init_from_auxp(mut auxp: *const Elf_auxv_t) {
+ loop {
+ let Elf_auxv_t { a_type, a_val } = read(auxp);
+
+ match a_type as _ {
+ AT_PAGESZ => PAGE_SIZE.store(a_val as usize, Ordering::Relaxed),
+ AT_CLKTCK => CLOCK_TICKS_PER_SECOND.store(a_val as usize, Ordering::Relaxed),
+ AT_HWCAP => HWCAP.store(a_val as usize, Ordering::Relaxed),
+ AT_HWCAP2 => HWCAP2.store(a_val as usize, Ordering::Relaxed),
+ AT_EXECFN => EXECFN.store(a_val.cast::<c::c_char>(), Ordering::Relaxed),
+ AT_SYSINFO_EHDR => SYSINFO_EHDR.store(a_val.cast::<Elf_Ehdr>(), Ordering::Relaxed),
+
+ #[cfg(feature = "runtime")]
+ AT_PHDR => PHDR.store(a_val.cast::<Elf_Phdr>(), Ordering::Relaxed),
+ #[cfg(feature = "runtime")]
+ AT_PHNUM => PHNUM.store(a_val as usize, Ordering::Relaxed),
+ #[cfg(feature = "runtime")]
+ AT_PHENT => PHENT.store(a_val as usize, Ordering::Relaxed),
+ #[cfg(feature = "runtime")]
+ AT_ENTRY => ENTRY.store(a_val as usize, Ordering::Relaxed),
+
+ AT_NULL => break,
+ _ => (),
+ }
+ auxp = auxp.add(1);
+ }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs b/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs
index 97739fcb5..0e6ca6ed5 100644
--- a/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs
@@ -6,35 +6,39 @@
#![allow(unsafe_code)]
use crate::backend::c;
-use crate::backend::elf::*;
#[cfg(feature = "param")]
use crate::ffi::CStr;
#[cfg(not(feature = "runtime"))]
use core::ptr::null;
-#[cfg(feature = "runtime")]
-use core::slice;
+use linux_raw_sys::elf::*;
// `getauxval` wasn't supported in glibc until 2.16. Also this lets us use
// `*mut` as the return type to preserve strict provenance.
#[cfg(not(feature = "runtime"))]
weak!(fn getauxval(c::c_ulong) -> *mut c::c_void);
-// With the "runtime" feature, go ahead and depend on `getauxval` existing
-// so that we never fail.
+// With the "runtime" feature, go ahead and depend on `getauxval` existing so
+// that we never fail.
#[cfg(feature = "runtime")]
extern "C" {
fn getauxval(type_: c::c_ulong) -> *mut c::c_void;
}
+#[cfg(feature = "runtime")]
const AT_PHDR: c::c_ulong = 3;
+#[cfg(feature = "runtime")]
+const AT_PHENT: c::c_ulong = 4;
+#[cfg(feature = "runtime")]
const AT_PHNUM: c::c_ulong = 5;
+#[cfg(feature = "runtime")]
+const AT_ENTRY: c::c_ulong = 9;
const AT_HWCAP: c::c_ulong = 16;
const AT_HWCAP2: c::c_ulong = 26;
const AT_EXECFN: c::c_ulong = 31;
const AT_SYSINFO_EHDR: c::c_ulong = 33;
-// Declare `sysconf` ourselves so that we don't depend on all of libc
-// just for this.
+// Declare `sysconf` ourselves so that we don't depend on all of libc just for
+// this.
extern "C" {
fn sysconf(name: c::c_int) -> c::c_long;
}
@@ -52,12 +56,16 @@ const _SC_CLK_TCK: c::c_int = 2;
fn test_abi() {
const_assert_eq!(self::_SC_PAGESIZE, ::libc::_SC_PAGESIZE);
const_assert_eq!(self::_SC_CLK_TCK, ::libc::_SC_CLK_TCK);
- const_assert_eq!(self::AT_PHDR, ::libc::AT_PHDR);
- const_assert_eq!(self::AT_PHNUM, ::libc::AT_PHNUM);
const_assert_eq!(self::AT_HWCAP, ::libc::AT_HWCAP);
const_assert_eq!(self::AT_HWCAP2, ::libc::AT_HWCAP2);
const_assert_eq!(self::AT_EXECFN, ::libc::AT_EXECFN);
const_assert_eq!(self::AT_SYSINFO_EHDR, ::libc::AT_SYSINFO_EHDR);
+ #[cfg(feature = "runtime")]
+ const_assert_eq!(self::AT_PHDR, ::libc::AT_PHDR);
+ #[cfg(feature = "runtime")]
+ const_assert_eq!(self::AT_PHNUM, ::libc::AT_PHNUM);
+ #[cfg(feature = "runtime")]
+ const_assert_eq!(self::AT_ENTRY, ::libc::AT_ENTRY);
}
#[cfg(feature = "param")]
@@ -114,24 +122,15 @@ pub(crate) fn linux_execfn() -> &'static CStr {
#[cfg(feature = "runtime")]
#[inline]
-pub(crate) fn exe_phdrs() -> (*const c::c_void, usize) {
+pub(crate) fn exe_phdrs() -> (*const c::c_void, usize, usize) {
unsafe {
let phdr = getauxval(AT_PHDR) as *const c::c_void;
+ let phent = getauxval(AT_PHENT) as usize;
let phnum = getauxval(AT_PHNUM) as usize;
- (phdr, phnum)
+ (phdr, phent, phnum)
}
}
-#[cfg(feature = "runtime")]
-#[inline]
-pub(in super::super) fn exe_phdrs_slice() -> &'static [Elf_Phdr] {
- let (phdr, phnum) = exe_phdrs();
-
- // SAFETY: We assume the `AT_PHDR` and `AT_PHNUM` values provided by the
- // kernel form a valid slice.
- unsafe { slice::from_raw_parts(phdr.cast(), phnum) }
-}
-
/// `AT_SYSINFO_EHDR` isn't present on all platforms in all configurations,
/// so if we don't see it, this function returns a null pointer.
#[inline]
@@ -150,3 +149,9 @@ pub(in super::super) fn sysinfo_ehdr() -> *const Elf_Ehdr {
getauxval(AT_SYSINFO_EHDR) as *const Elf_Ehdr
}
}
+
+#[cfg(feature = "runtime")]
+#[inline]
+pub(crate) fn entry() -> usize {
+ unsafe { getauxval(AT_ENTRY) as usize }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/param/mod.rs b/vendor/rustix/src/backend/linux_raw/param/mod.rs
index 956282074..365f01604 100644
--- a/vendor/rustix/src/backend/linux_raw/param/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/mod.rs
@@ -1,12 +1,15 @@
-// On Mustang, origin is in control of program startup and can access the
-// incoming aux values on the stack.
+// With "use-explicitly-provided-auxv" enabled, we expect to be initialized
+// with an explicit `rustix::param::init` call.
//
// With "use-libc-auxv" enabled, use libc's `getauxval`.
//
// Otherwise, we read aux values from /proc/self/auxv.
-#[cfg_attr(target_vendor = "mustang", path = "mustang_auxv.rs")]
+#[cfg_attr(feature = "use-explicitly-provided-auxv", path = "init.rs")]
#[cfg_attr(
- all(not(target_vendor = "mustang"), feature = "use-libc-auxv"),
+ all(
+ not(feature = "use-explicitly-provided-auxv"),
+ feature = "use-libc-auxv"
+ ),
path = "libc_auxv.rs"
)]
pub(crate) mod auxv;
diff --git a/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs b/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs
deleted file mode 100644
index f45a25faf..000000000
--- a/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs
+++ /dev/null
@@ -1,159 +0,0 @@
-//! Linux auxv support, for Mustang.
-//!
-//! # Safety
-//!
-//! This uses raw pointers to locate and read the kernel-provided auxv array.
-#![allow(unsafe_code)]
-
-use crate::backend::c;
-use crate::backend::elf::*;
-#[cfg(feature = "param")]
-use crate::ffi::CStr;
-use core::ffi::c_void;
-use core::mem::size_of;
-use core::ptr::{null, read};
-#[cfg(feature = "runtime")]
-use core::slice;
-use linux_raw_sys::general::{
- AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_NULL, AT_PAGESZ, AT_PHDR, AT_PHENT, AT_PHNUM,
- AT_SYSINFO_EHDR,
-};
-
-#[cfg(feature = "param")]
-#[inline]
-pub(crate) fn page_size() -> usize {
- // SAFETY: This is initialized during program startup.
- unsafe { PAGE_SIZE }
-}
-
-#[cfg(feature = "param")]
-#[inline]
-pub(crate) fn clock_ticks_per_second() -> u64 {
- // SAFETY: This is initialized during program startup.
- unsafe { CLOCK_TICKS_PER_SECOND as u64 }
-}
-
-#[cfg(feature = "param")]
-#[inline]
-pub(crate) fn linux_hwcap() -> (usize, usize) {
- // SAFETY: This is initialized during program startup.
- unsafe { (HWCAP, HWCAP2) }
-}
-
-#[cfg(feature = "param")]
-#[inline]
-pub(crate) fn linux_execfn() -> &'static CStr {
- // SAFETY: This is initialized during program startup. And we
- // assume it's a valid pointer to a NUL-terminated string.
- unsafe { CStr::from_ptr(EXECFN.0.cast()) }
-}
-
-#[cfg(feature = "runtime")]
-#[inline]
-pub(crate) fn exe_phdrs() -> (*const c_void, usize) {
- // SAFETY: This is initialized during program startup.
- unsafe { (PHDR.0.cast(), PHNUM) }
-}
-
-#[cfg(feature = "runtime")]
-#[inline]
-pub(in super::super) fn exe_phdrs_slice() -> &'static [Elf_Phdr] {
- let (phdr, phnum) = exe_phdrs();
-
- // SAFETY: We assume the `AT_PHDR` and `AT_PHNUM` values provided by the
- // kernel form a valid slice.
- unsafe { slice::from_raw_parts(phdr.cast(), phnum) }
-}
-
-/// `AT_SYSINFO_EHDR` isn't present on all platforms in all configurations,
-/// so if we don't see it, this function returns a null pointer.
-#[inline]
-pub(in super::super) fn sysinfo_ehdr() -> *const Elf_Ehdr {
- // SAFETY: This is initialized during program startup.
- unsafe { SYSINFO_EHDR.0 }
-}
-
-/// A const pointer to `T` that implements [`Sync`].
-#[repr(transparent)]
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub struct SyncConstPtr<T>(*const T);
-unsafe impl<T> Sync for SyncConstPtr<T> {}
-
-impl<T> SyncConstPtr<T> {
- /// Creates a `SyncConstPointer` from a raw pointer.
- ///
- /// Behavior is undefined if `ptr` is actually not
- /// safe to share across threads.
- pub const unsafe fn new(ptr: *const T) -> Self {
- Self(ptr)
- }
-}
-
-static mut PAGE_SIZE: usize = 0;
-static mut CLOCK_TICKS_PER_SECOND: usize = 0;
-static mut HWCAP: usize = 0;
-static mut HWCAP2: usize = 0;
-static mut SYSINFO_EHDR: SyncConstPtr<Elf_Ehdr> = unsafe { SyncConstPtr::new(null()) };
-static mut PHDR: SyncConstPtr<Elf_Phdr> = unsafe { SyncConstPtr::new(null()) };
-static mut PHNUM: usize = 0;
-static mut EXECFN: SyncConstPtr<c::c_char> = unsafe { SyncConstPtr::new(null()) };
-
-/// On mustang, we export a function to be called during initialization, and
-/// passed a pointer to the original environment variable block set up by the
-/// OS.
-pub(crate) unsafe fn init(envp: *mut *mut u8) {
- init_from_envp(envp);
-}
-
-/// # Safety
-///
-/// This must be passed a pointer to the environment variable buffer
-/// provided by the kernel, which is followed in memory by the auxv array.
-unsafe fn init_from_envp(mut envp: *mut *mut u8) {
- while !(*envp).is_null() {
- envp = envp.add(1);
- }
- init_from_auxp(envp.add(1).cast())
-}
-
-/// Process auxv entries from the auxv array pointed to by `auxp`.
-///
-/// # Safety
-///
-/// This must be passed a pointer to an auxv array.
-///
-/// The buffer contains `Elf_aux_t` elements, though it need not be aligned;
-/// function uses `read_unaligned` to read from it.
-unsafe fn init_from_auxp(mut auxp: *const Elf_auxv_t) {
- loop {
- let Elf_auxv_t { a_type, a_val } = read(auxp);
-
- match a_type as _ {
- AT_PAGESZ => PAGE_SIZE = a_val as usize,
- AT_CLKTCK => CLOCK_TICKS_PER_SECOND = a_val as usize,
- AT_HWCAP => HWCAP = a_val as usize,
- AT_HWCAP2 => HWCAP2 = a_val as usize,
- AT_PHDR => PHDR = SyncConstPtr::new(a_val.cast::<Elf_Phdr>()),
- AT_PHNUM => PHNUM = a_val as usize,
- AT_PHENT => assert_eq!(a_val as usize, size_of::<Elf_Phdr>()),
- AT_EXECFN => EXECFN = SyncConstPtr::new(a_val.cast::<c::c_char>()),
- AT_SYSINFO_EHDR => SYSINFO_EHDR = SyncConstPtr::new(a_val.cast::<Elf_Ehdr>()),
- AT_NULL => break,
- _ => (),
- }
- auxp = auxp.add(1);
- }
-}
-
-// ELF ABI
-
-#[repr(C)]
-#[derive(Copy, Clone)]
-struct Elf_auxv_t {
- a_type: usize,
-
- // Some of the values in the auxv array are pointers, so we make `a_val` a
- // pointer, in order to preserve their provenance. For the values which are
- // integers, we cast this to `usize`.
- a_val: *const c_void,
-}
diff --git a/vendor/rustix/src/backend/linux_raw/pid/syscalls.rs b/vendor/rustix/src/backend/linux_raw/pid/syscalls.rs
index f36bac048..9665ab3e9 100644
--- a/vendor/rustix/src/backend/linux_raw/pid/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/pid/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::ret_usize_infallible;
use crate::pid::{Pid, RawPid};
diff --git a/vendor/rustix/src/backend/linux_raw/pipe/syscalls.rs b/vendor/rustix/src/backend/linux_raw/pipe/syscalls.rs
index e05094237..ec3e459be 100644
--- a/vendor/rustix/src/backend/linux_raw/pipe/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/pipe/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::{c_int, c_uint, opt_mut, pass_usize, ret, ret_usize, slice};
use crate::backend::{c, MAX_IOV};
@@ -59,9 +58,9 @@ pub(crate) fn pipe_with(flags: PipeFlags) -> io::Result<(OwnedFd, OwnedFd)> {
#[inline]
pub fn splice(
- fd_in: BorrowedFd,
+ fd_in: BorrowedFd<'_>,
off_in: Option<&mut u64>,
- fd_out: BorrowedFd,
+ fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
len: usize,
flags: SpliceFlags,
@@ -81,8 +80,8 @@ pub fn splice(
#[inline]
pub unsafe fn vmsplice(
- fd: BorrowedFd,
- bufs: &[IoSliceRaw],
+ fd: BorrowedFd<'_>,
+ bufs: &[IoSliceRaw<'_>],
flags: SpliceFlags,
) -> io::Result<usize> {
let (bufs_addr, bufs_len) = slice(&bufs[..cmp::min(bufs.len(), MAX_IOV)]);
@@ -91,8 +90,8 @@ pub unsafe fn vmsplice(
#[inline]
pub fn tee(
- fd_in: BorrowedFd,
- fd_out: BorrowedFd,
+ fd_in: BorrowedFd<'_>,
+ fd_out: BorrowedFd<'_>,
len: usize,
flags: SpliceFlags,
) -> io::Result<usize> {
diff --git a/vendor/rustix/src/backend/linux_raw/pipe/types.rs b/vendor/rustix/src/backend/linux_raw/pipe/types.rs
index 90d2d79ab..c950b5d0a 100644
--- a/vendor/rustix/src/backend/linux_raw/pipe/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/pipe/types.rs
@@ -15,6 +15,9 @@ bitflags! {
const DIRECT = linux_raw_sys::general::O_DIRECT;
/// `O_NONBLOCK`
const NONBLOCK = linux_raw_sys::general::O_NONBLOCK;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -32,6 +35,9 @@ bitflags! {
const MORE = linux_raw_sys::general::SPLICE_F_MORE;
/// `SPLICE_F_GIFT`
const GIFT = linux_raw_sys::general::SPLICE_F_GIFT;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/prctl/syscalls.rs b/vendor/rustix/src/backend/linux_raw/prctl/syscalls.rs
index 193f4b7b4..1410d5128 100644
--- a/vendor/rustix/src/backend/linux_raw/prctl/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/prctl/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
use crate::backend::conv::{c_int, ret_c_int};
diff --git a/vendor/rustix/src/backend/linux_raw/process/syscalls.rs b/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
index 5ec2755ff..c0416bf5a 100644
--- a/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
@@ -3,17 +3,16 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use super::types::RawCpuSet;
use crate::backend::c;
-#[cfg(feature = "fs")]
+#[cfg(all(feature = "alloc", feature = "fs"))]
use crate::backend::conv::slice_mut;
use crate::backend::conv::{
by_mut, by_ref, c_int, c_uint, negative_pid, pass_usize, raw_fd, ret, ret_c_int,
ret_c_int_infallible, ret_c_uint, ret_infallible, ret_owned_fd, ret_usize, size_of,
- slice_just_addr, slice_just_addr_mut, zero,
+ slice_just_addr, zero,
};
use crate::fd::{AsRawFd, BorrowedFd, OwnedFd, RawFd};
#[cfg(feature = "fs")]
@@ -21,8 +20,8 @@ use crate::ffi::CStr;
use crate::io;
use crate::pid::RawPid;
use crate::process::{
- Cpuid, Gid, MembarrierCommand, MembarrierQuery, Pid, PidfdFlags, PidfdGetfdFlags, Resource,
- Rlimit, Uid, WaitId, WaitOptions, WaitStatus, WaitidOptions, WaitidStatus,
+ Cpuid, MembarrierCommand, MembarrierQuery, Pid, PidfdFlags, PidfdGetfdFlags, Resource, Rlimit,
+ Uid, WaitId, WaitOptions, WaitStatus, WaitidOptions, WaitidStatus,
};
use crate::signal::Signal;
use crate::utils::as_mut_ptr;
@@ -32,9 +31,10 @@ use linux_raw_sys::general::{
membarrier_cmd, membarrier_cmd_flag, rlimit, rlimit64, PRIO_PGRP, PRIO_PROCESS, PRIO_USER,
RLIM64_INFINITY, RLIM_INFINITY,
};
-use linux_raw_sys::ioctl::TIOCSCTTY;
#[cfg(feature = "fs")]
use {crate::backend::conv::ret_c_uint_infallible, crate::fs::Mode};
+#[cfg(feature = "alloc")]
+use {crate::backend::conv::slice_just_addr_mut, crate::process::Gid};
#[cfg(feature = "fs")]
#[inline]
@@ -53,7 +53,7 @@ pub(crate) fn chroot(filename: &CStr) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_chroot, filename)) }
}
-#[cfg(feature = "fs")]
+#[cfg(all(feature = "alloc", feature = "fs"))]
#[inline]
pub(crate) fn getcwd(buf: &mut [MaybeUninit<u8>]) -> io::Result<usize> {
let (buf_addr_mut, buf_len) = slice_mut(buf);
@@ -365,12 +365,12 @@ pub(crate) fn prlimit(pid: Option<Pid>, limit: Resource, new: Rlimit) -> io::Res
/// Convert a Rust [`Rlimit`] to a C `rlimit64`.
#[inline]
fn rlimit_from_linux(lim: rlimit64) -> Rlimit {
- let current = if lim.rlim_cur == RLIM64_INFINITY as _ {
+ let current = if lim.rlim_cur as u64 == RLIM64_INFINITY as u64 {
None
} else {
Some(lim.rlim_cur)
};
- let maximum = if lim.rlim_max == RLIM64_INFINITY as _ {
+ let maximum = if lim.rlim_max as u64 == RLIM64_INFINITY as u64 {
None
} else {
Some(lim.rlim_max)
@@ -395,12 +395,12 @@ fn rlimit_to_linux(lim: Rlimit) -> rlimit64 {
/// Like `rlimit_from_linux` but uses Linux's old 32-bit `rlimit`.
#[allow(clippy::useless_conversion)]
fn rlimit_from_linux_old(lim: rlimit) -> Rlimit {
- let current = if lim.rlim_cur == RLIM_INFINITY as _ {
+ let current = if lim.rlim_cur as u32 == RLIM_INFINITY as u32 {
None
} else {
Some(lim.rlim_cur.into())
};
- let maximum = if lim.rlim_max == RLIM_INFINITY as _ {
+ let maximum = if lim.rlim_max as u32 == RLIM_INFINITY as u32 {
None
} else {
Some(lim.rlim_max.into())
@@ -610,6 +610,7 @@ pub(crate) fn pidfd_open(pid: Pid, flags: PidfdFlags) -> io::Result<OwnedFd> {
unsafe { ret_owned_fd(syscall_readonly!(__NR_pidfd_open, pid, flags)) }
}
+#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn getgroups(buf: &mut [Gid]) -> io::Result<usize> {
let len = buf.len().try_into().map_err(|_| io::Errno::NOMEM)?;
@@ -622,15 +623,3 @@ pub(crate) fn getgroups(buf: &mut [Gid]) -> io::Result<usize> {
))
}
}
-
-#[inline]
-pub(crate) fn ioctl_tiocsctty(fd: BorrowedFd<'_>) -> io::Result<()> {
- unsafe {
- ret(syscall_readonly!(
- __NR_ioctl,
- fd,
- c_uint(TIOCSCTTY),
- by_ref(&0_u32)
- ))
- }
-}
diff --git a/vendor/rustix/src/backend/linux_raw/process/types.rs b/vendor/rustix/src/backend/linux_raw/process/types.rs
index f31749b83..841668a60 100644
--- a/vendor/rustix/src/backend/linux_raw/process/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/process/types.rs
@@ -1,4 +1,3 @@
-use crate::backend::c;
use linux_raw_sys::general::membarrier_cmd;
/// A command for use with [`membarrier`] and [`membarrier_cpu`].
@@ -78,15 +77,6 @@ pub enum Resource {
Rttime = linux_raw_sys::general::RLIMIT_RTTIME,
}
-/// `EXIT_SUCCESS`
-pub const EXIT_SUCCESS: c::c_int = 0;
-/// `EXIT_FAILURE`
-pub const EXIT_FAILURE: c::c_int = 1;
-/// The status value of a child terminated with a [`Signal::Abort`] signal.
-///
-/// [`Signal::Abort`]: crate::process::Signal::Abort
-pub const EXIT_SIGNALED_SIGABRT: c::c_int = 128 + linux_raw_sys::general::SIGABRT as i32;
-
/// A CPU identifier as a raw integer.
pub type RawCpuid = u32;
diff --git a/vendor/rustix/src/backend/linux_raw/pty/syscalls.rs b/vendor/rustix/src/backend/linux_raw/pty/syscalls.rs
index 529564c34..b64344fb9 100644
--- a/vendor/rustix/src/backend/linux_raw/pty/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/pty/syscalls.rs
@@ -3,22 +3,21 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
-use crate::backend::c;
-use crate::backend::conv::{by_ref, c_uint, ret, ret_owned_fd};
-use crate::fd::{BorrowedFd, OwnedFd};
-use crate::ffi::CString;
+use crate::backend::conv::{by_ref, c_uint, ret};
+use crate::fd::BorrowedFd;
use crate::io;
-use crate::path::DecInt;
-use crate::pty::OpenptFlags;
-use alloc::vec::Vec;
-use core::mem::MaybeUninit;
-use linux_raw_sys::ioctl::{TIOCGPTN, TIOCGPTPEER, TIOCSPTLCK};
+use linux_raw_sys::ioctl::TIOCSPTLCK;
+#[cfg(feature = "alloc")]
+use {
+ crate::backend::c, crate::ffi::CString, crate::path::DecInt, alloc::vec::Vec,
+ core::mem::MaybeUninit, linux_raw_sys::ioctl::TIOCGPTN,
+};
+#[cfg(feature = "alloc")]
#[inline]
-pub(crate) fn ptsname(fd: BorrowedFd, mut buffer: Vec<u8>) -> io::Result<CString> {
+pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CString> {
unsafe {
let mut n = MaybeUninit::<c::c_int>::uninit();
ret(syscall!(__NR_ioctl, fd, c_uint(TIOCGPTN), &mut n))?;
@@ -32,7 +31,7 @@ pub(crate) fn ptsname(fd: BorrowedFd, mut buffer: Vec<u8>) -> io::Result<CString
}
#[inline]
-pub(crate) fn unlockpt(fd: BorrowedFd) -> io::Result<()> {
+pub(crate) fn unlockpt(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe {
ret(syscall_readonly!(
__NR_ioctl,
@@ -42,16 +41,3 @@ pub(crate) fn unlockpt(fd: BorrowedFd) -> io::Result<()> {
))
}
}
-
-#[cfg(target_os = "linux")]
-#[inline]
-pub(crate) fn ioctl_tiocgptpeer(fd: BorrowedFd, flags: OpenptFlags) -> io::Result<OwnedFd> {
- unsafe {
- ret_owned_fd(syscall_readonly!(
- __NR_ioctl,
- fd,
- c_uint(TIOCGPTPEER),
- flags
- ))
- }
-}
diff --git a/vendor/rustix/src/backend/linux_raw/rand/syscalls.rs b/vendor/rustix/src/backend/linux_raw/rand/syscalls.rs
index 95a6efcff..e744f3193 100644
--- a/vendor/rustix/src/backend/linux_raw/rand/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/rand/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::{ret_usize, slice_mut};
use crate::io;
diff --git a/vendor/rustix/src/backend/linux_raw/rand/types.rs b/vendor/rustix/src/backend/linux_raw/rand/types.rs
index 21e950015..47b996d30 100644
--- a/vendor/rustix/src/backend/linux_raw/rand/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/rand/types.rs
@@ -13,5 +13,8 @@ bitflags! {
const NONBLOCK = linux_raw_sys::general::GRND_NONBLOCK;
/// `GRND_INSECURE`
const INSECURE = linux_raw_sys::general::GRND_INSECURE;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/runtime/syscalls.rs b/vendor/rustix/src/backend/linux_raw/runtime/syscalls.rs
index f82e2187b..c1ff3d239 100644
--- a/vendor/rustix/src/backend/linux_raw/runtime/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/runtime/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
#[cfg(target_arch = "x86")]
@@ -93,7 +92,10 @@ pub(crate) mod tls {
ret_infallible(syscall_readonly!(
__NR_arch_prctl,
c_uint(ARCH_SET_FS),
- data
+ data,
+ zero(),
+ zero(),
+ zero()
))
}
@@ -105,7 +107,14 @@ pub(crate) mod tls {
#[inline]
pub(crate) unsafe fn set_thread_name(name: &CStr) -> io::Result<()> {
- ret(syscall_readonly!(__NR_prctl, c_uint(PR_SET_NAME), name))
+ ret(syscall_readonly!(
+ __NR_prctl,
+ c_uint(PR_SET_NAME),
+ name,
+ zero(),
+ zero(),
+ zero()
+ ))
}
#[inline]
diff --git a/vendor/rustix/src/backend/linux_raw/runtime/tls.rs b/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
index 763971591..ad1634894 100644
--- a/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
+++ b/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
@@ -7,9 +7,9 @@
#![allow(unsafe_code)]
use crate::backend::c;
-use crate::backend::elf::*;
-use crate::backend::param::auxv::exe_phdrs_slice;
-use core::ptr::null;
+use crate::backend::param::auxv::exe_phdrs;
+use core::ptr::{null, NonNull};
+use linux_raw_sys::elf::*;
/// For use with [`set_thread_area`].
///
@@ -22,26 +22,41 @@ pub(crate) fn startup_tls_info() -> StartupTlsInfo {
let mut tls_phdr = null();
let mut stack_size = 0;
- let phdrs = exe_phdrs_slice();
+ let (first_phdr, phent, phnum) = exe_phdrs();
+ let mut current_phdr = first_phdr.cast::<Elf_Phdr>();
// SAFETY: We assume the phdr array pointer and length the kernel provided
// to the process describe a valid phdr array.
unsafe {
- for phdr in phdrs {
+ let phdrs_end = current_phdr.cast::<u8>().add(phnum * phent).cast();
+ while current_phdr != phdrs_end {
+ let phdr = &*current_phdr;
+ current_phdr = current_phdr.cast::<u8>().add(phent).cast();
+
match phdr.p_type {
- PT_PHDR => base = phdrs.as_ptr().cast::<u8>().sub(phdr.p_vaddr),
+ PT_PHDR => base = first_phdr.cast::<u8>().sub(phdr.p_vaddr),
PT_TLS => tls_phdr = phdr,
PT_GNU_STACK => stack_size = phdr.p_memsz,
_ => {}
}
}
- StartupTlsInfo {
- addr: base.cast::<u8>().add((*tls_phdr).p_vaddr).cast(),
- mem_size: (*tls_phdr).p_memsz,
- file_size: (*tls_phdr).p_filesz,
- align: (*tls_phdr).p_align,
- stack_size,
+ if tls_phdr.is_null() {
+ StartupTlsInfo {
+ addr: NonNull::dangling().as_ptr(),
+ mem_size: 0,
+ file_size: 0,
+ align: 1,
+ stack_size: 0,
+ }
+ } else {
+ StartupTlsInfo {
+ addr: base.cast::<u8>().add((*tls_phdr).p_vaddr).cast(),
+ mem_size: (*tls_phdr).p_memsz,
+ file_size: (*tls_phdr).p_filesz,
+ align: (*tls_phdr).p_align,
+ stack_size,
+ }
}
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/system/syscalls.rs b/vendor/rustix/src/backend/linux_raw/system/syscalls.rs
index 514751d6f..947d5168e 100644
--- a/vendor/rustix/src/backend/linux_raw/system/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/system/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use super::types::RawUname;
use crate::backend::conv::{ret, ret_infallible, slice};
diff --git a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
index 8f030e1c3..09100441f 100644
--- a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
@@ -3,27 +3,25 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
use crate::backend::conv::{by_ref, c_uint, ret};
use crate::fd::BorrowedFd;
use crate::io;
use crate::pid::Pid;
-#[cfg(feature = "procfs")]
+#[cfg(all(feature = "alloc", feature = "procfs"))]
use crate::procfs;
use crate::termios::{
Action, ControlModes, InputModes, LocalModes, OptionalActions, OutputModes, QueueSelector,
SpecialCodeIndex, Termios, Winsize,
};
-#[cfg(feature = "procfs")]
+#[cfg(all(feature = "alloc", feature = "procfs"))]
use crate::{ffi::CStr, fs::FileType, path::DecInt};
use core::mem::MaybeUninit;
use linux_raw_sys::general::IBSHIFT;
use linux_raw_sys::ioctl::{
- TCFLSH, TCSBRK, TCXONC, TIOCEXCL, TIOCGPGRP, TIOCGSID, TIOCGWINSZ, TIOCNXCL, TIOCSPGRP,
- TIOCSWINSZ,
+ TCFLSH, TCSBRK, TCXONC, TIOCGPGRP, TIOCGSID, TIOCGWINSZ, TIOCSPGRP, TIOCSWINSZ,
};
#[inline]
@@ -56,7 +54,7 @@ pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
#[inline]
pub(crate) fn tcsetattr(
- fd: BorrowedFd,
+ fd: BorrowedFd<'_>,
optional_actions: OptionalActions,
termios: &Termios,
) -> io::Result<()> {
@@ -84,17 +82,17 @@ pub(crate) fn tcsetattr(
}
#[inline]
-pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> {
+pub(crate) fn tcsendbreak(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TCSBRK), c_uint(0))) }
}
#[inline]
-pub(crate) fn tcdrain(fd: BorrowedFd) -> io::Result<()> {
+pub(crate) fn tcdrain(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TCSBRK), c_uint(1))) }
}
#[inline]
-pub(crate) fn tcflush(fd: BorrowedFd, queue_selector: QueueSelector) -> io::Result<()> {
+pub(crate) fn tcflush(fd: BorrowedFd<'_>, queue_selector: QueueSelector) -> io::Result<()> {
unsafe {
ret(syscall_readonly!(
__NR_ioctl,
@@ -106,7 +104,7 @@ pub(crate) fn tcflush(fd: BorrowedFd, queue_selector: QueueSelector) -> io::Resu
}
#[inline]
-pub(crate) fn tcflow(fd: BorrowedFd, action: Action) -> io::Result<()> {
+pub(crate) fn tcflow(fd: BorrowedFd<'_>, action: Action) -> io::Result<()> {
unsafe {
ret(syscall_readonly!(
__NR_ioctl,
@@ -118,7 +116,7 @@ pub(crate) fn tcflow(fd: BorrowedFd, action: Action) -> io::Result<()> {
}
#[inline]
-pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> {
+pub(crate) fn tcgetsid(fd: BorrowedFd<'_>) -> io::Result<Pid> {
unsafe {
let mut result = MaybeUninit::<c::pid_t>::uninit();
ret(syscall!(__NR_ioctl, fd, c_uint(TIOCGSID), &mut result))?;
@@ -128,7 +126,7 @@ pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> {
}
#[inline]
-pub(crate) fn tcsetwinsize(fd: BorrowedFd, winsize: Winsize) -> io::Result<()> {
+pub(crate) fn tcsetwinsize(fd: BorrowedFd<'_>, winsize: Winsize) -> io::Result<()> {
unsafe {
ret(syscall!(
__NR_ioctl,
@@ -144,16 +142,6 @@ pub(crate) fn tcsetpgrp(fd: BorrowedFd<'_>, pid: Pid) -> io::Result<()> {
unsafe { ret(syscall!(__NR_ioctl, fd, c_uint(TIOCSPGRP), pid)) }
}
-#[inline]
-pub(crate) fn ioctl_tiocexcl(fd: BorrowedFd<'_>) -> io::Result<()> {
- unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TIOCEXCL))) }
-}
-
-#[inline]
-pub(crate) fn ioctl_tiocnxcl(fd: BorrowedFd<'_>) -> io::Result<()> {
- unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TIOCNXCL))) }
-}
-
/// A wrapper around a conceptual `cfsetspeed` which handles an arbitrary
/// integer speed value.
#[inline]
@@ -240,8 +228,7 @@ pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool {
tcgetwinsize(fd).is_ok()
}
-#[cfg(feature = "procfs")]
-#[allow(unsafe_code)]
+#[cfg(all(feature = "alloc", feature = "procfs"))]
pub(crate) fn ttyname(fd: BorrowedFd<'_>, buf: &mut [MaybeUninit<u8>]) -> io::Result<usize> {
let fd_stat = crate::backend::fs::syscalls::fstat(fd)?;
@@ -256,7 +243,7 @@ pub(crate) fn ttyname(fd: BorrowedFd<'_>, buf: &mut [MaybeUninit<u8>]) -> io::Re
// Get a fd to '/proc/self/fd'.
let proc_self_fd = procfs::proc_self_fd()?;
- // Gather the ttyname by reading the 'fd' file inside 'proc_self_fd'.
+ // Gather the ttyname by reading the "fd" file inside `proc_self_fd`.
let r = crate::backend::fs::syscalls::readlinkat(
proc_self_fd,
DecInt::from_fd(fd).as_c_str(),
diff --git a/vendor/rustix/src/backend/linux_raw/thread/futex.rs b/vendor/rustix/src/backend/linux_raw/thread/futex.rs
index 4cde309a5..263e98070 100644
--- a/vendor/rustix/src/backend/linux_raw/thread/futex.rs
+++ b/vendor/rustix/src/backend/linux_raw/thread/futex.rs
@@ -9,6 +9,10 @@ bitflags::bitflags! {
const PRIVATE = linux_raw_sys::general::FUTEX_PRIVATE_FLAG;
/// `FUTEX_CLOCK_REALTIME`
const CLOCK_REALTIME = linux_raw_sys::general::FUTEX_CLOCK_REALTIME;
+
+ // This deliberately lacks a `const _ = !0`, so that users can use
+ // `from_bits_truncate` to extract the `SocketFlags` from a flags
+ // value that also includes a `SocketType`.
}
}
diff --git a/vendor/rustix/src/backend/linux_raw/thread/mod.rs b/vendor/rustix/src/backend/linux_raw/thread/mod.rs
index 8bb80c33a..6a002c632 100644
--- a/vendor/rustix/src/backend/linux_raw/thread/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/thread/mod.rs
@@ -1,4 +1,2 @@
-mod futex;
+pub(crate) mod futex;
pub(crate) mod syscalls;
-
-pub use futex::{FutexFlags, FutexOperation};
diff --git a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
index f23b7c2df..0095eed79 100644
--- a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
use crate::backend::conv::{
@@ -274,7 +273,7 @@ unsafe fn futex_old(
}
#[inline]
-pub(crate) fn setns(fd: BorrowedFd, nstype: c::c_int) -> io::Result<c::c_int> {
+pub(crate) fn setns(fd: BorrowedFd<'_>, nstype: c::c_int) -> io::Result<c::c_int> {
unsafe { ret_c_int(syscall_readonly!(__NR_setns, fd, c_int(nstype))) }
}
diff --git a/vendor/rustix/src/backend/linux_raw/time/syscalls.rs b/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
index 634ce2674..27c3652a4 100644
--- a/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::{ret, ret_infallible};
use crate::clockid::ClockId;
diff --git a/vendor/rustix/src/backend/linux_raw/time/types.rs b/vendor/rustix/src/backend/linux_raw/time/types.rs
index 62cb167e6..ab43aed7c 100644
--- a/vendor/rustix/src/backend/linux_raw/time/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/time/types.rs
@@ -20,6 +20,9 @@ bitflags! {
/// `TFD_CLOEXEC`
const CLOEXEC = linux_raw_sys::general::TFD_CLOEXEC;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -35,6 +38,9 @@ bitflags! {
/// `TFD_TIMER_CANCEL_ON_SET`
const CANCEL_ON_SET = linux_raw_sys::general::TFD_TIMER_CANCEL_ON_SET;
+
+ /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ const _ = !0;
}
}
@@ -47,10 +53,10 @@ bitflags! {
pub enum TimerfdClockId {
/// `CLOCK_REALTIME`—A clock that tells the “real” time.
///
- /// This is a clock that tells the amount of time elapsed since the
- /// Unix epoch, 1970-01-01T00:00:00Z. The clock is externally settable, so
- /// it is not monotonic. Successive reads may see decreasing times, so it
- /// isn't reliable for measuring durations.
+ /// This is a clock that tells the amount of time elapsed since the Unix
+ /// epoch, 1970-01-01T00:00:00Z. The clock is externally settable, so it is
+ /// not monotonic. Successive reads may see decreasing times, so it isn't
+ /// reliable for measuring durations.
Realtime = linux_raw_sys::general::CLOCK_REALTIME,
/// `CLOCK_MONOTONIC`—A clock that tells an abstract time.
diff --git a/vendor/rustix/src/backend/linux_raw/ugid/syscalls.rs b/vendor/rustix/src/backend/linux_raw/ugid/syscalls.rs
index 12ff6dce1..5f1551e7c 100644
--- a/vendor/rustix/src/backend/linux_raw/ugid/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/ugid/syscalls.rs
@@ -3,8 +3,7 @@
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
-#![allow(unsafe_code)]
-#![allow(clippy::undocumented_unsafe_blocks)]
+#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
use crate::backend::c;
use crate::backend::conv::ret_usize_infallible;
diff --git a/vendor/rustix/src/backend/linux_raw/vdso.rs b/vendor/rustix/src/backend/linux_raw/vdso.rs
index 606aee7d1..1b0ae5375 100644
--- a/vendor/rustix/src/backend/linux_raw/vdso.rs
+++ b/vendor/rustix/src/backend/linux_raw/vdso.rs
@@ -13,12 +13,12 @@
#![allow(unsafe_code)]
use super::c;
-use super::elf::*;
use crate::ffi::CStr;
use crate::utils::check_raw_pointer;
use core::ffi::c_void;
use core::mem::size_of;
use core::ptr::{null, null_mut};
+use linux_raw_sys::elf::*;
pub(super) struct Vdso {
// Load information
@@ -143,28 +143,31 @@ fn init_from_sysinfo_ehdr() -> Option<Vdso> {
match d.d_tag {
DT_STRTAB => {
vdso.symstrings =
- check_raw_pointer::<u8>(vdso.addr_from_elf(d.d_val)? as *mut _)?.as_ptr();
+ check_raw_pointer::<u8>(vdso.addr_from_elf(d.d_un.d_ptr)? as *mut _)?
+ .as_ptr();
}
DT_SYMTAB => {
vdso.symtab =
- check_raw_pointer::<Elf_Sym>(vdso.addr_from_elf(d.d_val)? as *mut _)?
+ check_raw_pointer::<Elf_Sym>(vdso.addr_from_elf(d.d_un.d_ptr)? as *mut _)?
.as_ptr();
}
DT_HASH => {
- hash =
- check_raw_pointer::<u32>(vdso.addr_from_elf(d.d_val)? as *mut _)?.as_ptr();
+ hash = check_raw_pointer::<u32>(vdso.addr_from_elf(d.d_un.d_ptr)? as *mut _)?
+ .as_ptr();
}
DT_VERSYM => {
vdso.versym =
- check_raw_pointer::<u16>(vdso.addr_from_elf(d.d_val)? as *mut _)?.as_ptr();
+ check_raw_pointer::<u16>(vdso.addr_from_elf(d.d_un.d_ptr)? as *mut _)?
+ .as_ptr();
}
DT_VERDEF => {
- vdso.verdef =
- check_raw_pointer::<Elf_Verdef>(vdso.addr_from_elf(d.d_val)? as *mut _)?
- .as_ptr();
+ vdso.verdef = check_raw_pointer::<Elf_Verdef>(
+ vdso.addr_from_elf(d.d_un.d_ptr)? as *mut _,
+ )?
+ .as_ptr();
}
DT_SYMENT => {
- if d.d_val != size_of::<Elf_Sym>() {
+ if d.d_un.d_ptr != size_of::<Elf_Sym>() {
return None; // Failed
}
}
@@ -194,8 +197,8 @@ fn init_from_sysinfo_ehdr() -> Option<Vdso> {
impl Vdso {
/// Parse the vDSO.
///
- /// Returns `None` if the vDSO can't be located or if it doesn't conform
- /// to our expectations.
+ /// Returns `None` if the vDSO can't be located or if it doesn't conform to
+ /// our expectations.
#[inline]
pub(super) fn new() -> Option<Self> {
init_from_sysinfo_ehdr()
diff --git a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
index 316d26a1c..1ff50415b 100644
--- a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
+++ b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
@@ -287,11 +287,10 @@ unsafe fn _rustix_clock_gettime_via_syscall_old(
clockid: c::c_int,
res: *mut Timespec,
) -> io::Result<()> {
- // Ordinarily `rustix` doesn't like to emulate system calls, but in
- // the case of time APIs, it's specific to Linux, specific to
- // 32-bit architectures *and* specific to old kernel versions, and
- // it's not that hard to fix up here, so that no other code needs
- // to worry about this.
+ // Ordinarily `rustix` doesn't like to emulate system calls, but in the
+ // case of time APIs, it's specific to Linux, specific to 32-bit
+ // architectures *and* specific to old kernel versions, and it's not that
+ // hard to fix up here, so that no other code needs to worry about this.
let mut old_result = MaybeUninit::<__kernel_old_timespec>::uninit();
let r0 = syscall!(__NR_clock_gettime, c_int(clockid), &mut old_result);
match ret(r0) {