summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/backend')
-rw-r--r--vendor/rustix/src/backend/libc/fs/dir.rs16
-rw-r--r--vendor/rustix/src/backend/libc/io/errno.rs2
-rw-r--r--vendor/rustix/src/backend/libc/mod.rs3
-rw-r--r--vendor/rustix/src/backend/libc/offset.rs2
-rw-r--r--vendor/rustix/src/backend/libc/termios/mod.rs1
-rw-r--r--vendor/rustix/src/backend/libc/termios/syscalls.rs47
-rw-r--r--vendor/rustix/src/backend/libc/thread/syscalls.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/mod.rs1
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/auxv.rs7
-rw-r--r--vendor/rustix/src/backend/linux_raw/termios/types.rs8
-rw-r--r--vendor/rustix/src/backend/linux_raw/thread/syscalls.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs2
12 files changed, 64 insertions, 37 deletions
diff --git a/vendor/rustix/src/backend/libc/fs/dir.rs b/vendor/rustix/src/backend/libc/fs/dir.rs
index 8e5477401..6b69c3600 100644
--- a/vendor/rustix/src/backend/libc/fs/dir.rs
+++ b/vendor/rustix/src/backend/libc/fs/dir.rs
@@ -242,7 +242,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
// with a field that we missed here. And we can avoid blindly copying the
// whole `d_name` field, which may not be entirely allocated.
#[cfg_attr(target_os = "wasi", allow(unused_mut))]
- #[cfg(not(target_os = "dragonfly"))]
+ #[cfg(not(any(target_os = "freebsd", target_os = "dragonfly")))]
let mut dirent = libc_dirent {
#[cfg(not(any(
target_os = "aix",
@@ -253,7 +253,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
d_type,
#[cfg(not(any(
target_os = "aix",
- target_os = "freebsd",
+ target_os = "freebsd", // Until FreeBSD 12
target_os = "haiku",
target_os = "ios",
target_os = "macos",
@@ -306,14 +306,18 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
// */
- // On dragonfly, `dirent` has some non-public padding fields so we can't
- // directly initialize it.
- #[cfg(target_os = "dragonfly")]
- let mut dirent = unsafe {
+ // On dragonfly and FreeBSD 12, `dirent` has some non-public padding fields
+ // so we can't directly initialize it.
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ let mut dirent = {
let mut dirent: libc_dirent = zeroed();
dirent.d_fileno = d_fileno;
dirent.d_namlen = d_namlen;
dirent.d_type = d_type;
+ #[cfg(target_os = "freebsd")]
+ {
+ dirent.d_reclen = d_reclen;
+ }
dirent
};
diff --git a/vendor/rustix/src/backend/libc/io/errno.rs b/vendor/rustix/src/backend/libc/io/errno.rs
index 131709e0c..25323771c 100644
--- a/vendor/rustix/src/backend/libc/io/errno.rs
+++ b/vendor/rustix/src/backend/libc/io/errno.rs
@@ -158,7 +158,7 @@ impl Errno {
/// `ECANCELED`
pub const CANCELED: Self = Self(c::ECANCELED);
/// `ECAPMODE`
- #[cfg(any(target_os = "freebsd"))]
+ #[cfg(target_os = "freebsd")]
pub const CAPMODE: Self = Self(c::ECAPMODE);
/// `ECHILD`
#[cfg(not(windows))]
diff --git a/vendor/rustix/src/backend/libc/mod.rs b/vendor/rustix/src/backend/libc/mod.rs
index 16d21b657..70029282f 100644
--- a/vendor/rustix/src/backend/libc/mod.rs
+++ b/vendor/rustix/src/backend/libc/mod.rs
@@ -61,7 +61,6 @@ pub(crate) mod fs;
pub(crate) mod io;
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(feature = "io_uring")]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "io_uring")))]
pub(crate) mod io_uring;
#[cfg(not(any(windows, target_os = "wasi")))]
#[cfg(feature = "mm")]
@@ -82,7 +81,7 @@ pub(crate) mod process;
#[cfg(not(windows))]
#[cfg(feature = "rand")]
pub(crate) mod rand;
-#[cfg(not(any(windows, target_os = "wasi")))]
+#[cfg(not(windows))]
#[cfg(feature = "termios")]
pub(crate) mod termios;
#[cfg(not(windows))]
diff --git a/vendor/rustix/src/backend/libc/offset.rs b/vendor/rustix/src/backend/libc/offset.rs
index 48729be0c..8aae9d073 100644
--- a/vendor/rustix/src/backend/libc/offset.rs
+++ b/vendor/rustix/src/backend/libc/offset.rs
@@ -360,7 +360,7 @@ pub(super) use readwrite_pv::{preadv as libc_preadv, pwritev as libc_pwritev};
)))]
#[cfg(feature = "fs")]
pub(super) use c::posix_fallocate as libc_posix_fallocate;
-#[cfg(any(target_os = "l4re"))]
+#[cfg(target_os = "l4re")]
#[cfg(feature = "fs")]
pub(super) use c::posix_fallocate64 as libc_posix_fallocate;
#[cfg(not(any(
diff --git a/vendor/rustix/src/backend/libc/termios/mod.rs b/vendor/rustix/src/backend/libc/termios/mod.rs
index 1e0181a99..c82c95958 100644
--- a/vendor/rustix/src/backend/libc/termios/mod.rs
+++ b/vendor/rustix/src/backend/libc/termios/mod.rs
@@ -1,2 +1,3 @@
pub(crate) mod syscalls;
+#[cfg(not(target_os = "wasi"))]
pub(crate) mod types;
diff --git a/vendor/rustix/src/backend/libc/termios/syscalls.rs b/vendor/rustix/src/backend/libc/termios/syscalls.rs
index e0ab7a016..f54e9a6f3 100644
--- a/vendor/rustix/src/backend/libc/termios/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/termios/syscalls.rs
@@ -10,12 +10,15 @@ use crate::fd::BorrowedFd;
#[cfg(feature = "procfs")]
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
use crate::ffi::CStr;
+#[cfg(not(target_os = "wasi"))]
use crate::io;
+#[cfg(not(target_os = "wasi"))]
use crate::process::{Pid, RawNonZeroPid};
+#[cfg(not(target_os = "wasi"))]
use crate::termios::{Action, OptionalActions, QueueSelector, Speed, Termios, Winsize};
use core::mem::MaybeUninit;
-use libc_errno::errno;
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
let mut result = MaybeUninit::<Termios>::uninit();
unsafe {
@@ -24,6 +27,7 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
}
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
unsafe {
let pid = ret_pid_t(c::tcgetpgrp(borrowed_fd(fd)))?;
@@ -32,10 +36,12 @@ pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
}
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcsetpgrp(fd: BorrowedFd<'_>, pid: Pid) -> io::Result<()> {
unsafe { ret(c::tcsetpgrp(borrowed_fd(fd), pid.as_raw_nonzero().get())) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcsetattr(
fd: BorrowedFd,
optional_actions: OptionalActions,
@@ -50,22 +56,27 @@ pub(crate) fn tcsetattr(
}
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::tcsendbreak(borrowed_fd(fd), 0)) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcdrain(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::tcdrain(borrowed_fd(fd))) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcflush(fd: BorrowedFd, queue_selector: QueueSelector) -> io::Result<()> {
unsafe { ret(c::tcflush(borrowed_fd(fd), queue_selector as _)) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcflow(fd: BorrowedFd, action: Action) -> io::Result<()> {
unsafe { ret(c::tcflow(borrowed_fd(fd), action as _)) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> {
unsafe {
let pid = ret_pid_t(c::tcgetsid(borrowed_fd(fd)))?;
@@ -74,10 +85,12 @@ pub(crate) fn tcgetsid(fd: BorrowedFd) -> io::Result<Pid> {
}
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcsetwinsize(fd: BorrowedFd, winsize: Winsize) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCSWINSZ, &winsize)) }
}
+#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcgetwinsize(fd: BorrowedFd) -> io::Result<Winsize> {
unsafe {
let mut buf = MaybeUninit::<Winsize>::uninit();
@@ -90,59 +103,51 @@ pub(crate) fn tcgetwinsize(fd: BorrowedFd) -> io::Result<Winsize> {
}
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
#[must_use]
pub(crate) fn cfgetospeed(termios: &Termios) -> Speed {
unsafe { c::cfgetospeed(termios) }
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
#[must_use]
pub(crate) fn cfgetispeed(termios: &Termios) -> Speed {
unsafe { c::cfgetispeed(termios) }
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn cfmakeraw(termios: &mut Termios) {
unsafe { c::cfmakeraw(termios) }
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn cfsetospeed(termios: &mut Termios, speed: Speed) -> io::Result<()> {
unsafe { ret(c::cfsetospeed(termios, speed)) }
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn cfsetispeed(termios: &mut Termios, speed: Speed) -> io::Result<()> {
unsafe { ret(c::cfsetispeed(termios, speed)) }
}
+#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn cfsetspeed(termios: &mut Termios, speed: Speed) -> io::Result<()> {
unsafe { ret(c::cfsetspeed(termios, speed)) }
}
pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool {
- let res = unsafe { c::isatty(borrowed_fd(fd)) };
- if res == 0 {
- match errno().0 {
- #[cfg(not(any(target_os = "android", target_os = "linux")))]
- c::ENOTTY => false,
-
- // Old Linux versions reportedly return `EINVAL`.
- // <https://man7.org/linux/man-pages/man3/isatty.3.html#ERRORS>
- #[cfg(any(target_os = "android", target_os = "linux"))]
- c::ENOTTY | c::EINVAL => false,
-
- // Darwin mysteriously returns `EOPNOTSUPP` sometimes.
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- c::EOPNOTSUPP => false,
-
- err => panic!("unexpected error from isatty: {:?}", err),
- }
- } else {
- true
- }
+ // Use the return value of `isatty` alone. We don't check `errno` because
+ // we return `bool` rather than `io::Result<bool>`, because we assume
+ // `BorrrowedFd` protects us from `EBADF`, and any other reasonably
+ // anticipated errno value would end up interpreted as "assume it's not a
+ // terminal" anyway.
+ unsafe { c::isatty(borrowed_fd(fd)) != 0 }
}
#[cfg(feature = "procfs")]
diff --git a/vendor/rustix/src/backend/libc/thread/syscalls.rs b/vendor/rustix/src/backend/libc/thread/syscalls.rs
index 0709fbb19..4f69b8f63 100644
--- a/vendor/rustix/src/backend/libc/thread/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/thread/syscalls.rs
@@ -293,3 +293,9 @@ pub(crate) fn gettid() -> Pid {
pub(crate) fn setns(fd: BorrowedFd, nstype: c::c_int) -> io::Result<c::c_int> {
unsafe { ret_c_int(c::setns(borrowed_fd(fd), nstype)) }
}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn unshare(flags: crate::thread::UnshareFlags) -> io::Result<()> {
+ unsafe { ret(c::unshare(flags.bits() as i32)) }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/mod.rs b/vendor/rustix/src/backend/linux_raw/mod.rs
index 231dc37b6..e7e073e32 100644
--- a/vendor/rustix/src/backend/linux_raw/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/mod.rs
@@ -28,7 +28,6 @@ mod vdso_wrappers;
pub(crate) mod fs;
pub(crate) mod io;
#[cfg(feature = "io_uring")]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "io_uring")))]
pub(crate) mod io_uring;
#[cfg(feature = "mm")]
pub(crate) mod mm;
diff --git a/vendor/rustix/src/backend/linux_raw/param/auxv.rs b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
index 20a3d5da6..acdd9d0e7 100644
--- a/vendor/rustix/src/backend/linux_raw/param/auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
@@ -10,6 +10,7 @@ use super::super::elf::*;
use crate::fd::OwnedFd;
#[cfg(feature = "param")]
use crate::ffi::CStr;
+#[cfg(not(target_vendor = "mustang"))]
use crate::fs::{Mode, OFlags};
use crate::utils::{as_ptr, check_raw_pointer};
use alloc::vec::Vec;
@@ -130,6 +131,7 @@ static PHNUM: AtomicUsize = AtomicUsize::new(0);
static EXECFN: AtomicPtr<c::c_char> = AtomicPtr::new(null_mut());
/// On non-Mustang platforms, we read the aux vector from /proc/self/auxv.
+#[cfg(not(target_vendor = "mustang"))]
fn init_from_proc_self_auxv() {
// Open "/proc/self/auxv", either because we trust "/proc", or because
// we're running inside QEMU and `proc_self_auxv`'s extra checking foils
@@ -146,6 +148,11 @@ fn init_from_proc_self_auxv() {
let _ = init_from_auxv_file(file);
}
+#[cfg(target_vendor = "mustang")]
+fn init_from_proc_self_auxv() {
+ panic!("mustang should have initialized the auxv values");
+}
+
/// Process auxv entries from the open file `auxv`.
fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
let mut buffer = Vec::<u8>::with_capacity(512);
diff --git a/vendor/rustix/src/backend/linux_raw/termios/types.rs b/vendor/rustix/src/backend/linux_raw/termios/types.rs
index 88db4e1c9..a44f1eda5 100644
--- a/vendor/rustix/src/backend/linux_raw/termios/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/termios/types.rs
@@ -338,19 +338,19 @@ pub const B1500000: Speed = linux_raw_sys::general::B1500000;
pub const B2000000: Speed = linux_raw_sys::general::B2000000;
/// `B2500000`
-#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
+#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
pub const B2500000: Speed = linux_raw_sys::general::B2500000;
/// `B3000000`
-#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
+#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
pub const B3000000: Speed = linux_raw_sys::general::B3000000;
/// `B3500000`
-#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
+#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
pub const B3500000: Speed = linux_raw_sys::general::B3500000;
/// `B4000000`
-#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
+#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
pub const B4000000: Speed = linux_raw_sys::general::B4000000;
/// `CSIZE`
diff --git a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
index 99c632e7e..2ec3e43e8 100644
--- a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
@@ -288,3 +288,9 @@ unsafe fn futex_old(
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))) }
}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn unshare(flags: crate::thread::UnshareFlags) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_unshare, c_uint(flags.bits()))) }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
index 487835314..aaa000622 100644
--- a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
+++ b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
@@ -364,7 +364,7 @@ fn init() {
// On all 64-bit platforms, the 64-bit `clock_gettime` symbols are
// always available.
- #[cfg(any(target_pointer_width = "64"))]
+ #[cfg(target_pointer_width = "64")]
let ok = true;
// On some 32-bit platforms, the 64-bit `clock_gettime` symbols are not