diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/rustix/src/backend/linux_raw/io | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-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/io')
-rw-r--r-- | vendor/rustix/src/backend/linux_raw/io/errno.rs | 28 | ||||
-rw-r--r-- | vendor/rustix/src/backend/linux_raw/io/syscalls.rs | 70 | ||||
-rw-r--r-- | vendor/rustix/src/backend/linux_raw/io/types.rs | 9 |
3 files changed, 55 insertions, 52 deletions
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§ion=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; } } |