From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustix/src/process/chdir.rs | 10 ++++--- vendor/rustix/src/process/exit.rs | 6 ++-- vendor/rustix/src/process/id.rs | 6 ++-- vendor/rustix/src/process/ioctl.rs | 35 +++++++++++++++++++++-- vendor/rustix/src/process/membarrier.rs | 49 +++++++++++++++++--------------- vendor/rustix/src/process/mod.rs | 4 +-- vendor/rustix/src/process/pidfd.rs | 7 +++-- vendor/rustix/src/process/pidfd_getfd.rs | 9 ++++-- vendor/rustix/src/process/prctl.rs | 7 +++-- vendor/rustix/src/process/procctl.rs | 3 ++ vendor/rustix/src/process/wait.rs | 16 +++++++---- 11 files changed, 104 insertions(+), 48 deletions(-) (limited to 'vendor/rustix/src/process') diff --git a/vendor/rustix/src/process/chdir.rs b/vendor/rustix/src/process/chdir.rs index 0da0b5c2e..b110afef8 100644 --- a/vendor/rustix/src/process/chdir.rs +++ b/vendor/rustix/src/process/chdir.rs @@ -1,11 +1,13 @@ #[cfg(not(target_os = "fuchsia"))] use crate::backend::fd::AsFd; +#[cfg(feature = "fs")] +use crate::path; #[cfg(any(feature = "fs", not(target_os = "fuchsia")))] use crate::{backend, io}; -#[cfg(feature = "fs")] +#[cfg(all(feature = "alloc", feature = "fs"))] use { crate::ffi::{CStr, CString}, - crate::path::{self, SMALL_PATH_BUFFER_SIZE}, + crate::path::SMALL_PATH_BUFFER_SIZE, alloc::vec::Vec, }; @@ -48,7 +50,7 @@ pub fn fchdir(fd: Fd) -> io::Result<()> { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html /// [Linux]: https://man7.org/linux/man-pages/man3/getcwd.3.html -#[cfg(feature = "fs")] +#[cfg(all(feature = "alloc", feature = "fs"))] #[cfg(not(target_os = "wasi"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "fs")))] #[inline] @@ -56,7 +58,7 @@ pub fn getcwd>>(reuse: B) -> io::Result { _getcwd(reuse.into()) } -#[cfg(feature = "fs")] +#[cfg(all(feature = "alloc", feature = "fs"))] #[allow(unsafe_code)] fn _getcwd(mut buffer: Vec) -> io::Result { buffer.clear(); diff --git a/vendor/rustix/src/process/exit.rs b/vendor/rustix/src/process/exit.rs index 5533dbabb..95b78c4a1 100644 --- a/vendor/rustix/src/process/exit.rs +++ b/vendor/rustix/src/process/exit.rs @@ -10,7 +10,7 @@ use crate::backend; /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html /// [Linux]: https://man7.org/linux/man-pages/man3/exit.3.html -pub const EXIT_SUCCESS: i32 = backend::process::types::EXIT_SUCCESS; +pub const EXIT_SUCCESS: i32 = backend::c::EXIT_SUCCESS; /// `EXIT_FAILURE` for use with [`exit`]. /// @@ -22,7 +22,7 @@ pub const EXIT_SUCCESS: i32 = backend::process::types::EXIT_SUCCESS; /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html /// [Linux]: https://man7.org/linux/man-pages/man3/exit.3.html -pub const EXIT_FAILURE: i32 = backend::process::types::EXIT_FAILURE; +pub const EXIT_FAILURE: i32 = backend::c::EXIT_FAILURE; /// The exit status used by a process terminated with a [`Signal::Abort`] /// signal. @@ -33,4 +33,4 @@ pub const EXIT_FAILURE: i32 = backend::process::types::EXIT_FAILURE; /// [Linux]: https://tldp.org/LDP/abs/html/exitcodes.html /// [`Signal::Abort`]: crate::process::Signal::Abort #[cfg(not(any(target_os = "espidf", target_os = "wasi")))] -pub const EXIT_SIGNALED_SIGABRT: i32 = backend::process::types::EXIT_SIGNALED_SIGABRT; +pub const EXIT_SIGNALED_SIGABRT: i32 = backend::c::EXIT_SIGNALED_SIGABRT; diff --git a/vendor/rustix/src/process/id.rs b/vendor/rustix/src/process/id.rs index 4cacf1ab0..4ed33a6c8 100644 --- a/vendor/rustix/src/process/id.rs +++ b/vendor/rustix/src/process/id.rs @@ -8,6 +8,7 @@ #![allow(unsafe_code)] use crate::{backend, io}; +#[cfg(feature = "alloc")] use alloc::vec::Vec; #[cfg(linux_kernel)] use backend::process::types::RawCpuid; @@ -208,12 +209,11 @@ pub fn setsid() -> io::Result { /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgroups.html /// [Linux]: https://man7.org/linux/man-pages/man2/getgroups.2.html +#[cfg(feature = "alloc")] pub fn getgroups() -> io::Result> { - let mut buffer = Vec::new(); - // This code would benefit from having a better way to read into // uninitialized memory, but that requires `unsafe`. - buffer.reserve(8); + let mut buffer = Vec::with_capacity(8); buffer.resize(buffer.capacity(), Gid::ROOT); loop { diff --git a/vendor/rustix/src/process/ioctl.rs b/vendor/rustix/src/process/ioctl.rs index cde6b5b3c..3c9d90255 100644 --- a/vendor/rustix/src/process/ioctl.rs +++ b/vendor/rustix/src/process/ioctl.rs @@ -1,4 +1,13 @@ -use crate::{backend, io}; +//! Process-oriented `ioctl`s. +//! +//! # Safety +//! +//! This module invokes `ioctl`s. + +#![allow(unsafe_code)] + +use crate::{backend, io, ioctl}; +use backend::c; use backend::fd::AsFd; /// `ioctl(fd, TIOCSCTTY, 0)`—Sets the controlling terminal for the processs. @@ -17,5 +26,27 @@ use backend::fd::AsFd; #[inline] #[doc(alias = "TIOCSCTTY")] pub fn ioctl_tiocsctty(fd: Fd) -> io::Result<()> { - backend::process::syscalls::ioctl_tiocsctty(fd.as_fd()) + unsafe { ioctl::ioctl(fd, Tiocsctty) } +} + +#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] +struct Tiocsctty; + +#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] +unsafe impl ioctl::Ioctl for Tiocsctty { + type Output = (); + + const IS_MUTATING: bool = false; + const OPCODE: ioctl::Opcode = ioctl::Opcode::old(c::TIOCSCTTY as ioctl::RawOpcode); + + fn as_ptr(&mut self) -> *mut c::c_void { + (&0u32) as *const u32 as *mut c::c_void + } + + unsafe fn output_from_ptr( + _: ioctl::IoctlOutput, + _: *mut c::c_void, + ) -> io::Result { + Ok(()) + } } diff --git a/vendor/rustix/src/process/membarrier.rs b/vendor/rustix/src/process/membarrier.rs index df9f1a44c..9c42bbd85 100644 --- a/vendor/rustix/src/process/membarrier.rs +++ b/vendor/rustix/src/process/membarrier.rs @@ -14,26 +14,29 @@ bitflags::bitflags! { #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MembarrierQuery: u32 { - /// `MEMBARRIER_CMD_GLOBAL` (also known as `MEMBARRIER_CMD_SHARED`) - #[doc(alias = "SHARED")] - #[doc(alias = "MEMBARRIER_CMD_SHARED")] - const GLOBAL = MembarrierCommand::Global as _; - /// `MEMBARRIER_CMD_GLOBAL_EXPEDITED` - const GLOBAL_EXPEDITED = MembarrierCommand::GlobalExpedited as _; - /// `MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED` - const REGISTER_GLOBAL_EXPEDITED = MembarrierCommand::RegisterGlobalExpedited as _; - /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED` - const PRIVATE_EXPEDITED = MembarrierCommand::PrivateExpedited as _; - /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED` - const REGISTER_PRIVATE_EXPEDITED = MembarrierCommand::RegisterPrivateExpedited as _; - /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE` - const PRIVATE_EXPEDITED_SYNC_CORE = MembarrierCommand::PrivateExpeditedSyncCore as _; - /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE` - const REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = MembarrierCommand::RegisterPrivateExpeditedSyncCore as _; - /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10) - const PRIVATE_EXPEDITED_RSEQ = MembarrierCommand::PrivateExpeditedRseq as _; - /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10) - const REGISTER_PRIVATE_EXPEDITED_RSEQ = MembarrierCommand::RegisterPrivateExpeditedRseq as _; + /// `MEMBARRIER_CMD_GLOBAL` (also known as `MEMBARRIER_CMD_SHARED`) + #[doc(alias = "SHARED")] + #[doc(alias = "MEMBARRIER_CMD_SHARED")] + const GLOBAL = MembarrierCommand::Global as _; + /// `MEMBARRIER_CMD_GLOBAL_EXPEDITED` + const GLOBAL_EXPEDITED = MembarrierCommand::GlobalExpedited as _; + /// `MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED` + const REGISTER_GLOBAL_EXPEDITED = MembarrierCommand::RegisterGlobalExpedited as _; + /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED` + const PRIVATE_EXPEDITED = MembarrierCommand::PrivateExpedited as _; + /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED` + const REGISTER_PRIVATE_EXPEDITED = MembarrierCommand::RegisterPrivateExpedited as _; + /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE` + const PRIVATE_EXPEDITED_SYNC_CORE = MembarrierCommand::PrivateExpeditedSyncCore as _; + /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE` + const REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = MembarrierCommand::RegisterPrivateExpeditedSyncCore as _; + /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10) + const PRIVATE_EXPEDITED_RSEQ = MembarrierCommand::PrivateExpeditedRseq as _; + /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10) + const REGISTER_PRIVATE_EXPEDITED_RSEQ = MembarrierCommand::RegisterPrivateExpeditedRseq as _; + + /// + const _ = !0; } } @@ -51,9 +54,9 @@ impl MembarrierQuery { /// `membarrier(MEMBARRIER_CMD_QUERY, 0, 0)`—Query the supported `membarrier` /// commands. /// -/// This function doesn't return a `Result` because it always succeeds; if -/// the underlying OS doesn't support the `membarrier` syscall, it returns -/// an empty `MembarrierQuery` value. +/// This function doesn't return a `Result` because it always succeeds; if the +/// underlying OS doesn't support the `membarrier` syscall, it returns an empty +/// `MembarrierQuery` value. /// /// # References /// - [Linux] diff --git a/vendor/rustix/src/process/mod.rs b/vendor/rustix/src/process/mod.rs index 9c62f127e..55eed1ac8 100644 --- a/vendor/rustix/src/process/mod.rs +++ b/vendor/rustix/src/process/mod.rs @@ -7,7 +7,7 @@ mod chroot; mod exit; #[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id. mod id; -#[cfg(not(target_os = "espidf"))] +#[cfg(not(any(target_os = "aix", target_os = "espidf")))] mod ioctl; #[cfg(not(any(target_os = "espidf", target_os = "wasi")))] mod kill; @@ -45,7 +45,7 @@ pub use chroot::*; pub use exit::*; #[cfg(not(target_os = "wasi"))] pub use id::*; -#[cfg(not(target_os = "espidf"))] +#[cfg(not(any(target_os = "aix", target_os = "espidf")))] pub use ioctl::*; #[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub use kill::*; diff --git a/vendor/rustix/src/process/pidfd.rs b/vendor/rustix/src/process/pidfd.rs index fb8298117..0548055fc 100644 --- a/vendor/rustix/src/process/pidfd.rs +++ b/vendor/rustix/src/process/pidfd.rs @@ -11,11 +11,14 @@ bitflags::bitflags! { pub struct PidfdFlags: backend::c::c_uint { /// `PIDFD_NONBLOCK`. const NONBLOCK = backend::c::PIDFD_NONBLOCK; + + /// + const _ = !0; } } -/// `syscall(SYS_pidfd_open, pid, flags)`—Creates a file descriptor for -/// a process. +/// `syscall(SYS_pidfd_open, pid, flags)`—Creates a file descriptor for a +/// process. /// /// # References /// - [Linux] diff --git a/vendor/rustix/src/process/pidfd_getfd.rs b/vendor/rustix/src/process/pidfd_getfd.rs index 7234810c2..27d4f1986 100644 --- a/vendor/rustix/src/process/pidfd_getfd.rs +++ b/vendor/rustix/src/process/pidfd_getfd.rs @@ -1,3 +1,5 @@ +//! The [`pidfd_getfd`] function and supporting types. + #![allow(unsafe_code)] use crate::fd::OwnedFd; use crate::{backend, io}; @@ -15,11 +17,14 @@ bitflags::bitflags! { /// All flags are reserved for future use. #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] - pub struct PidfdGetfdFlags: backend::c::c_uint {} + pub struct PidfdGetfdFlags: backend::c::c_uint { + /// + const _ = !0; + } } /// `syscall(SYS_pidfd_getfd, pidfd, flags)`—Obtain a duplicate of another -/// process's file descriptor. +/// process' file descriptor. /// /// # References /// - [Linux] diff --git a/vendor/rustix/src/process/prctl.rs b/vendor/rustix/src/process/prctl.rs index d79657e98..59be7020f 100644 --- a/vendor/rustix/src/process/prctl.rs +++ b/vendor/rustix/src/process/prctl.rs @@ -96,7 +96,7 @@ impl TryFrom for DumpableBehavior { } } -/// Get the current state of the calling process's `dumpable` attribute. +/// Get the current state of the calling process' `dumpable` attribute. /// /// # References /// - [`prctl(PR_GET_DUMPABLE,...)`] @@ -148,6 +148,9 @@ bitflags! { /// Generate a [`Signal::Bus`] signal on unaligned user access. #[doc(alias = "PR_UNALIGN_SIGBUS")] const SIGBUS = 2; + + /// + const _ = !0; } } @@ -670,7 +673,7 @@ pub unsafe fn set_virtual_memory_map_address( #[inline] #[doc(alias = "PR_SET_MM")] #[doc(alias = "PR_SET_MM_EXE_FILE")] -pub fn set_executable_file(fd: BorrowedFd) -> io::Result<()> { +pub fn set_executable_file(fd: BorrowedFd<'_>) -> io::Result<()> { let fd = usize::try_from(fd.as_raw_fd()).map_err(|_r| io::Errno::RANGE)?; unsafe { prctl_3args(PR_SET_MM, PR_SET_MM_EXE_FILE as *mut _, fd as *mut _) }.map(|_r| ()) } diff --git a/vendor/rustix/src/process/procctl.rs b/vendor/rustix/src/process/procctl.rs index 8da53d383..5225f16f7 100644 --- a/vendor/rustix/src/process/procctl.rs +++ b/vendor/rustix/src/process/procctl.rs @@ -229,6 +229,9 @@ bitflags! { const OWNED = 1; /// The process is the root of the reaper tree (pid 1). const REALINIT = 2; + + /// + const _ = !0; } } diff --git a/vendor/rustix/src/process/wait.rs b/vendor/rustix/src/process/wait.rs index 72b37d6d4..b43bd03d6 100644 --- a/vendor/rustix/src/process/wait.rs +++ b/vendor/rustix/src/process/wait.rs @@ -22,6 +22,9 @@ bitflags! { /// Return if a stopped child has been resumed by delivery of /// [`Signal::Cont`]. const CONTINUED = bitcast!(backend::process::wait::WCONTINUED); + + /// + const _ = !0; } } @@ -42,6 +45,9 @@ bitflags! { const NOWAIT = bitcast!(backend::process::wait::WNOWAIT); /// Wait for processes that have been stopped. const STOPPED = bitcast!(backend::process::wait::WSTOPPED); + + /// + const _ = !0; } } @@ -170,7 +176,7 @@ impl WaitidStatus { /// Returns the number of the signal that stopped the process, /// if the process was stopped by a signal. #[inline] - #[cfg(not(any(target_os = "netbsd", target_os = "fuchsia", target_os = "emscripten")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))] pub fn stopping_signal(&self) -> Option { if self.stopped() { Some(self.si_status() as _) @@ -182,7 +188,7 @@ impl WaitidStatus { /// Returns the number of the signal that trapped the process, /// if the process was trapped by a signal. #[inline] - #[cfg(not(any(target_os = "netbsd", target_os = "fuchsia", target_os = "emscripten")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))] pub fn trapping_signal(&self) -> Option { if self.trapped() { Some(self.si_status() as _) @@ -194,7 +200,7 @@ impl WaitidStatus { /// Returns the exit status number returned by the process, /// if it exited normally. #[inline] - #[cfg(not(any(target_os = "netbsd", target_os = "fuchsia", target_os = "emscripten")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))] pub fn exit_status(&self) -> Option { if self.exited() { Some(self.si_status() as _) @@ -206,7 +212,7 @@ impl WaitidStatus { /// Returns the number of the signal that terminated the process, /// if the process was terminated by a signal. #[inline] - #[cfg(not(any(target_os = "netbsd", target_os = "fuchsia", target_os = "emscripten")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))] pub fn terminating_signal(&self) -> Option { if self.killed() || self.dumped() { Some(self.si_status() as _) @@ -231,7 +237,7 @@ impl WaitidStatus { self.0.si_code } - #[cfg(not(any(target_os = "netbsd", target_os = "fuchsia", target_os = "emscripten")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))] #[allow(unsafe_code)] fn si_status(&self) -> backend::c::c_int { // SAFETY: POSIX [specifies] that the `siginfo_t` returned by a -- cgit v1.2.3