summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustix/src/backend
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend')
-rw-r--r--vendor/rustix/src/backend/libc/c.rs9
-rw-r--r--vendor/rustix/src/backend/libc/fs/dir.rs136
-rw-r--r--vendor/rustix/src/backend/libc/fs/inotify.rs121
-rw-r--r--vendor/rustix/src/backend/libc/fs/makedev.rs38
-rw-r--r--vendor/rustix/src/backend/libc/fs/mod.rs16
-rw-r--r--vendor/rustix/src/backend/libc/fs/syscalls.rs342
-rw-r--r--vendor/rustix/src/backend/libc/fs/types.rs326
-rw-r--r--vendor/rustix/src/backend/libc/io/epoll.rs531
-rw-r--r--vendor/rustix/src/backend/libc/io/errno.rs527
-rw-r--r--vendor/rustix/src/backend/libc/io/poll_fd.rs4
-rw-r--r--vendor/rustix/src/backend/libc/io/syscalls.rs226
-rw-r--r--vendor/rustix/src/backend/libc/io/types.rs39
-rw-r--r--vendor/rustix/src/backend/libc/io_lifetimes.rs19
-rw-r--r--vendor/rustix/src/backend/libc/io_uring/syscalls.rs6
-rw-r--r--vendor/rustix/src/backend/libc/mm/syscalls.rs6
-rw-r--r--vendor/rustix/src/backend/libc/mm/types.rs114
-rw-r--r--vendor/rustix/src/backend/libc/mod.rs5
-rw-r--r--vendor/rustix/src/backend/libc/net/addr.rs136
-rw-r--r--vendor/rustix/src/backend/libc/net/ext.rs23
-rw-r--r--vendor/rustix/src/backend/libc/net/read_sockaddr.rs57
-rw-r--r--vendor/rustix/src/backend/libc/net/send_recv.rs34
-rw-r--r--vendor/rustix/src/backend/libc/net/syscalls.rs95
-rw-r--r--vendor/rustix/src/backend/libc/net/types.rs349
-rw-r--r--vendor/rustix/src/backend/libc/net/write_sockaddr.rs30
-rw-r--r--vendor/rustix/src/backend/libc/offset.rs262
-rw-r--r--vendor/rustix/src/backend/libc/process/cpu_set.rs2
-rw-r--r--vendor/rustix/src/backend/libc/process/syscalls.rs125
-rw-r--r--vendor/rustix/src/backend/libc/process/types.rs155
-rw-r--r--vendor/rustix/src/backend/libc/process/wait.rs3
-rw-r--r--vendor/rustix/src/backend/libc/rand/syscalls.rs4
-rw-r--r--vendor/rustix/src/backend/libc/rand/types.rs6
-rw-r--r--vendor/rustix/src/backend/libc/termios/syscalls.rs48
-rw-r--r--vendor/rustix/src/backend/libc/termios/types.rs606
-rw-r--r--vendor/rustix/src/backend/libc/thread/syscalls.rs82
-rw-r--r--vendor/rustix/src/backend/libc/time/syscalls.rs58
-rw-r--r--vendor/rustix/src/backend/libc/time/types.rs32
-rw-r--r--vendor/rustix/src/backend/libc/weak.rs2
-rw-r--r--vendor/rustix/src/backend/libc/winsock_c.rs1
-rw-r--r--vendor/rustix/src/backend/linux_raw/c.rs32
-rw-r--r--vendor/rustix/src/backend/linux_raw/conv.rs73
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/inotify.rs108
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/mod.rs1
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/syscalls.rs170
-rw-r--r--vendor/rustix/src/backend/linux_raw/fs/types.rs138
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/epoll.rs519
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/errno.rs19
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/syscalls.rs7
-rw-r--r--vendor/rustix/src/backend/linux_raw/io/types.rs11
-rw-r--r--vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/mod.rs5
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/addr.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/net/syscalls.rs10
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/auxv.rs6
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs39
-rw-r--r--vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs14
-rw-r--r--vendor/rustix/src/backend/linux_raw/process/cpu_set.rs2
-rw-r--r--vendor/rustix/src/backend/linux_raw/process/syscalls.rs111
-rw-r--r--vendor/rustix/src/backend/linux_raw/process/wait.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/runtime/tls.rs8
-rw-r--r--vendor/rustix/src/backend/linux_raw/termios/syscalls.rs50
-rw-r--r--vendor/rustix/src/backend/linux_raw/termios/types.rs37
-rw-r--r--vendor/rustix/src/backend/linux_raw/thread/syscalls.rs62
-rw-r--r--vendor/rustix/src/backend/linux_raw/time/syscalls.rs41
-rw-r--r--vendor/rustix/src/backend/linux_raw/vdso.rs4
-rw-r--r--vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs14
-rw-r--r--vendor/rustix/src/backend/linux_raw/weak.rs228
66 files changed, 3120 insertions, 3178 deletions
diff --git a/vendor/rustix/src/backend/libc/c.rs b/vendor/rustix/src/backend/libc/c.rs
new file mode 100644
index 000000000..35d24d893
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/c.rs
@@ -0,0 +1,9 @@
+pub(crate) use libc::*;
+
+/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
+#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
+pub(crate) const PROC_SUPER_MAGIC: u32 = 0x0000_9fa0;
+
+/// `NFS_SUPER_MAGIC`—The magic number for the NFS filesystem.
+#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
+pub(crate) const NFS_SUPER_MAGIC: u32 = 0x0000_6969;
diff --git a/vendor/rustix/src/backend/libc/fs/dir.rs b/vendor/rustix/src/backend/libc/fs/dir.rs
index 6b69c3600..d1c901323 100644
--- a/vendor/rustix/src/backend/libc/fs/dir.rs
+++ b/vendor/rustix/src/backend/libc/fs/dir.rs
@@ -1,6 +1,6 @@
use super::super::c;
use super::super::conv::owned_fd;
-#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+#[cfg(not(any(solarish, target_os = "haiku")))]
use super::types::FileType;
use crate::fd::{AsFd, BorrowedFd};
use crate::ffi::CStr;
@@ -8,48 +8,25 @@ use crate::ffi::CStr;
use crate::ffi::CString;
use crate::fs::{fcntl_getfl, fstat, openat, Mode, OFlags, Stat};
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::{fstatfs, StatFs};
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
use crate::fs::{fstatvfs, StatVfs};
use crate::io;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
use crate::process::fchdir;
#[cfg(target_os = "wasi")]
use alloc::borrow::ToOwned;
-#[cfg(not(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
- target_os = "openbsd",
-)))]
+#[cfg(not(any(linux_like, target_os = "openbsd")))]
use c::dirent as libc_dirent;
-#[cfg(not(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
-)))]
+#[cfg(not(linux_like))]
use c::readdir as libc_readdir;
-#[cfg(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
-))]
+#[cfg(linux_like)]
use c::{dirent64 as libc_dirent, readdir64 as libc_readdir};
use core::fmt;
use core::mem::zeroed;
@@ -139,11 +116,10 @@ impl Dir {
/// `fstatfs(self)`
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
@@ -152,13 +128,7 @@ impl Dir {
}
/// `fstatvfs(self)`
- #[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
pub fn statvfs(&self) -> io::Result<StatVfs> {
fstatvfs(unsafe { BorrowedFd::borrow_raw(c::dirfd(self.0.as_ptr())) })
@@ -176,21 +146,14 @@ impl Dir {
// struct, as the name is NUL-terminated and memory may not be allocated for
// the full extent of the struct. Copy the fields one at a time.
unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
- #[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "solaris"
- )))]
+ #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
let d_type = input.d_type;
#[cfg(not(any(
+ apple,
+ freebsdlike,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "wasi",
)))]
@@ -199,36 +162,19 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
#[cfg(target_os = "aix")]
let d_offset = input.d_offset;
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(freebsdlike, netbsdlike)))]
let d_ino = input.d_ino;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd"
- ))]
+ #[cfg(any(freebsdlike, netbsdlike))]
let d_fileno = input.d_fileno;
#[cfg(not(any(target_os = "dragonfly", target_os = "wasi")))]
let d_reclen = input.d_reclen;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "ios",
- target_os = "macos",
- ))]
+ #[cfg(any(bsd, target_os = "aix"))]
let d_namlen = input.d_namlen;
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(apple)]
let d_seekoff = input.d_seekoff;
#[cfg(target_os = "haiku")]
@@ -242,43 +188,30 @@ 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(any(target_os = "freebsd", target_os = "dragonfly")))]
+ #[cfg(not(freebsdlike))]
let mut dirent = libc_dirent {
- #[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "solaris"
- )))]
+ #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
d_type,
#[cfg(not(any(
+ apple,
target_os = "aix",
target_os = "freebsd", // Until FreeBSD 12
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "wasi",
)))]
d_off,
#[cfg(target_os = "aix")]
d_offset,
- #[cfg(not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
+ #[cfg(not(any(netbsdlike, target_os = "freebsd")))]
d_ino,
- #[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
+ #[cfg(any(netbsdlike, target_os = "freebsd"))]
d_fileno,
#[cfg(not(target_os = "wasi"))]
d_reclen,
- #[cfg(any(
- target_os = "aix",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(apple, netbsdlike, target_os = "aix", target_os = "freebsd"))]
d_namlen,
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(apple)]
d_seekoff,
// The `d_name` field is NUL-terminated, and we need to be careful not
// to read bytes past the NUL, even though they're within the nominal
@@ -304,11 +237,11 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
pub d_pino: i64,
pub d_reclen: ::c_ushort,
pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
- // */
+ */
// 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"))]
+ #[cfg(freebsdlike)]
let mut dirent = {
let mut dirent: libc_dirent = zeroed();
dirent.d_fileno = d_fileno;
@@ -386,36 +319,21 @@ impl DirEntry {
}
/// Returns the type of this directory entry.
- #[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "solaris"
- )))]
+ #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
#[inline]
pub fn file_type(&self) -> FileType {
FileType::from_dirent_d_type(self.dirent.d_type)
}
/// Return the inode number of this directory entry.
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(freebsdlike, netbsdlike)))]
#[inline]
pub fn ino(&self) -> u64 {
self.dirent.d_ino as u64
}
/// Return the inode number of this directory entry.
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(freebsdlike, netbsdlike))]
#[inline]
pub fn ino(&self) -> u64 {
#[allow(clippy::useless_conversion)]
diff --git a/vendor/rustix/src/backend/libc/fs/inotify.rs b/vendor/rustix/src/backend/libc/fs/inotify.rs
new file mode 100644
index 000000000..8a42e0583
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/fs/inotify.rs
@@ -0,0 +1,121 @@
+//! inotify support for working with inotifies
+
+use super::super::c;
+use super::super::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_owned_fd};
+use crate::fd::{BorrowedFd, OwnedFd};
+use crate::io;
+use bitflags::bitflags;
+
+bitflags! {
+ /// `IN_*` for use with [`inotify_init`].
+ ///
+ /// [`inotify_init`]: crate::fs::inotify::inotify_init
+ pub struct CreateFlags: c::c_int {
+ /// `IN_CLOEXEC`
+ const CLOEXEC = c::IN_CLOEXEC;
+ /// `IN_NONBLOCK`
+ const NONBLOCK = c::IN_NONBLOCK;
+ }
+}
+
+bitflags! {
+ /// `IN*` for use with [`inotify_add_watch`].
+ ///
+ /// [`inotify_add_watch`]: crate::fs::inotify::inotify_add_watch
+ #[derive(Default)]
+ pub struct WatchFlags: u32 {
+ /// `IN_ACCESS`
+ const ACCESS = c::IN_ACCESS;
+ /// `IN_ATTRIB`
+ const ATTRIB = c::IN_ATTRIB;
+ /// `IN_CLOSE_NOWRITE`
+ const CLOSE_NOWRITE = c::IN_CLOSE_NOWRITE;
+ /// `IN_CLOSE_WRITE`
+ const CLOSE_WRITE = c::IN_CLOSE_WRITE;
+ /// `IN_CREATE `
+ const CREATE = c::IN_CREATE;
+ /// `IN_DELETE`
+ const DELETE = c::IN_DELETE;
+ /// `IN_DELETE_SELF`
+ const DELETE_SELF = c::IN_DELETE_SELF;
+ /// `IN_MODIFY`
+ const MODIFY = c::IN_MODIFY;
+ /// `IN_MOVE_SELF`
+ const MOVE_SELF = c::IN_MOVE_SELF;
+ /// `IN_MOVED_FROM`
+ const MOVED_FROM = c::IN_MOVED_FROM;
+ /// `IN_MOVED_TO`
+ const MOVED_TO = c::IN_MOVED_TO;
+ /// `IN_OPEN`
+ const OPEN = c::IN_OPEN;
+
+ /// `IN_CLOSE`
+ const CLOSE = c::IN_CLOSE;
+ /// `IN_MOVE`
+ const MOVE = c::IN_MOVE;
+ /// `IN_ALL_EVENTS`
+ const ALL_EVENTS = c::IN_ALL_EVENTS;
+
+ /// `IN_DONT_FOLLOW`
+ const DONT_FOLLOW = c::IN_DONT_FOLLOW;
+ /// `IN_EXCL_UNLINK`
+ const EXCL_UNLINK = 1;
+ /// `IN_MASK_ADD`
+ const MASK_ADD = 1;
+ /// `IN_MASK_CREATE`
+ const MASK_CREATE = 1;
+ /// `IN_ONESHOT`
+ const ONESHOT = c::IN_ONESHOT;
+ /// `IN_ONLYDIR`
+ const ONLYDIR = c::IN_ONLYDIR;
+ }
+}
+
+/// `inotify_init1(flags)`—Creates a new inotify object.
+///
+/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
+/// descriptor from being implicitly passed across `exec` boundaries.
+#[doc(alias = "inotify_init1")]
+pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
+ // SAFETY: `inotify_init1` has no safety preconditions.
+ unsafe { ret_owned_fd(c::inotify_init1(flags.bits())) }
+}
+
+/// `inotify_add_watch(self, path, flags)`—Adds a watch to inotify
+///
+/// This registers or updates a watch for the filesystem path `path`
+/// and returns a watch descriptor corresponding to this watch.
+///
+/// Note: Due to the existence of hardlinks, providing two
+/// different paths to this method may result in it returning
+/// the same watch descriptor. An application should keep track of this
+/// externally to avoid logic errors.
+pub fn inotify_add_watch<P: crate::path::Arg>(
+ inot: BorrowedFd<'_>,
+ path: P,
+ flags: WatchFlags,
+) -> io::Result<i32> {
+ let path = path.as_cow_c_str().unwrap();
+ // SAFETY: The fd and path we are passing is guaranteed valid by the type
+ // system.
+ unsafe {
+ ret_c_int(c::inotify_add_watch(
+ borrowed_fd(inot),
+ c_str(&path),
+ flags.bits(),
+ ))
+ }
+}
+
+/// `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.
+#[doc(alias = "inotify_rm_watch")]
+pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
+ // Android's `inotify_rm_watch` takes u32 despite `inotify_add_watch` is i32.
+ #[cfg(target_os = "android")]
+ let wd = wd as u32;
+ // SAFETY: The fd is valid and closing an arbitrary wd is valid.
+ unsafe { ret(c::inotify_rm_watch(borrowed_fd(inot), wd)) }
+}
diff --git a/vendor/rustix/src/backend/libc/fs/makedev.rs b/vendor/rustix/src/backend/libc/fs/makedev.rs
index 08ecd872e..afe942a59 100644
--- a/vendor/rustix/src/backend/libc/fs/makedev.rs
+++ b/vendor/rustix/src/backend/libc/fs/makedev.rs
@@ -2,7 +2,12 @@
use super::super::c;
use crate::fs::Dev;
-#[cfg(not(any(target_os = "android", target_os = "emscripten")))]
+#[cfg(not(any(
+ apple,
+ target_os = "aix",
+ target_os = "android",
+ target_os = "emscripten",
+)))]
#[inline]
pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
c::makedev(maj, min)
@@ -11,7 +16,6 @@ pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
#[cfg(all(target_os = "android", not(target_pointer_width = "32")))]
#[inline]
pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
- // Android's `makedev` oddly has signed argument types.
c::makedev(maj, min)
}
@@ -33,7 +37,27 @@ pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
Dev::from(c::makedev(maj, min))
}
-#[cfg(not(any(target_os = "android", target_os = "emscripten")))]
+#[cfg(apple)]
+#[inline]
+pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
+ // Apple's `makedev` oddly has signed argument types and is `unsafe`.
+ unsafe { c::makedev(maj as i32, min as i32) }
+}
+
+#[cfg(target_os = "aix")]
+#[inline]
+pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
+ // AIX's `makedev` oddly is `unsafe`.
+ unsafe { c::makedev(maj, min) }
+}
+
+#[cfg(not(any(
+ apple,
+ freebsdlike,
+ netbsdlike,
+ target_os = "android",
+ target_os = "emscripten",
+)))]
#[inline]
pub(crate) fn major(dev: Dev) -> u32 {
unsafe { c::major(dev) }
@@ -61,7 +85,13 @@ pub(crate) fn major(dev: Dev) -> u32 {
unsafe { c::major(dev as u32) }
}
-#[cfg(not(any(target_os = "android", target_os = "emscripten")))]
+#[cfg(not(any(
+ apple,
+ freebsdlike,
+ netbsdlike,
+ target_os = "android",
+ target_os = "emscripten",
+)))]
#[inline]
pub(crate) fn minor(dev: Dev) -> u32 {
unsafe { c::minor(dev) }
diff --git a/vendor/rustix/src/backend/libc/fs/mod.rs b/vendor/rustix/src/backend/libc/fs/mod.rs
index d0fc08765..54a48103c 100644
--- a/vendor/rustix/src/backend/libc/fs/mod.rs
+++ b/vendor/rustix/src/backend/libc/fs/mod.rs
@@ -1,18 +1,8 @@
#[cfg(not(target_os = "redox"))]
pub(crate) mod dir;
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "haiku",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub mod inotify;
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub(crate) mod makedev;
#[cfg(not(windows))]
pub(crate) mod syscalls;
diff --git a/vendor/rustix/src/backend/libc/fs/syscalls.rs b/vendor/rustix/src/backend/libc/fs/syscalls.rs
index 1d1891f0f..77b49ee3e 100644
--- a/vendor/rustix/src/backend/libc/fs/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/fs/syscalls.rs
@@ -9,49 +9,36 @@ use super::super::conv::{syscall_ret, syscall_ret_owned_fd, syscall_ret_ssize_t}
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
use super::super::offset::libc_fallocate;
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
use super::super::offset::libc_posix_fadvise;
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
use super::super::offset::libc_posix_fallocate;
use super::super::offset::{libc_fstat, libc_fstatat, libc_ftruncate, libc_lseek, libc_off_t};
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
use super::super::offset::{libc_fstatfs, libc_statfs};
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
use super::super::offset::{libc_fstatvfs, libc_statvfs};
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
@@ -60,33 +47,28 @@ use super::super::offset::{libc_fstatvfs, libc_statvfs};
use super::super::time::types::LibcTimespec;
use crate::fd::{BorrowedFd, OwnedFd};
use crate::ffi::CStr;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
use crate::ffi::CString;
-#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
+#[cfg(not(solarish))]
use crate::fs::Access;
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
use crate::fs::Advice;
#[cfg(not(any(
+ netbsdlike,
+ solarish,
target_os = "aix",
target_os = "dragonfly",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
use crate::fs::FallocateFlags;
-#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
+#[cfg(not(target_os = "wasi"))]
use crate::fs::FlockOperation;
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
use crate::fs::MemfdFlags;
@@ -98,31 +80,19 @@ use crate::fs::MemfdFlags;
))]
use crate::fs::SealFlags;
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
use crate::fs::StatFs;
#[cfg(any(target_os = "android", target_os = "linux"))]
use crate::fs::{cwd, RenameFlags, ResolveFlags, Statx, StatxFlags};
-#[cfg(not(any(
- target_os = "ios",
- target_os = "macos",
- target_os = "redox",
- target_os = "wasi",
-)))]
+#[cfg(not(any(apple, target_os = "redox", target_os = "wasi")))]
use crate::fs::{Dev, FileType};
use crate::fs::{Mode, OFlags, Stat, Timestamps};
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
use crate::fs::{StatVfs, StatVfsMountFlags};
use crate::io::{self, SeekFrom};
#[cfg(not(target_os = "wasi"))]
@@ -133,24 +103,14 @@ use crate::process::{Gid, Uid};
)))]
use crate::utils::as_ptr;
use core::convert::TryInto;
-#[cfg(any(
- target_os = "android",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
-))]
+#[cfg(any(apple, target_os = "android", target_os = "linux"))]
use core::mem::size_of;
use core::mem::MaybeUninit;
#[cfg(any(target_os = "android", target_os = "linux"))]
use core::ptr::null;
-#[cfg(any(
- target_os = "android",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
-))]
+#[cfg(any(apple, target_os = "android", target_os = "linux"))]
use core::ptr::null_mut;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
use {
super::super::conv::nonnegative_ret,
crate::fs::{copyfile_state_t, CloneFlags, CopyfileFlags},
@@ -202,7 +162,7 @@ pub(crate) fn openat(
mode: Mode,
) -> io::Result<OwnedFd> {
// Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
- // Basically old glibc versions don't handle O_TMPFILE correctly.
+ // GLIBC versions before 2.25 don't handle `O_TMPFILE` correctly.
#[cfg(all(unix, target_env = "gnu"))]
if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() {
return openat_via_syscall(dirfd, path, oflags, mode);
@@ -221,11 +181,10 @@ pub(crate) fn openat(
}
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[inline]
@@ -237,13 +196,7 @@ pub(crate) fn statfs(filename: &CStr) -> io::Result<StatFs> {
}
}
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[inline]
pub(crate) fn statvfs(filename: &CStr) -> io::Result<StatVfs> {
unsafe {
@@ -278,6 +231,22 @@ pub(crate) fn mkdirat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Res
}
}
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn getdents_uninit(
+ fd: BorrowedFd<'_>,
+ buf: &mut [MaybeUninit<u8>],
+) -> io::Result<usize> {
+ unsafe {
+ syscall_ret_ssize_t(c::syscall(
+ c::SYS_getdents64,
+ fd,
+ buf.as_mut_ptr().cast::<c::c_char>(),
+ buf.len(),
+ ))
+ }
+ .map(|nread| nread as usize)
+}
+
#[cfg(not(target_os = "redox"))]
pub(crate) fn linkat(
old_dirfd: BorrowedFd<'_>,
@@ -433,12 +402,7 @@ fn statat_old(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<
}
}
-#[cfg(not(any(
- target_os = "emscripten",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(solarish, target_os = "emscripten", target_os = "redox")))]
pub(crate) fn accessat(
dirfd: BorrowedFd<'_>,
path: &CStr,
@@ -499,8 +463,7 @@ pub(crate) fn utimensat(
// Main version: libc is y2038 safe and has `utimensat`. Or, the platform
// is not y2038 safe and there's nothing practical we can do.
#[cfg(not(any(
- target_os = "ios",
- target_os = "macos",
+ apple,
all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
@@ -519,7 +482,7 @@ pub(crate) fn utimensat(
}
// `utimensat` was introduced in macOS 10.13.
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(apple)]
unsafe {
// ABI details
weak! {
@@ -675,13 +638,41 @@ unsafe fn utimensat_old(
target_os = "redox",
target_os = "wasi",
)))]
-pub(crate) fn chmodat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Result<()> {
- unsafe { ret(c::fchmodat(borrowed_fd(dirfd), c_str(path), mode.bits(), 0)) }
+pub(crate) fn chmodat(
+ dirfd: BorrowedFd<'_>,
+ path: &CStr,
+ mode: Mode,
+ flags: AtFlags,
+) -> io::Result<()> {
+ unsafe {
+ ret(c::fchmodat(
+ borrowed_fd(dirfd),
+ c_str(path),
+ mode.bits() as c::mode_t,
+ flags.bits(),
+ ))
+ }
}
#[cfg(any(target_os = "android", target_os = "linux"))]
-pub(crate) fn chmodat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Result<()> {
+pub(crate) fn chmodat(
+ dirfd: BorrowedFd<'_>,
+ path: &CStr,
+ mode: Mode,
+ flags: AtFlags,
+) -> io::Result<()> {
// Linux's `fchmodat` does not have a flags argument.
+ //
+ // Use `c::syscall` rather than `c::fchmodat` because some libc
+ // implementations, such as musl, add extra logic to `fchmod` to emulate
+ // support for `AT_SYMLINK_NOFOLLOW`, which uses `/proc` outside our
+ // control.
+ if flags == AtFlags::SYMLINK_NOFOLLOW {
+ return Err(io::Errno::OPNOTSUPP);
+ }
+ if !flags.is_empty() {
+ return Err(io::Errno::INVAL);
+ }
unsafe {
// Pass `mode` as a `c_uint` even if `mode_t` is narrower, since
// `libc_openat` is declared as a variadic function and narrower
@@ -695,7 +686,7 @@ pub(crate) fn chmodat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Res
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn fclonefileat(
srcfd: BorrowedFd<'_>,
dst_dirfd: BorrowedFd<'_>,
@@ -734,12 +725,7 @@ pub(crate) fn chownat(
}
}
-#[cfg(not(any(
- target_os = "ios",
- target_os = "macos",
- target_os = "redox",
- target_os = "wasi",
-)))]
+#[cfg(not(any(apple, target_os = "redox", target_os = "wasi")))]
pub(crate) fn mknodat(
dirfd: BorrowedFd<'_>,
path: &CStr,
@@ -763,8 +749,8 @@ pub(crate) fn copy_file_range(
off_in: Option<&mut u64>,
fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
- len: u64,
-) -> io::Result<u64> {
+ len: usize,
+) -> io::Result<usize> {
assert_eq!(size_of::<c::loff_t>(), size_of::<u64>());
let mut off_in_val: c::loff_t = 0;
@@ -782,7 +768,6 @@ pub(crate) fn copy_file_range(
} else {
null_mut()
};
- let len: usize = len.try_into().unwrap_or(usize::MAX);
let copied = unsafe {
syscall_ret_ssize_t(c::syscall(
c::SYS_copy_file_range,
@@ -800,19 +785,16 @@ pub(crate) fn copy_file_range(
if let Some(off_out) = off_out {
*off_out = off_out_val as u64;
}
- Ok(copied as u64)
+ Ok(copied as usize)
}
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub(crate) fn fadvise(fd: BorrowedFd<'_>, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
let offset = offset as i64;
@@ -875,6 +857,40 @@ pub(crate) fn fcntl_add_seals(fd: BorrowedFd<'_>, seals: SealFlags) -> io::Resul
unsafe { ret(c::fcntl(borrowed_fd(fd), c::F_ADD_SEALS, seals.bits())) }
}
+#[cfg(not(any(
+ target_os = "emscripten",
+ target_os = "fuchsia",
+ target_os = "redox",
+ target_os = "wasi"
+)))]
+#[inline]
+pub(crate) fn fcntl_lock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
+ use c::{flock, F_RDLCK, F_SETLK, F_SETLKW, F_UNLCK, F_WRLCK, SEEK_SET};
+
+ let (cmd, l_type) = match operation {
+ FlockOperation::LockShared => (F_SETLKW, F_RDLCK),
+ FlockOperation::LockExclusive => (F_SETLKW, F_WRLCK),
+ FlockOperation::Unlock => (F_SETLKW, F_UNLCK),
+ FlockOperation::NonBlockingLockShared => (F_SETLK, F_RDLCK),
+ FlockOperation::NonBlockingLockExclusive => (F_SETLK, F_WRLCK),
+ FlockOperation::NonBlockingUnlock => (F_SETLK, F_UNLCK),
+ };
+
+ unsafe {
+ let mut lock: flock = core::mem::zeroed();
+ lock.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.
+ lock.l_whence = SEEK_SET as _;
+ lock.l_start = 0;
+ lock.l_len = 0;
+
+ ret(c::fcntl(borrowed_fd(fd), cmd, &lock))
+ }
+}
+
pub(crate) fn seek(fd: BorrowedFd<'_>, pos: SeekFrom) -> io::Result<u64> {
let (whence, offset): (c::c_int, libc_off_t) = match pos {
SeekFrom::Start(pos) => {
@@ -884,6 +900,10 @@ pub(crate) fn seek(fd: BorrowedFd<'_>, pos: SeekFrom) -> io::Result<u64> {
}
SeekFrom::End(offset) => (c::SEEK_END, offset),
SeekFrom::Current(offset) => (c::SEEK_CUR, offset),
+ #[cfg(any(freebsdlike, target_os = "linux", target_os = "solaris"))]
+ SeekFrom::Data(offset) => (c::SEEK_DATA, offset),
+ #[cfg(any(freebsdlike, target_os = "linux", target_os = "solaris"))]
+ SeekFrom::Hole(offset) => (c::SEEK_HOLE, offset),
};
let offset = unsafe { ret_off_t(libc_lseek(borrowed_fd(fd), offset, whence))? };
Ok(offset as u64)
@@ -939,6 +959,25 @@ pub(crate) fn flock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result
unsafe { ret(c::flock(borrowed_fd(fd), operation as c::c_int)) }
}
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn syncfs(fd: BorrowedFd<'_>) -> io::Result<()> {
+ unsafe { ret(c::syncfs(borrowed_fd(fd))) }
+}
+
+#[cfg(not(any(solarish, target_os = "redox", target_os = "wasi")))]
+pub(crate) fn sync() {
+ // TODO: Remove this when upstream libc adds `sync`.
+ #[cfg(target_os = "android")]
+ unsafe {
+ syscall_ret(c::syscall(c::SYS_sync)).ok();
+ }
+
+ #[cfg(not(target_os = "android"))]
+ unsafe {
+ c::sync()
+ }
+}
+
pub(crate) fn fstat(fd: BorrowedFd<'_>) -> io::Result<Stat> {
// 32-bit and mips64 Linux: `struct stat64` is not y2038 compatible; use
// `statx`.
@@ -980,11 +1019,10 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result<Stat> {
}
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
@@ -995,13 +1033,7 @@ pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
}
}
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
let mut statvfs = MaybeUninit::<libc_statvfs>::uninit();
unsafe {
@@ -1010,13 +1042,7 @@ pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
}
}
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi"
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
fn libc_statvfs_to_statvfs(from: libc_statvfs) -> StatVfs {
StatVfs {
f_bsize: from.f_bsize as u64,
@@ -1055,8 +1081,7 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
// Main version: libc is y2038 safe and has `futimens`. Or, the platform
// is not y2038 safe and there's nothing practical we can do.
#[cfg(not(any(
- target_os = "ios",
- target_os = "macos",
+ apple,
all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
@@ -1070,7 +1095,7 @@ pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
}
// `futimens` was introduced in macOS 10.13.
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(apple)]
unsafe {
// ABI details.
weak! {
@@ -1135,15 +1160,12 @@ unsafe fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
}
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "aix",
target_os = "dragonfly",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub(crate) fn fallocate(
fd: BorrowedFd<'_>,
@@ -1174,7 +1196,7 @@ pub(crate) fn fallocate(
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn fallocate(
fd: BorrowedFd<'_>,
mode: FallocateFlags,
@@ -1196,6 +1218,8 @@ pub(crate) fn fallocate(
};
unsafe {
if c::fcntl(borrowed_fd(fd), c::F_PREALLOCATE, &store) == -1 {
+ // Unable to allocate contiguous disk space; attempt to allocate
+ // non-contiguously.
store.fst_flags = c::F_ALLOCATEALL;
let _ = ret_c_int(c::fcntl(borrowed_fd(fd), c::F_PREALLOCATE, &store))?;
}
@@ -1208,10 +1232,9 @@ pub(crate) fn fsync(fd: BorrowedFd<'_>) -> io::Result<()> {
}
#[cfg(not(any(
+ apple,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
)))]
pub(crate) fn fdatasync(fd: BorrowedFd<'_>) -> io::Result<()> {
@@ -1469,18 +1492,9 @@ fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
mod sys {
use super::{c, BorrowedFd, Statx};
- #[cfg(all(target_os = "android", target_arch = "arm"))]
- const SYS_statx: c::c_long = 397;
- #[cfg(all(target_os = "android", target_arch = "x86"))]
- const SYS_statx: c::c_long = 383;
- #[cfg(all(target_os = "android", target_arch = "aarch64"))]
- const SYS_statx: c::c_long = 291;
- #[cfg(all(target_os = "android", target_arch = "x86_64"))]
- const SYS_statx: c::c_long = 332;
-
weak_or_syscall! {
pub(super) fn statx(
- pirfd: BorrowedFd<'_>,
+ dirfd_: BorrowedFd<'_>,
path: *const c::c_char,
flags: c::c_int,
mask: c::c_uint,
@@ -1545,7 +1559,7 @@ pub(crate) fn is_statx_available() -> bool {
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) unsafe fn fcopyfile(
from: BorrowedFd<'_>,
to: BorrowedFd<'_>,
@@ -1569,7 +1583,7 @@ pub(crate) unsafe fn fcopyfile(
))
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn copyfile_state_alloc() -> io::Result<copyfile_state_t> {
extern "C" {
fn copyfile_state_alloc() -> copyfile_state_t;
@@ -1583,7 +1597,7 @@ pub(crate) fn copyfile_state_alloc() -> io::Result<copyfile_state_t> {
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) unsafe fn copyfile_state_free(state: copyfile_state_t) -> io::Result<()> {
extern "C" {
fn copyfile_state_free(state: copyfile_state_t) -> c::c_int;
@@ -1592,17 +1606,17 @@ pub(crate) unsafe fn copyfile_state_free(state: copyfile_state_t) -> io::Result<
nonnegative_ret(copyfile_state_free(state))
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
const COPYFILE_STATE_COPIED: u32 = 8;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) unsafe fn copyfile_state_get_copied(state: copyfile_state_t) -> io::Result<u64> {
let mut copied = MaybeUninit::<u64>::uninit();
copyfile_state_get(state, COPYFILE_STATE_COPIED, copied.as_mut_ptr().cast())?;
Ok(copied.assume_init())
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) unsafe fn copyfile_state_get(
state: copyfile_state_t,
flag: u32,
@@ -1615,9 +1629,9 @@ pub(crate) unsafe fn copyfile_state_get(
nonnegative_ret(copyfile_state_get(state, flag, dst))
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
- // The use of PATH_MAX is generally not encouraged, but it
+ // The use of `PATH_MAX` is generally not encouraged, but it
// is inevitable in this case because macOS defines `fcntl` with
// `F_GETPATH` in terms of `MAXPATHLEN`, and there are no
// alternatives. If a better method is invented, it should be used
@@ -1643,7 +1657,7 @@ pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
Ok(CString::new(buf).unwrap())
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn fcntl_rdadvise(fd: BorrowedFd<'_>, offset: u64, len: u64) -> io::Result<()> {
// From the [macOS `fcntl` man page]:
// `F_RDADVISE` - Issue an advisory read async with no copy to user.
@@ -1680,14 +1694,14 @@ pub(crate) fn fcntl_rdadvise(fd: BorrowedFd<'_>, offset: u64, len: u64) -> io::R
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn fcntl_fullfsync(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe { ret(c::fcntl(borrowed_fd(fd), c::F_FULLFSYNC)) }
}
/// Convert `times` from a `futimens`/`utimensat` argument into `setattrlist`
/// arguments.
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
fn times_to_attrlist(times: &Timestamps) -> (c::size_t, [c::timespec; 2], Attrlist) {
// ABI details.
const ATTR_CMN_MODTIME: u32 = 0x0000_0400;
@@ -1755,11 +1769,11 @@ fn times_to_attrlist(times: &Timestamps) -> (c::size_t, [c::timespec; 2], Attrli
}
/// Support type for `Attrlist`.
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
type Attrgroup = u32;
/// Attribute list for use with `setattrlist`.
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
#[repr(C)]
struct Attrlist {
bitmapcount: u16,
@@ -1770,3 +1784,27 @@ struct Attrlist {
fileattr: Attrgroup,
forkattr: Attrgroup,
}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn mount(
+ source: Option<&CStr>,
+ target: &CStr,
+ file_system_type: Option<&CStr>,
+ flags: super::types::MountFlagsArg,
+ data: Option<&CStr>,
+) -> io::Result<()> {
+ unsafe {
+ ret(c::mount(
+ source.map_or_else(null, CStr::as_ptr),
+ target.as_ptr(),
+ file_system_type.map_or_else(null, CStr::as_ptr),
+ flags.0,
+ data.map_or_else(null, CStr::as_ptr).cast(),
+ ))
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn unmount(target: &CStr, flags: super::types::UnmountFlags) -> io::Result<()> {
+ unsafe { ret(c::umount2(target.as_ptr(), flags.bits())) }
+}
diff --git a/vendor/rustix/src/backend/libc/fs/types.rs b/vendor/rustix/src/backend/libc/fs/types.rs
index 8d8ec08bf..f635f2cca 100644
--- a/vendor/rustix/src/backend/libc/fs/types.rs
+++ b/vendor/rustix/src/backend/libc/fs/types.rs
@@ -40,11 +40,16 @@ bitflags! {
/// `AT_EMPTY_PATH`
#[cfg(any(
target_os = "android",
+ target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
))]
const EMPTY_PATH = c::AT_EMPTY_PATH;
+ /// `AT_RESOLVE_BENEATH`
+ #[cfg(target_os = "freebsd")]
+ const RESOLVE_BENEATH = c::AT_RESOLVE_BENEATH;
+
/// `AT_EACCESS`
#[cfg(not(any(target_os = "emscripten", target_os = "android")))]
const EACCESS = c::AT_EACCESS;
@@ -147,6 +152,32 @@ impl Mode {
}
}
+impl From<RawMode> for Mode {
+ /// Support conversions from raw mode values to `Mode`.
+ ///
+ /// ```
+ /// use rustix::fs::{Mode, RawMode};
+ /// assert_eq!(Mode::from(0o700), Mode::RWXU);
+ /// ```
+ #[inline]
+ fn from(st_mode: RawMode) -> Self {
+ Self::from_raw_mode(st_mode)
+ }
+}
+
+impl From<Mode> for RawMode {
+ /// Support conversions from `Mode to raw mode values.
+ ///
+ /// ```
+ /// use rustix::fs::{Mode, RawMode};
+ /// assert_eq!(RawMode::from(Mode::RWXU), 0o700);
+ /// ```
+ #[inline]
+ fn from(mode: Mode) -> Self {
+ mode.as_raw_mode()
+ }
+}
+
bitflags! {
/// `O_*` constants for use with [`openat`].
///
@@ -175,7 +206,7 @@ bitflags! {
const DIRECTORY = c::O_DIRECTORY;
/// `O_DSYNC`
- #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "redox")))]
+ #[cfg(not(any(target_os = "dragonfly", target_os = "redox")))]
const DSYNC = c::O_DSYNC;
/// `O_EXCL`
@@ -183,13 +214,8 @@ bitflags! {
/// `O_FSYNC`
#[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
+ bsd,
all(target_os = "linux", not(target_env = "musl")),
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
))]
const FSYNC = c::O_FSYNC;
@@ -214,11 +240,10 @@ bitflags! {
/// `O_RSYNC`
#[cfg(any(
+ netbsdlike,
target_os = "android",
target_os = "emscripten",
target_os = "linux",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
))]
const RSYNC = c::O_RSYNC;
@@ -234,6 +259,7 @@ bitflags! {
#[cfg(any(
target_os = "android",
target_os = "emscripten",
+ target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "redox",
@@ -259,10 +285,29 @@ bitflags! {
target_os = "linux",
))]
const NOATIME = c::O_NOATIME;
+
+ /// `O_DIRECT`
+ #[cfg(any(
+ target_os = "android",
+ target_os = "emscripten",
+ target_os = "freebsd",
+ target_os = "fuchsia",
+ target_os = "linux",
+ target_os = "netbsd",
+ ))]
+ const DIRECT = c::O_DIRECT;
+
+ /// `O_RESOLVE_BENEATH`
+ #[cfg(target_os = "freebsd")]
+ const RESOLVE_BENEATH = c::O_RESOLVE_BENEATH;
+
+ /// `O_EMPTY_PATH`
+ #[cfg(target_os = "freebsd")]
+ const EMPTY_PATH = c::O_EMPTY_PATH;
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
bitflags! {
/// `CLONE_*` constants for use with [`fclonefileat`].
///
@@ -276,7 +321,7 @@ bitflags! {
}
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
mod copyfile {
pub(super) const ACL: u32 = 1 << 0;
pub(super) const STAT: u32 = 1 << 1;
@@ -287,7 +332,7 @@ mod copyfile {
pub(super) const ALL: u32 = METADATA | DATA;
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
bitflags! {
/// `COPYFILE_*` constants.
pub struct CopyfileFlags: c::c_uint {
@@ -427,12 +472,7 @@ impl FileType {
}
/// Construct a `FileType` from the `d_type` field of a `c::dirent`.
- #[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris"
- )))]
+ #[cfg(not(any(solarish, target_os = "haiku", target_os = "redox")))]
pub(crate) const fn from_dirent_d_type(d_type: u8) -> Self {
match d_type {
c::DT_REG => Self::RegularFile,
@@ -454,15 +494,12 @@ impl FileType {
///
/// [`fadvise`]: crate::fs::fadvise
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[repr(u32)]
@@ -502,40 +539,28 @@ bitflags! {
const HUGETLB = c::MFD_HUGETLB;
/// `MFD_HUGE_64KB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_64KB = c::MFD_HUGE_64KB;
/// `MFD_HUGE_512JB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_512KB = c::MFD_HUGE_512KB;
/// `MFD_HUGE_1MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_1MB = c::MFD_HUGE_1MB;
/// `MFD_HUGE_2MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_2MB = c::MFD_HUGE_2MB;
/// `MFD_HUGE_8MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_8MB = c::MFD_HUGE_8MB;
/// `MFD_HUGE_16MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_16MB = c::MFD_HUGE_16MB;
/// `MFD_HUGE_32MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_32MB = c::MFD_HUGE_32MB;
/// `MFD_HUGE_256MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_256MB = c::MFD_HUGE_256MB;
/// `MFD_HUGE_512MB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_512MB = c::MFD_HUGE_512MB;
/// `MFD_HUGE_1GB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_1GB = c::MFD_HUGE_1GB;
/// `MFD_HUGE_2GB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_2GB = c::MFD_HUGE_2GB;
/// `MFD_HUGE_16GB`
- #[cfg(any(target_os = "android", target_os = "linux"))]
const HUGE_16GB = c::MFD_HUGE_16GB;
}
}
@@ -676,14 +701,7 @@ bitflags! {
}
}
-#[cfg(not(any(
- target_os = "aix",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(netbsdlike, solarish, target_os = "aix", target_os = "redox")))]
bitflags! {
/// `FALLOC_FL_*` constants for use with [`fallocate`].
///
@@ -691,41 +709,26 @@ bitflags! {
pub struct FallocateFlags: i32 {
/// `FALLOC_FL_KEEP_SIZE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
const KEEP_SIZE = c::FALLOC_FL_KEEP_SIZE;
/// `FALLOC_FL_PUNCH_HOLE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
const PUNCH_HOLE = c::FALLOC_FL_PUNCH_HOLE;
/// `FALLOC_FL_NO_HIDE_STALE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "wasi",
@@ -733,56 +736,36 @@ bitflags! {
const NO_HIDE_STALE = c::FALLOC_FL_NO_HIDE_STALE;
/// `FALLOC_FL_COLLAPSE_RANGE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "emscripten",
target_os = "wasi",
)))]
const COLLAPSE_RANGE = c::FALLOC_FL_COLLAPSE_RANGE;
/// `FALLOC_FL_ZERO_RANGE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "emscripten",
target_os = "wasi",
)))]
const ZERO_RANGE = c::FALLOC_FL_ZERO_RANGE;
/// `FALLOC_FL_INSERT_RANGE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "emscripten",
target_os = "wasi",
)))]
const INSERT_RANGE = c::FALLOC_FL_INSERT_RANGE;
/// `FALLOC_FL_UNSHARE_RANGE`
#[cfg(not(any(
+ bsd,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "emscripten",
target_os = "wasi",
)))]
@@ -790,13 +773,7 @@ bitflags! {
}
}
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
bitflags! {
/// `ST_*` constants for use with [`StatVfs`].
pub struct StatVfsMountFlags: u64 {
@@ -836,10 +813,11 @@ bitflags! {
}
}
-/// `LOCK_*` constants for use with [`flock`]
+/// `LOCK_*` constants for use with [`flock`] and [`fcntl_lock`].
///
/// [`flock`]: crate::fs::flock
-#[cfg(not(any(target_os = "solaris", target_os = "wasi")))]
+/// [`fcntl_lock`]: crate::fs::fcntl_lock
+#[cfg(not(target_os = "wasi"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(i32)]
pub enum FlockOperation {
@@ -861,12 +839,7 @@ pub enum FlockOperation {
///
/// [`statat`]: crate::fs::statat
/// [`fstat`]: crate::fs::fstat
-#[cfg(not(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-)))]
+#[cfg(not(linux_like))]
pub type Stat = c::stat;
/// `struct stat` for use with [`statat`] and [`fstat`].
@@ -921,15 +894,11 @@ pub struct Stat {
/// [`statfs`]: crate::fs::statfs
/// [`fstatfs`]: crate::fs::fstatfs
#[cfg(not(any(
- target_os = "android",
- target_os = "emscripten",
+ linux_like,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "linux",
- target_os = "l4re",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[allow(clippy::module_name_repetitions)]
@@ -939,25 +908,14 @@ pub type StatFs = c::statfs;
///
/// [`statfs`]: crate::fs::statfs
/// [`fstatfs`]: crate::fs::fstatfs
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
pub type StatFs = c::statfs64;
/// `struct statvfs` for use with [`statvfs`] and [`fstatvfs`].
///
/// [`statvfs`]: crate::fs::statvfs
/// [`fstatvfs`]: crate::fs::fstatvfs
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[allow(missing_docs)]
pub struct StatVfs {
pub f_bsize: u64,
@@ -1081,36 +1039,112 @@ pub type FsWord = u64;
#[cfg(all(target_os = "linux", target_arch = "s390x"))]
pub type FsWord = u32;
-#[cfg(not(target_os = "redox"))]
-pub use c::{UTIME_NOW, UTIME_OMIT};
-
-/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
-#[cfg(all(
- any(target_os = "android", target_os = "linux"),
- not(target_env = "musl"),
-))]
-pub const PROC_SUPER_MAGIC: FsWord = c::PROC_SUPER_MAGIC as FsWord;
-
-/// `NFS_SUPER_MAGIC`—The magic number for the NFS filesystem.
-#[cfg(all(
- any(target_os = "android", target_os = "linux"),
- not(target_env = "musl"),
-))]
-pub const NFS_SUPER_MAGIC: FsWord = c::NFS_SUPER_MAGIC as FsWord;
-
-/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
-#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
-pub const PROC_SUPER_MAGIC: FsWord = 0x0000_9fa0;
-
-/// `NFS_SUPER_MAGIC`—The magic number for the NFS filesystem.
-#[cfg(all(any(target_os = "android", target_os = "linux"), target_env = "musl"))]
-pub const NFS_SUPER_MAGIC: FsWord = 0x0000_6969;
-
/// `copyfile_state_t`—State for use with [`fcopyfile`].
///
/// [`fcopyfile`]: crate::fs::fcopyfile
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
#[allow(non_camel_case_types)]
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct copyfile_state_t(pub(crate) *mut c::c_void);
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MS_*` constants for use with [`mount`].
+ ///
+ /// [`mount`]: crate::fs::mount
+ pub struct MountFlags: c::c_ulong {
+ /// `MS_BIND`
+ const BIND = c::MS_BIND;
+
+ /// `MS_DIRSYNC`
+ const DIRSYNC = c::MS_DIRSYNC;
+
+ /// `MS_LAZYTIME`
+ const LAZYTIME = c::MS_LAZYTIME;
+
+ /// `MS_MANDLOCK`
+ #[doc(alias = "MANDLOCK")]
+ const PERMIT_MANDATORY_FILE_LOCKING = c::MS_MANDLOCK;
+
+ /// `MS_NOATIME`
+ const NOATIME = c::MS_NOATIME;
+
+ /// `MS_NODEV`
+ const NODEV = c::MS_NODEV;
+
+ /// `MS_NODIRATIME`
+ const NODIRATIME = c::MS_NODIRATIME;
+
+ /// `MS_NOEXEC`
+ const NOEXEC = c::MS_NOEXEC;
+
+ /// `MS_NOSUID`
+ const NOSUID = c::MS_NOSUID;
+
+ /// `MS_RDONLY`
+ const RDONLY = c::MS_RDONLY;
+
+ /// `MS_REC`
+ const REC = c::MS_REC;
+
+ /// `MS_RELATIME`
+ const RELATIME = c::MS_RELATIME;
+
+ /// `MS_SILENT`
+ const SILENT = c::MS_SILENT;
+
+ /// `MS_STRICTATIME`
+ const STRICTATIME = c::MS_STRICTATIME;
+
+ /// `MS_SYNCHRONOUS`
+ const SYNCHRONOUS = c::MS_SYNCHRONOUS;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MS_*` constants for use with [`change_mount`].
+ ///
+ /// [`change_mount`]: crate::fs::mount::change_mount.
+ pub struct MountPropagationFlags: c::c_ulong {
+ /// `MS_SHARED`
+ const SHARED = c::MS_SHARED;
+ /// `MS_PRIVATE`
+ const PRIVATE = c::MS_PRIVATE;
+ /// `MS_SLAVE`
+ const SLAVE = c::MS_SLAVE;
+ /// `MS_UNBINDABLE`
+ const UNBINDABLE = c::MS_UNBINDABLE;
+ /// `MS_REC`
+ const REC = c::MS_REC;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ pub(crate) struct InternalMountFlags: c::c_ulong {
+ const REMOUNT = c::MS_REMOUNT;
+ const MOVE = c::MS_MOVE;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) struct MountFlagsArg(pub(crate) c::c_ulong);
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MNT_*` constants for use with [`unmount`].
+ ///
+ /// [`unmount`]: crate::fs::mount::unmount
+ pub struct UnmountFlags: c::c_int {
+ /// `MNT_FORCE`
+ const FORCE = c::MNT_FORCE;
+ /// `MNT_DETACH`
+ const DETACH = c::MNT_DETACH;
+ /// `MNT_EXPIRE`
+ const EXPIRE = c::MNT_EXPIRE;
+ /// `UMOUNT_NOFOLLOW`
+ const NOFOLLOW = c::UMOUNT_NOFOLLOW;
+ }
+}
diff --git a/vendor/rustix/src/backend/libc/io/epoll.rs b/vendor/rustix/src/backend/libc/io/epoll.rs
index 3205a613f..62a3c742b 100644
--- a/vendor/rustix/src/backend/libc/io/epoll.rs
+++ b/vendor/rustix/src/backend/libc/io/epoll.rs
@@ -6,17 +6,17 @@
//!
//! # Examples
//!
-//! ```rust,no_run
+//! ```no_run
//! # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
//! # #[cfg(feature = "net")]
//! # fn main() -> std::io::Result<()> {
//! use io_lifetimes::AsFd;
-//! use rustix::io::epoll::{self, Epoll};
-//! use rustix::io::{ioctl_fionbio, read, write};
+//! use rustix::io::{epoll, ioctl_fionbio, read, write};
//! use rustix::net::{
//! accept, bind_v4, listen, socket, AddressFamily, Ipv4Addr, Protocol, SocketAddrV4,
//! SocketType,
//! };
+//! use std::collections::HashMap;
//! use std::os::unix::io::AsRawFd;
//!
//! // Create a socket and listen on it.
@@ -26,29 +26,40 @@
//!
//! // Create an epoll object. Using `Owning` here means the epoll object will
//! // take ownership of the file descriptors registered with it.
-//! let epoll = Epoll::new(epoll::CreateFlags::CLOEXEC, epoll::Owning::new())?;
-//!
-//! // Remember the socket raw fd, which we use for comparisons only.
-//! let raw_listen_sock = listen_sock.as_fd().as_raw_fd();
+//! let epoll = epoll::epoll_create(epoll::CreateFlags::CLOEXEC)?;
//!
//! // Register the socket with the epoll object.
-//! epoll.add(listen_sock, epoll::EventFlags::IN)?;
+//! epoll::epoll_add(&epoll, &listen_sock, 1, epoll::EventFlags::IN)?;
+//!
+//! // Keep track of the sockets we've opened.
+//! let mut next_id = 2;
+//! let mut sockets = HashMap::new();
//!
//! // Process events.
//! let mut event_list = epoll::EventVec::with_capacity(4);
//! loop {
-//! epoll.wait(&mut event_list, -1)?;
+//! epoll::epoll_wait(&epoll, &mut event_list, -1)?;
//! for (_event_flags, target) in &event_list {
-//! if target.as_raw_fd() == raw_listen_sock {
+//! if target == 1 {
//! // Accept a new connection, set it to non-blocking, and
//! // register to be notified when it's ready to write to.
-//! let conn_sock = accept(&*target)?;
+//! let conn_sock = accept(&listen_sock)?;
//! ioctl_fionbio(&conn_sock, true)?;
-//! epoll.add(conn_sock, epoll::EventFlags::OUT | epoll::EventFlags::ET)?;
+//! epoll::epoll_add(
+//! &epoll,
+//! &conn_sock,
+//! next_id,
+//! epoll::EventFlags::OUT | epoll::EventFlags::ET,
+//! )?;
+//!
+//! // Keep track of the socket.
+//! sockets.insert(next_id, conn_sock);
+//! next_id += 1;
//! } else {
//! // Write a message to the stream and then unregister it.
-//! write(&*target, b"hello\n")?;
-//! let _ = epoll.del(target)?;
+//! let target = sockets.remove(&target).unwrap();
+//! write(&target, b"hello\n")?;
+//! let _ = epoll::epoll_del(&epoll, &target)?;
//! }
//! }
//! }
@@ -59,17 +70,12 @@
use super::super::c;
use super::super::conv::{ret, ret_owned_fd, ret_u32};
-use crate::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
-#[cfg(not(feature = "rustc-dep-of-std"))]
-use crate::fd::{FromRawFd, IntoRawFd};
+use crate::fd::{AsFd, AsRawFd, OwnedFd};
use crate::io;
use alloc::vec::Vec;
use bitflags::bitflags;
use core::convert::TryInto;
-use core::fmt;
-use core::marker::PhantomData;
-use core::ops::Deref;
-use core::ptr::{null, null_mut};
+use core::ptr::null_mut;
bitflags! {
/// `EPOLL_*` for use with [`Epoll::new`].
@@ -98,6 +104,24 @@ bitflags! {
/// `EPOLLHUP`
const HUP = c::EPOLLHUP as u32;
+ /// `EPOLLRDNORM`
+ const RDNORM = c::EPOLLRDNORM as u32;
+
+ /// `EPOLLRDBAND`
+ const RDBAND = c::EPOLLRDBAND as u32;
+
+ /// `EPOLLWRNORM`
+ const WRNORM = c::EPOLLWRNORM as u32;
+
+ /// `EPOLLWRBAND`
+ const WRBAND = c::EPOLLWRBAND as u32;
+
+ /// `EPOLLMSG`
+ const MSG = c::EPOLLMSG as u32;
+
+ /// `EPOLLRDHUP`
+ const RDHUP = c::EPOLLRDHUP as u32;
+
/// `EPOLLET`
const ET = c::EPOLLET as u32;
@@ -113,360 +137,136 @@ bitflags! {
}
}
-/// A reference to a `T`.
-pub struct Ref<'a, T> {
- t: T,
- _phantom: PhantomData<&'a T>,
-}
-
-impl<'a, T> Ref<'a, T> {
- #[inline]
- fn new(t: T) -> Self {
- Self {
- t,
- _phantom: PhantomData,
- }
- }
-
- #[inline]
- fn consume(self) -> T {
- self.t
- }
-}
-
-impl<'a, T> Deref for Ref<'a, T> {
- type Target = T;
-
- #[inline]
- fn deref(&self) -> &T {
- &self.t
- }
-}
-
-impl<'a, T: fmt::Debug> fmt::Debug for Ref<'a, T> {
- fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
- self.t.fmt(fmt)
- }
-}
-
-/// A trait for data stored within an [`Epoll`] instance.
-pub trait Context {
- /// The type of an element owned by this context.
- type Data;
-
- /// The type of a value used to refer to an element owned by this context.
- type Target: AsFd;
-
- /// Assume ownership of `data`, and returning a `Target`.
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target>;
-
- /// Encode `target` as a `u64`. The only requirement on this value is that
- /// it be decodable by `decode`.
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64;
-
- /// Decode `raw`, which is a value encoded by `encode`, into a `Target`.
- ///
- /// # Safety
- ///
- /// `raw` must be a `u64` value returned from `encode`, from the same
- /// context, and within the context's lifetime.
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target>;
-
- /// Release ownership of the value referred to by `target` and return it.
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data;
-}
-
-/// A type implementing [`Context`] where the `Data` type is `BorrowedFd<'a>`.
-pub struct Borrowing<'a> {
- _phantom: PhantomData<BorrowedFd<'a>>,
-}
-
-impl<'a> Context for Borrowing<'a> {
- type Data = BorrowedFd<'a>;
- type Target = BorrowedFd<'a>;
-
- #[inline]
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target> {
- Ref::new(data)
- }
-
- #[inline]
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64 {
- target.as_raw_fd() as u64
- }
-
- #[inline]
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target> {
- Ref::new(BorrowedFd::<'a>::borrow_raw(raw as RawFd))
- }
-
- #[inline]
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data {
- target.consume()
- }
-}
-
-/// A type implementing [`Context`] where the `Data` type is `T`, a type
-/// implementing `From<OwnedFd>` and `From<T> for OwnedFd`.
+/// `epoll_create1(flags)`—Creates a new `Epoll`.
///
-/// This may be used with [`OwnedFd`], or higher-level types like
-/// [`std::fs::File`] or [`std::net::TcpStream`].
-#[cfg(not(feature = "rustc-dep-of-std"))]
-pub struct Owning<'context, T: Into<OwnedFd> + From<OwnedFd>> {
- _phantom: PhantomData<&'context T>,
+/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
+/// descriptor from being implicitly passed across `exec` boundaries.
+#[inline]
+#[doc(alias = "epoll_create1")]
+pub fn epoll_create(flags: CreateFlags) -> io::Result<OwnedFd> {
+ // SAFETY: We're calling `epoll_create1` via FFI and we know how it
+ // behaves.
+ unsafe { ret_owned_fd(c::epoll_create1(flags.bits())) }
}
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: Into<OwnedFd> + From<OwnedFd>> Owning<'context, T> {
- /// Creates a new empty `Owning`.
- #[allow(clippy::new_without_default)] // This is a specialized type that doesn't need to be generically constructible.
- #[inline]
- pub fn new() -> Self {
- Self {
- _phantom: PhantomData,
- }
- }
-}
-
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> Context for Owning<'context, T> {
- type Data = T;
- type Target = BorrowedFd<'context>;
-
- #[inline]
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target> {
- let fd: OwnedFd = data.into();
- let raw_fd = fd.into_raw_fd();
- // Safety: `epoll` will assign ownership of the file descriptor to the
- // kernel epoll object. We use `Into<OwnedFd>`+`IntoRawFd` to consume
- // the `Data` and extract the raw file descriptor and then "borrow" it
- // with `borrow_raw` knowing that the borrow won't outlive the
- // kernel epoll object.
- unsafe { Ref::new(BorrowedFd::<'context>::borrow_raw(raw_fd)) }
- }
-
- #[inline]
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64 {
- target.as_fd().as_raw_fd() as u64
- }
-
- #[inline]
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target> {
- Ref::new(BorrowedFd::<'context>::borrow_raw(raw as RawFd))
- }
-
- #[inline]
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data {
- // The file descriptor was held by the kernel epoll object and is now
- // being released, so we can create a new `OwnedFd` that assumes
- // ownership.
- let raw_fd = target.consume().as_raw_fd();
- unsafe { T::from(OwnedFd::from_raw_fd(raw_fd).into()) }
- }
-}
-
-/// An "epoll", an interface to an OS object allowing one to repeatedly wait
-/// for events from a set of file descriptors efficiently.
-pub struct Epoll<Context: self::Context> {
- epoll_fd: OwnedFd,
- context: Context,
-}
-
-impl<Context: self::Context> Epoll<Context> {
- /// `epoll_create1(flags)`—Creates a new `Epoll`.
- ///
- /// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
- /// descriptor from being implicitly passed across `exec` boundaries.
- #[inline]
- #[doc(alias = "epoll_create1")]
- pub fn new(flags: CreateFlags, context: Context) -> io::Result<Self> {
- // Safety: We're calling `epoll_create1` via FFI and we know how it
- // behaves.
- unsafe {
- Ok(Self {
- epoll_fd: ret_owned_fd(c::epoll_create1(flags.bits()))?,
- context,
- })
- }
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
- /// `Epoll`.
- ///
- /// This registers interest in any of the events set in `events` occurring
- /// on the file descriptor associated with `data`.
- #[doc(alias = "epoll_ctl")]
- pub fn add(
- &self,
- data: Context::Data,
- event_flags: EventFlags,
- ) -> io::Result<Ref<'_, Context::Target>> {
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- let target = self.context.acquire(data);
- let raw_fd = target.as_fd().as_raw_fd();
- let encoded = self.context.encode(target);
- ret(c::epoll_ctl(
- self.epoll_fd.as_fd().as_raw_fd(),
- c::EPOLL_CTL_ADD,
- raw_fd,
- &mut c::epoll_event {
- events: event_flags.bits(),
- r#u64: encoded,
- },
- ))?;
- Ok(self.context.decode(encoded))
- }
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in
- /// this `Epoll`.
- ///
- /// This sets the events of interest with `target` to `events`.
- #[doc(alias = "epoll_ctl")]
- pub fn mod_(
- &self,
- target: Ref<'_, Context::Target>,
- event_flags: EventFlags,
- ) -> io::Result<()> {
- let raw_fd = target.as_fd().as_raw_fd();
- let encoded = self.context.encode(target);
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- ret(c::epoll_ctl(
- self.epoll_fd.as_fd().as_raw_fd(),
- c::EPOLL_CTL_MOD,
- raw_fd,
- &mut c::epoll_event {
- events: event_flags.bits(),
- r#u64: encoded,
- },
- ))
- }
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in
- /// this `Epoll`.
- ///
- /// This also returns the owning `Data`.
- #[doc(alias = "epoll_ctl")]
- pub fn del(&self, target: Ref<'_, Context::Target>) -> io::Result<Context::Data> {
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- let raw_fd = target.as_fd().as_raw_fd();
- ret(c::epoll_ctl(
- self.epoll_fd.as_fd().as_raw_fd(),
- c::EPOLL_CTL_DEL,
- raw_fd,
- null_mut(),
- ))?;
- }
- Ok(self.context.release(target))
- }
-
- /// `epoll_wait(self, events, timeout)`—Waits for registered events of
- /// interest.
- ///
- /// For each event of interest, an element is written to `events`. On
- /// success, this returns the number of written elements.
- #[doc(alias = "epoll_wait")]
- pub fn wait<'context>(
- &'context self,
- event_list: &mut EventVec<'context, Context>,
- timeout: c::c_int,
- ) -> io::Result<()> {
- // Safety: We're calling `epoll_wait` via FFI and we know how it
- // behaves.
- unsafe {
- event_list.events.set_len(0);
- let nfds = ret_u32(c::epoll_wait(
- self.epoll_fd.as_fd().as_raw_fd(),
- event_list.events.as_mut_ptr().cast::<c::epoll_event>(),
- event_list.events.capacity().try_into().unwrap_or(i32::MAX),
- timeout,
- ))?;
- event_list.events.set_len(nfds as usize);
- event_list.context = &self.context;
- }
-
- Ok(())
- }
-}
-
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> AsRawFd for Epoll<Owning<'context, T>> {
- fn as_raw_fd(&self) -> RawFd {
- self.epoll_fd.as_raw_fd()
- }
-}
-
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> IntoRawFd for Epoll<Owning<'context, T>> {
- fn into_raw_fd(self) -> RawFd {
- self.epoll_fd.into_raw_fd()
- }
-}
-
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> FromRawFd for Epoll<Owning<'context, T>> {
- unsafe fn from_raw_fd(fd: RawFd) -> Self {
- Self {
- epoll_fd: OwnedFd::from_raw_fd(fd),
- context: Owning::new(),
- }
+/// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
+/// `Epoll`.
+///
+/// Note that if `epoll_del` 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 source is still registered with it. This can lead to
+/// spurious events being returned from `epoll_wait`. If a file descriptor
+/// is an `Arc<dyn SystemResource>`, then `epoll` can be thought to maintain
+/// a `Weak<dyn SystemResource>` to the file descriptor.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_add(
+ epoll: impl AsFd,
+ source: impl AsFd,
+ data: u64,
+ event_flags: EventFlags,
+) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ let raw_fd = source.as_fd().as_raw_fd();
+ ret(c::epoll_ctl(
+ epoll.as_fd().as_raw_fd(),
+ c::EPOLL_CTL_ADD,
+ raw_fd,
+ &mut c::epoll_event {
+ events: event_flags.bits(),
+ r#u64: data,
+ },
+ ))
}
}
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> AsFd for Epoll<Owning<'context, T>> {
- fn as_fd(&self) -> BorrowedFd<'_> {
- self.epoll_fd.as_fd()
+/// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in
+/// this `Epoll`.
+///
+/// This sets the events of interest with `target` to `events`.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_mod(
+ epoll: impl AsFd,
+ source: impl AsFd,
+ data: u64,
+ event_flags: EventFlags,
+) -> io::Result<()> {
+ let raw_fd = source.as_fd().as_raw_fd();
+
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ ret(c::epoll_ctl(
+ epoll.as_fd().as_raw_fd(),
+ c::EPOLL_CTL_MOD,
+ raw_fd,
+ &mut c::epoll_event {
+ events: event_flags.bits(),
+ r#u64: data,
+ },
+ ))
}
}
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> From<Epoll<Owning<'context, T>>>
- for OwnedFd
-{
- fn from(epoll: Epoll<Owning<'context, T>>) -> Self {
- epoll.epoll_fd
+/// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in
+/// this `Epoll`.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_del(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ let raw_fd = source.as_fd().as_raw_fd();
+ ret(c::epoll_ctl(
+ epoll.as_fd().as_raw_fd(),
+ c::EPOLL_CTL_DEL,
+ raw_fd,
+ null_mut(),
+ ))
}
}
-#[cfg(not(feature = "rustc-dep-of-std"))]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> From<OwnedFd>
- for Epoll<Owning<'context, T>>
-{
- fn from(fd: OwnedFd) -> Self {
- Self {
- epoll_fd: fd,
- context: Owning::new(),
- }
- }
+/// `epoll_wait(self, events, timeout)`—Waits for registered events of
+/// interest.
+///
+/// For each event of interest, an element is written to `events`. On
+/// success, this returns the number of written elements.
+pub fn epoll_wait(
+ epoll: impl AsFd,
+ event_list: &mut EventVec,
+ timeout: c::c_int,
+) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_wait` via FFI and we know how it
+ // behaves.
+ unsafe {
+ event_list.events.set_len(0);
+ let nfds = ret_u32(c::epoll_wait(
+ epoll.as_fd().as_raw_fd(),
+ event_list.events.as_mut_ptr().cast::<c::epoll_event>(),
+ event_list.events.capacity().try_into().unwrap_or(i32::MAX),
+ timeout,
+ ))?;
+ event_list.events.set_len(nfds as usize);
+ }
+
+ Ok(())
}
/// An iterator over the `Event`s in an `EventVec`.
-pub struct Iter<'context, Context: self::Context> {
- iter: core::slice::Iter<'context, Event>,
- context: *const Context,
- _phantom: PhantomData<&'context Context>,
+pub struct Iter<'a> {
+ iter: core::slice::Iter<'a, Event>,
}
-impl<'context, Context: self::Context> Iterator for Iter<'context, Context> {
- type Item = (EventFlags, Ref<'context, Context::Target>);
+impl<'a> Iterator for Iter<'a> {
+ type Item = (EventFlags, u64);
fn next(&mut self) -> Option<Self::Item> {
- // Safety: `self.context` is guaranteed to be valid because we hold
+ // SAFETY: `self.context` is guaranteed to be valid because we hold
// `'context` for it. And we know this event is associated with this
// context because `wait` sets both.
- self.iter.next().map(|event| {
- (event.event_flags, unsafe {
- (*self.context).decode(event.encoded)
- })
- })
+ self.iter
+ .next()
+ .map(|event| (event.event_flags, event.data))
}
}
@@ -485,27 +285,22 @@ impl<'context, Context: self::Context> Iterator for Iter<'context, Context> {
)]
struct Event {
// Match the layout of `c::epoll_event`. We just use a `u64` instead of
- // the full union; `Context` implementations will simply need to deal with
- // casting the value into and out of the `u64` themselves.
+ // the full union.
event_flags: EventFlags,
- encoded: u64,
+ data: u64,
}
/// A vector of `Event`s, plus context for interpreting them.
-pub struct EventVec<'context, Context: self::Context> {
+pub struct EventVec {
events: Vec<Event>,
- context: *const Context,
- _phantom: PhantomData<&'context Context>,
}
-impl<'context, Context: self::Context> EventVec<'context, Context> {
+impl EventVec {
/// Constructs an `EventVec` with memory for `capacity` `Event`s.
#[inline]
pub fn with_capacity(capacity: usize) -> Self {
Self {
events: Vec::with_capacity(capacity),
- context: null(),
- _phantom: PhantomData,
}
}
@@ -541,11 +336,9 @@ impl<'context, Context: self::Context> EventVec<'context, Context> {
/// Returns an iterator over the `Event`s in this `EventVec`.
#[inline]
- pub fn iter(&self) -> Iter<'_, Context> {
+ pub fn iter(&self) -> Iter<'_> {
Iter {
iter: self.events.iter(),
- context: self.context,
- _phantom: PhantomData,
}
}
@@ -562,9 +355,9 @@ impl<'context, Context: self::Context> EventVec<'context, Context> {
}
}
-impl<'context, Context: self::Context> IntoIterator for &'context EventVec<'context, Context> {
- type IntoIter = Iter<'context, Context>;
- type Item = (EventFlags, Ref<'context, Context::Target>);
+impl<'a> IntoIterator for &'a EventVec {
+ type IntoIter = Iter<'a>;
+ type Item = (EventFlags, u64);
#[inline]
fn into_iter(self) -> Self::IntoIter {
diff --git a/vendor/rustix/src/backend/libc/io/errno.rs b/vendor/rustix/src/backend/libc/io/errno.rs
index 25323771c..9e808c0b4 100644
--- a/vendor/rustix/src/backend/libc/io/errno.rs
+++ b/vendor/rustix/src/backend/libc/io/errno.rs
@@ -25,15 +25,10 @@ impl Errno {
pub const ADDRNOTAVAIL: Self = Self(c::EADDRNOTAVAIL);
/// `EADV`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const ADV: Self = Self(c::EADV);
@@ -44,26 +39,14 @@ impl Errno {
/// `EALREADY`
pub const ALREADY: Self = Self(c::EALREADY);
/// `EAUTH`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const AUTH: Self = Self(c::EAUTH);
/// `EBADE`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BADE: Self = Self(c::EBADE);
@@ -71,15 +54,10 @@ impl Errno {
pub const BADF: Self = Self(c::EBADF);
/// `EBADFD`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BADFD: Self = Self(c::EBADFD);
@@ -88,67 +66,40 @@ impl Errno {
pub const BADMSG: Self = Self(c::EBADMSG);
/// `EBADR`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BADR: Self = Self(c::EBADR);
/// `EBADRPC`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const BADRPC: Self = Self(c::EBADRPC);
/// `EBADRQC`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BADRQC: Self = Self(c::EBADRQC);
/// `EBADSLT`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BADSLT: Self = Self(c::EBADSLT);
/// `EBFONT`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const BFONT: Self = Self(c::EBFONT);
@@ -164,29 +115,14 @@ impl Errno {
#[cfg(not(windows))]
pub const CHILD: Self = Self(c::ECHILD);
/// `ECHRNG`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const CHRNG: Self = Self(c::ECHRNG);
/// `ECOMM`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const COMM: Self = Self(c::ECOMM);
@@ -201,16 +137,11 @@ impl Errno {
pub const DEADLK: Self = Self(c::EDEADLK);
/// `EDEADLOCK`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const DEADLOCK: Self = Self(c::EDEADLOCK);
@@ -223,21 +154,15 @@ impl Errno {
#[cfg(not(windows))]
pub const DOM: Self = Self(c::EDOM);
/// `EDOOFUS`
- #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
+ #[cfg(freebsdlike)]
pub const DOOFUS: Self = Self(c::EDOOFUS);
/// `EDOTDOT`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const DOTDOT: Self = Self(c::EDOTDOT);
@@ -252,15 +177,7 @@ impl Errno {
#[cfg(not(windows))]
pub const FBIG: Self = Self(c::EFBIG);
/// `EFTYPE`
- #[cfg(any(
- target_env = "newlib",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_env = "newlib"))]
pub const FTYPE: Self = Self(c::EFTYPE);
/// `EHOSTDOWN`
#[cfg(not(target_os = "wasi"))]
@@ -269,19 +186,13 @@ impl Errno {
pub const HOSTUNREACH: Self = Self(c::EHOSTUNREACH);
/// `EHWPOISON`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const HWPOISON: Self = Self(c::EHWPOISON);
@@ -318,218 +229,113 @@ impl Errno {
pub const ISDIR: Self = Self(c::EISDIR);
/// `EISNAM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const ISNAM: Self = Self(c::EISNAM);
/// `EKEYEXPIRED`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const KEYEXPIRED: Self = Self(c::EKEYEXPIRED);
/// `EKEYREJECTED`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const KEYREJECTED: Self = Self(c::EKEYREJECTED);
/// `EKEYREVOKED`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const KEYREVOKED: Self = Self(c::EKEYREVOKED);
/// `EL2HLT`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const L2HLT: Self = Self(c::EL2HLT);
/// `EL2NSYNC`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const L2NSYNC: Self = Self(c::EL2NSYNC);
/// `EL3HLT`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const L3HLT: Self = Self(c::EL3HLT);
/// `EL3RST`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const L3RST: Self = Self(c::EL3RST);
/// `ELIBACC`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const LIBACC: Self = Self(c::ELIBACC);
/// `ELIBBAD`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const LIBBAD: Self = Self(c::ELIBBAD);
/// `ELIBEXEC`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const LIBEXEC: Self = Self(c::ELIBEXEC);
/// `ELIBMAX`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const LIBMAX: Self = Self(c::ELIBMAX);
/// `ELIBSCN`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const LIBSCN: Self = Self(c::ELIBSCN);
/// `ELNRNG`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const LNRNG: Self = Self(c::ELNRNG);
/// `ELOOP`
pub const LOOP: Self = Self(c::ELOOP);
/// `EMEDIUMTYPE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const MEDIUMTYPE: Self = Self(c::EMEDIUMTYPE);
@@ -547,29 +353,16 @@ impl Errno {
pub const NAMETOOLONG: Self = Self(c::ENAMETOOLONG);
/// `ENAVAIL`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const NAVAIL: Self = Self(c::ENAVAIL);
/// `ENEEDAUTH`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const NEEDAUTH: Self = Self(c::ENEEDAUTH);
/// `ENETDOWN`
pub const NETDOWN: Self = Self(c::ENETDOWN);
@@ -582,49 +375,25 @@ impl Errno {
pub const NFILE: Self = Self(c::ENFILE);
/// `ENOANO`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const NOANO: Self = Self(c::ENOANO);
/// `ENOATTR`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
pub const NOATTR: Self = Self(c::ENOATTR);
/// `ENOBUFS`
pub const NOBUFS: Self = Self(c::ENOBUFS);
/// `ENOCSI`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const NOCSI: Self = Self(c::ENOCSI);
/// `ENODATA`
#[cfg(not(any(
+ freebsdlike,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
@@ -641,17 +410,11 @@ impl Errno {
pub const NOEXEC: Self = Self(c::ENOEXEC);
/// `ENOKEY`
#[cfg(not(any(
+ solarish,
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const NOKEY: Self = Self(c::ENOKEY);
@@ -663,17 +426,11 @@ impl Errno {
pub const NOLINK: Self = Self(c::ENOLINK);
/// `ENOMEDIUM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const NOMEDIUM: Self = Self(c::ENOMEDIUM);
@@ -688,29 +445,19 @@ impl Errno {
pub const NOMSG: Self = Self(c::ENOMSG);
/// `ENONET`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const NONET: Self = Self(c::ENONET);
/// `ENOPKG`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const NOPKG: Self = Self(c::ENOPKG);
@@ -721,9 +468,8 @@ impl Errno {
pub const NOSPC: Self = Self(c::ENOSPC);
/// `ENOSR`
#[cfg(not(any(
+ freebsdlike,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
@@ -731,9 +477,8 @@ impl Errno {
pub const NOSR: Self = Self(c::ENOSR);
/// `ENOSTR`
#[cfg(not(any(
+ freebsdlike,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
target_os = "openbsd",
target_os = "wasi",
@@ -757,27 +502,16 @@ impl Errno {
pub const NOTEMPTY: Self = Self(c::ENOTEMPTY);
/// `ENOTNAM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const NOTNAM: Self = Self(c::ENOTNAM);
/// `ENOTRECOVERABLE`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "haiku",
- target_os = "netbsd"
- )))]
+ #[cfg(not(any(freebsdlike, netbsdlike, windows, target_os = "haiku")))]
pub const NOTRECOVERABLE: Self = Self(c::ENOTRECOVERABLE);
/// `ENOTSOCK`
pub const NOTSOCK: Self = Self(c::ENOTSOCK);
@@ -789,15 +523,10 @@ impl Errno {
pub const NOTTY: Self = Self(c::ENOTTY);
/// `ENOTUNIQ`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const NOTUNIQ: Self = Self(c::ENOTUNIQ);
@@ -810,12 +539,7 @@ impl Errno {
#[cfg(not(windows))]
pub const OVERFLOW: Self = Self(c::EOVERFLOW);
/// `EOWNERDEAD`
- #[cfg(not(any(
- windows,
- target_os = "haiku",
- target_os = "dragonfly",
- target_os = "netbsd"
- )))]
+ #[cfg(not(any(freebsdlike, netbsdlike, windows, target_os = "haiku")))]
pub const OWNERDEAD: Self = Self(c::EOWNERDEAD);
/// `EPERM`
#[cfg(not(windows))]
@@ -827,44 +551,16 @@ impl Errno {
#[cfg(not(windows))]
pub const PIPE: Self = Self(c::EPIPE);
/// `EPROCLIM`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const PROCLIM: Self = Self(c::EPROCLIM);
/// `EPROCUNAVAIL`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const PROCUNAVAIL: Self = Self(c::EPROCUNAVAIL);
/// `EPROGMISMATCH`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const PROGMISMATCH: Self = Self(c::EPROGMISMATCH);
/// `EPROGUNAVAIL`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const PROGUNAVAIL: Self = Self(c::EPROGUNAVAIL);
/// `EPROTO`
#[cfg(not(windows))]
@@ -884,15 +580,10 @@ impl Errno {
pub const REFUSED: Self = Self(c::EREFUSED);
/// `EREMCHG`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const REMCHG: Self = Self(c::EREMCHG);
@@ -901,48 +592,26 @@ impl Errno {
pub const REMOTE: Self = Self(c::EREMOTE);
/// `EREMOTEIO`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const REMOTEIO: Self = Self(c::EREMOTEIO);
/// `ERESTART`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const RESTART: Self = Self(c::ERESTART);
/// `ERFKILL`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const RFKILL: Self = Self(c::ERFKILL);
@@ -950,14 +619,7 @@ impl Errno {
#[cfg(not(windows))]
pub const ROFS: Self = Self(c::EROFS);
/// `ERPCMISMATCH`
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
pub const RPCMISMATCH: Self = Self(c::ERPCMISMATCH);
/// `ESHUTDOWN`
#[cfg(not(target_os = "wasi"))]
@@ -973,15 +635,10 @@ impl Errno {
pub const SRCH: Self = Self(c::ESRCH);
/// `ESRMNT`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const SRMNT: Self = Self(c::ESRMNT);
@@ -989,26 +646,15 @@ impl Errno {
pub const STALE: Self = Self(c::ESTALE);
/// `ESTRPIPE`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const STRPIPE: Self = Self(c::ESTRPIPE);
/// `ETIME`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(freebsdlike, windows, target_os = "openbsd", target_os = "wasi")))]
pub const TIME: Self = Self(c::ETIME);
/// `ETIMEDOUT`
pub const TIMEDOUT: Self = Self(c::ETIMEDOUT);
@@ -1024,32 +670,16 @@ impl Errno {
pub const TXTBSY: Self = Self(c::ETXTBSY);
/// `EUCLEAN`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
target_os = "wasi",
)))]
pub const UCLEAN: Self = Self(c::EUCLEAN);
/// `EUNATCH`
- #[cfg(not(any(
- windows,
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "wasi",
- )))]
+ #[cfg(not(any(bsd, windows, target_os = "haiku", target_os = "wasi")))]
pub const UNATCH: Self = Self(c::EUNATCH);
/// `EUSERS`
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
@@ -1061,15 +691,10 @@ impl Errno {
pub const XDEV: Self = Self(c::EXDEV);
/// `EXFULL`
#[cfg(not(any(
+ bsd,
windows,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "wasi",
)))]
pub const XFULL: Self = Self(c::EXFULL);
diff --git a/vendor/rustix/src/backend/libc/io/poll_fd.rs b/vendor/rustix/src/backend/libc/io/poll_fd.rs
index c516a9309..a0568c60a 100644
--- a/vendor/rustix/src/backend/libc/io/poll_fd.rs
+++ b/vendor/rustix/src/backend/libc/io/poll_fd.rs
@@ -119,7 +119,7 @@ impl<'fd> PollFd<'fd> {
impl<'fd> AsFd for PollFd<'fd> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
- // Safety: Our constructors and `set_fd` require `pollfd.fd` to be
+ // SAFETY: Our constructors and `set_fd` require `pollfd.fd` to be
// valid for the `fd lifetime.
unsafe { BorrowedFd::borrow_raw(self.pollfd.fd) }
}
@@ -129,7 +129,7 @@ impl<'fd> AsFd for PollFd<'fd> {
impl<'fd> io_lifetimes::AsSocket for PollFd<'fd> {
#[inline]
fn as_socket(&self) -> BorrowedFd<'_> {
- // Safety: Our constructors and `set_fd` require `pollfd.fd` to be
+ // SAFETY: Our constructors and `set_fd` require `pollfd.fd` to be
// valid for the `fd lifetime.
unsafe { BorrowedFd::borrow_raw(self.pollfd.fd as RawFd) }
}
diff --git a/vendor/rustix/src/backend/libc/io/syscalls.rs b/vendor/rustix/src/backend/libc/io/syscalls.rs
index 3774e700a..03f9294d9 100644
--- a/vendor/rustix/src/backend/libc/io/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/io/syscalls.rs
@@ -12,15 +12,13 @@ use super::super::offset::{libc_preadv, libc_pwritev};
#[cfg(all(target_os = "linux", target_env = "gnu"))]
use super::super::offset::{libc_preadv2, libc_pwritev2};
use crate::fd::{AsFd, BorrowedFd, OwnedFd, RawFd};
+#[cfg(bsd)]
+use crate::io::kqueue::Event;
+#[cfg(solarish)]
+use crate::io::port::Event;
#[cfg(not(any(target_os = "aix", target_os = "wasi")))]
use crate::io::DupFlags;
-#[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "wasi"
-)))]
+#[cfg(not(any(apple, target_os = "aix", target_os = "haiku", target_os = "wasi")))]
use crate::io::PipeFlags;
use crate::io::{self, FdFlags, IoSlice, IoSliceMut, PollFd};
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -167,7 +165,7 @@ pub(crate) fn preadv2(
}
/// At present, `libc` only has `preadv2` defined for glibc. On other
-/// ABIs, `ReadWriteFlags` has no flags defined, and we use plain `preadv`.
+/// ABIs, use `libc::syscall`.
#[cfg(any(
target_os = "android",
all(target_os = "linux", not(target_env = "gnu")),
@@ -179,8 +177,19 @@ pub(crate) fn preadv2(
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
- assert!(flags.is_empty());
- preadv(fd, bufs, offset)
+ // Silently cast; we'll get `EINVAL` if the value is negative.
+ let offset = offset as i64;
+ let nread = unsafe {
+ ret_ssize_t(libc::syscall(
+ libc::SYS_preadv2,
+ borrowed_fd(fd),
+ bufs.as_ptr().cast::<c::iovec>(),
+ min(bufs.len(), max_iov()) as c::c_int,
+ offset,
+ flags.bits(),
+ ) as c::ssize_t)?
+ };
+ Ok(nread as usize)
}
#[cfg(all(target_os = "linux", target_env = "gnu"))]
@@ -205,7 +214,7 @@ pub(crate) fn pwritev2(
}
/// At present, `libc` only has `pwritev2` defined for glibc. On other
-/// ABIs, `ReadWriteFlags` has no flags defined, and we use plain `pwritev`.
+/// ABIs, use `libc::syscall`.
#[cfg(any(
target_os = "android",
all(target_os = "linux", not(target_env = "gnu")),
@@ -217,12 +226,23 @@ pub(crate) fn pwritev2(
offset: u64,
flags: ReadWriteFlags,
) -> io::Result<usize> {
- assert!(flags.is_empty());
- pwritev(fd, bufs, offset)
+ // Silently cast; we'll get `EINVAL` if the value is negative.
+ let offset = offset as i64;
+ let nwritten = unsafe {
+ ret_ssize_t(libc::syscall(
+ libc::SYS_pwritev2,
+ borrowed_fd(fd),
+ bufs.as_ptr().cast::<c::iovec>(),
+ min(bufs.len(), max_iov()) as c::c_int,
+ offset,
+ flags.bits(),
+ ) as c::ssize_t)?
+ };
+ Ok(nwritten as usize)
}
// These functions are derived from Rust's library/std/src/sys/unix/fd.rs at
-// revision a77da2d454e6caa227a85b16410b95f93495e7e0.
+// revision 326ef470a8b379a180d6dc4bbef08990698a737a.
// The maximum read limit on most POSIX-like systems is `SSIZE_MAX`, with the
// man page quoting that if the count of bytes to read is greater than
@@ -237,33 +257,28 @@ const READ_LIMIT: usize = c::c_int::MAX as usize - 1;
#[cfg(not(target_os = "macos"))]
const READ_LIMIT: usize = c::ssize_t::MAX as usize;
-#[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
-))]
+#[cfg(bsd)]
const fn max_iov() -> usize {
c::IOV_MAX as usize
}
-#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
+#[cfg(any(
+ target_os = "android",
+ target_os = "emscripten",
+ target_os = "linux",
+ target_os = "nto"
+))]
const fn max_iov() -> usize {
c::UIO_MAXIOV as usize
}
#[cfg(not(any(
+ bsd,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
- target_os = "ios",
target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
+ target_os = "nto",
+ target_os = "horizon",
)))]
const fn max_iov() -> usize {
16 // The minimum value required by POSIX.
@@ -321,6 +336,33 @@ pub(crate) fn ioctl_fionbio(fd: BorrowedFd<'_>, value: bool) -> io::Result<()> {
}
}
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn ioctl_ficlone(fd: BorrowedFd<'_>, src_fd: BorrowedFd<'_>) -> io::Result<()> {
+ // TODO: Enable `ioctl_ficlone` for android when upstream is updated.
+ // TODO: Enable `ioctl_ficlone` for more architectures when upstream is
+ // updated.
+ #[cfg(all(
+ target_os = "linux",
+ any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")
+ ))]
+ unsafe {
+ ret(c::ioctl(
+ borrowed_fd(fd),
+ c::FICLONE as _,
+ borrowed_fd(src_fd),
+ ))
+ }
+ #[cfg(not(all(
+ target_os = "linux",
+ any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")
+ )))]
+ {
+ let _ = fd;
+ let _ = src_fd;
+ Err(io::Errno::NOSYS)
+ }
+}
+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(all(feature = "fs", feature = "net"))]
pub(crate) fn is_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> {
@@ -398,12 +440,11 @@ pub(crate) fn dup2(fd: BorrowedFd<'_>, new: &mut OwnedFd) -> io::Result<()> {
}
#[cfg(not(any(
+ apple,
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
target_os = "wasi",
)))]
@@ -418,11 +459,10 @@ pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, flags: DupFlags) -> io
}
#[cfg(any(
+ apple,
target_os = "android",
target_os = "dragonfly",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
))]
pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, _flags: DupFlags) -> io::Result<()> {
@@ -433,7 +473,7 @@ pub(crate) fn dup3(fd: BorrowedFd<'_>, new: &mut OwnedFd, _flags: DupFlags) -> i
dup2(fd, new)
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(crate) fn ioctl_fioclex(fd: BorrowedFd<'_>) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::FIOCLEX)) }
}
@@ -448,6 +488,34 @@ pub(crate) fn ioctl_tiocnxcl(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::ioctl(borrowed_fd(fd), c::TIOCNXCL as _)) }
}
+#[cfg(bsd)]
+pub(crate) fn kqueue() -> io::Result<OwnedFd> {
+ unsafe { ret_owned_fd(c::kqueue()) }
+}
+
+#[cfg(bsd)]
+pub(crate) unsafe fn kevent(
+ kq: BorrowedFd<'_>,
+ changelist: &[Event],
+ eventlist: &mut [MaybeUninit<Event>],
+ timeout: Option<&c::timespec>,
+) -> io::Result<c::c_int> {
+ ret_c_int(c::kevent(
+ borrowed_fd(kq),
+ changelist.as_ptr() as *const _,
+ changelist
+ .len()
+ .try_into()
+ .map_err(|_| io::Errno::OVERFLOW)?,
+ eventlist.as_mut_ptr() as *mut _,
+ eventlist
+ .len()
+ .try_into()
+ .map_err(|_| io::Errno::OVERFLOW)?,
+ timeout.map_or(core::ptr::null(), |t| t as *const _),
+ ))
+}
+
#[cfg(not(target_os = "wasi"))]
pub(crate) fn pipe() -> io::Result<(OwnedFd, OwnedFd)> {
unsafe {
@@ -458,13 +526,7 @@ pub(crate) fn pipe() -> io::Result<(OwnedFd, OwnedFd)> {
}
}
-#[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "wasi"
-)))]
+#[cfg(not(any(apple, target_os = "aix", target_os = "haiku", target_os = "wasi")))]
pub(crate) fn pipe_with(flags: PipeFlags) -> io::Result<(OwnedFd, OwnedFd)> {
unsafe {
let mut result = MaybeUninit::<[OwnedFd; 2]>::uninit();
@@ -531,3 +593,85 @@ pub unsafe fn vmsplice(
))
.map(|spliced| spliced as usize)
}
+
+#[cfg(solarish)]
+pub(crate) fn port_create() -> io::Result<OwnedFd> {
+ unsafe { ret_owned_fd(c::port_create()) }
+}
+
+#[cfg(solarish)]
+pub(crate) unsafe fn port_associate(
+ port: BorrowedFd<'_>,
+ source: c::c_int,
+ object: c::uintptr_t,
+ events: c::c_int,
+ user: *mut c::c_void,
+) -> io::Result<()> {
+ ret(c::port_associate(
+ borrowed_fd(port),
+ source,
+ object,
+ events,
+ user,
+ ))
+}
+
+#[cfg(solarish)]
+pub(crate) unsafe fn port_dissociate(
+ port: BorrowedFd<'_>,
+ source: c::c_int,
+ object: c::uintptr_t,
+) -> io::Result<()> {
+ ret(c::port_dissociate(borrowed_fd(port), source, object))
+}
+
+#[cfg(solarish)]
+pub(crate) fn port_get(
+ port: BorrowedFd<'_>,
+ timeout: Option<&mut c::timespec>,
+) -> io::Result<Event> {
+ let mut event = MaybeUninit::<c::port_event>::uninit();
+ let timeout = timeout.map_or(core::ptr::null_mut(), |t| t as *mut _);
+
+ unsafe {
+ ret(c::port_get(borrowed_fd(port), event.as_mut_ptr(), timeout))?;
+ }
+
+ // If we're done, initialize the event and return it.
+ Ok(Event(unsafe { event.assume_init() }))
+}
+
+#[cfg(solarish)]
+pub(crate) fn port_getn(
+ port: BorrowedFd<'_>,
+ timeout: Option<&mut c::timespec>,
+ events: &mut Vec<Event>,
+ mut nget: u32,
+) -> io::Result<()> {
+ let timeout = timeout.map_or(core::ptr::null_mut(), |t| t as *mut _);
+ unsafe {
+ ret(c::port_getn(
+ borrowed_fd(port),
+ events.as_mut_ptr().cast(),
+ events.len().try_into().unwrap(),
+ &mut nget,
+ timeout,
+ ))?;
+ }
+
+ // Update the vector length.
+ unsafe {
+ events.set_len(nget.try_into().unwrap());
+ }
+
+ Ok(())
+}
+
+#[cfg(solarish)]
+pub(crate) fn port_send(
+ port: BorrowedFd<'_>,
+ events: c::c_int,
+ userdata: *mut c::c_void,
+) -> io::Result<()> {
+ unsafe { ret(c::port_send(borrowed_fd(port), events, userdata)) }
+}
diff --git a/vendor/rustix/src/backend/libc/io/types.rs b/vendor/rustix/src/backend/libc/io/types.rs
index 46d5f6332..cbdd734b9 100644
--- a/vendor/rustix/src/backend/libc/io/types.rs
+++ b/vendor/rustix/src/backend/libc/io/types.rs
@@ -22,20 +22,15 @@ bitflags! {
/// [`pwritev2`]: crate::io::pwritev
pub struct ReadWriteFlags: c::c_int {
/// `RWF_DSYNC` (since Linux 4.7)
- #[cfg(all(target_os = "linux", target_env = "gnu"))]
- const DSYNC = c::RWF_DSYNC;
+ const DSYNC = linux_raw_sys::general::RWF_DSYNC as c::c_int;
/// `RWF_HIPRI` (since Linux 4.6)
- #[cfg(all(target_os = "linux", target_env = "gnu"))]
- const HIPRI = c::RWF_HIPRI;
+ const HIPRI = linux_raw_sys::general::RWF_HIPRI as c::c_int;
/// `RWF_SYNC` (since Linux 4.7)
- #[cfg(all(target_os = "linux", target_env = "gnu"))]
- const SYNC = c::RWF_SYNC;
+ const SYNC = linux_raw_sys::general::RWF_SYNC as c::c_int;
/// `RWF_NOWAIT` (since Linux 4.14)
- #[cfg(all(target_os = "linux", target_env = "gnu"))]
- const NOWAIT = c::RWF_NOWAIT;
+ const NOWAIT = linux_raw_sys::general::RWF_NOWAIT as c::c_int;
/// `RWF_APPEND` (since Linux 4.16)
- #[cfg(all(target_os = "linux", target_env = "gnu"))]
- const APPEND = c::RWF_APPEND;
+ const APPEND = linux_raw_sys::general::RWF_APPEND as c::c_int;
}
}
@@ -62,16 +57,16 @@ bitflags! {
pub struct DupFlags: c::c_int {
/// `O_CLOEXEC`
#[cfg(not(any(
+ apple,
+ target_os = "aix",
target_os = "android",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
)))] // Android 5.0 has dup3, but libc doesn't have bindings
const CLOEXEC = c::O_CLOEXEC;
}
}
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
+#[cfg(not(any(apple, target_os = "wasi")))]
bitflags! {
/// `O_*` constants for use with [`pipe_with`].
///
@@ -81,11 +76,10 @@ bitflags! {
const CLOEXEC = c::O_CLOEXEC;
/// `O_DIRECT`
#[cfg(not(any(
+ solarish,
target_os = "haiku",
- target_os = "illumos",
target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const DIRECT = c::O_DIRECT;
/// `O_NONBLOCK`
@@ -109,13 +103,7 @@ bitflags! {
}
/// `PIPE_BUF`—The maximum size of a write to a pipe guaranteed to be atomic.
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "redox",
- target_os = "solaris",
- target_os = "wasi",
-)))]
+#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
pub const PIPE_BUF: usize = c::PIPE_BUF;
#[cfg(not(any(windows, target_os = "redox")))]
@@ -128,9 +116,10 @@ pub(crate) const STDOUT_FILENO: c::c_int = c::STDOUT_FILENO;
pub(crate) const STDERR_FILENO: c::c_int = c::STDERR_FILENO;
/// A buffer type used with `vmsplice`.
-/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms and WSABUF on Windows.
-/// Unlike `IoSlice` and `IoSliceMut` it is semantically like a raw pointer,
-/// and therefore can be shared or mutated as needed.
+/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms
+/// and `WSABUF` on Windows. Unlike `IoSlice` and `IoSliceMut` it is
+/// semantically like a raw pointer, and therefore can be shared or mutated as
+/// needed.
#[cfg(any(target_os = "android", target_os = "linux"))]
#[repr(transparent)]
pub struct IoSliceRaw<'a> {
diff --git a/vendor/rustix/src/backend/libc/io_lifetimes.rs b/vendor/rustix/src/backend/libc/io_lifetimes.rs
index 2dcd772e8..993365c0c 100644
--- a/vendor/rustix/src/backend/libc/io_lifetimes.rs
+++ b/vendor/rustix/src/backend/libc/io_lifetimes.rs
@@ -13,11 +13,11 @@ pub use io_lifetimes::AsSocket;
/// A version of [`AsRawFd`] for use with Winsock2 API.
///
-/// [`AsRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsRawFd.html
+/// [`AsRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsRawFd.html
pub trait AsRawFd {
/// A version of [`as_raw_fd`] for use with Winsock2 API.
///
- /// [`as_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.as_raw_fd
+ /// [`as_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.as_raw_fd
fn as_raw_fd(&self) -> RawFd;
}
#[cfg(feature = "std")]
@@ -30,11 +30,11 @@ impl<T: std::os::windows::io::AsRawSocket> AsRawFd for T {
/// A version of [`IntoRawFd`] for use with Winsock2 API.
///
-/// [`IntoRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.IntoRawFd.html
+/// [`IntoRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.IntoRawFd.html
pub trait IntoRawFd {
/// A version of [`into_raw_fd`] for use with Winsock2 API.
///
- /// [`into_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.into_raw_fd
+ /// [`into_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.into_raw_fd
fn into_raw_fd(self) -> RawFd;
}
#[cfg(feature = "std")]
@@ -47,11 +47,16 @@ impl<T: std::os::windows::io::IntoRawSocket> IntoRawFd for T {
/// A version of [`FromRawFd`] for use with Winsock2 API.
///
-/// [`FromRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html
+/// [`FromRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html
pub trait FromRawFd {
/// A version of [`from_raw_fd`] for use with Winsock2 API.
///
- /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd
+ /// # Safety
+ ///
+ /// See the [safety requirements] for [`from_raw_fd`].
+ ///
+ /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.from_raw_fd
+ /// [safety requirements]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#safety
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self;
}
#[cfg(feature = "std")]
@@ -64,7 +69,7 @@ impl<T: std::os::windows::io::FromRawSocket> FromRawFd for T {
/// A version of [`AsFd`] for use with Winsock2 API.
///
-/// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsFd.html
+/// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsFd.html
pub trait AsFd {
/// An `as_fd` function for Winsock2, where a `Fd` is a `Socket`.
fn as_fd(&self) -> BorrowedFd;
diff --git a/vendor/rustix/src/backend/libc/io_uring/syscalls.rs b/vendor/rustix/src/backend/libc/io_uring/syscalls.rs
index 31fcec3db..17d3eb10c 100644
--- a/vendor/rustix/src/backend/libc/io_uring/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/io_uring/syscalls.rs
@@ -1,7 +1,7 @@
//! libc syscalls supporting `rustix::io_uring`.
use super::super::c;
-use super::super::conv::{borrowed_fd, syscall_ret, syscall_ret_owned_fd, syscall_ret_u32};
+use super::super::conv::{borrowed_fd, syscall_ret_owned_fd, syscall_ret_u32};
use crate::fd::{BorrowedFd, OwnedFd};
use crate::io;
use crate::io_uring::{io_uring_params, IoringEnterFlags, IoringRegisterOp};
@@ -24,8 +24,8 @@ pub(crate) unsafe fn io_uring_register(
opcode: IoringRegisterOp,
arg: *const c::c_void,
nr_args: u32,
-) -> io::Result<()> {
- syscall_ret(c::syscall(
+) -> io::Result<u32> {
+ syscall_ret_u32(c::syscall(
__NR_io_uring_register as _,
borrowed_fd(fd),
opcode as u32 as usize,
diff --git a/vendor/rustix/src/backend/libc/mm/syscalls.rs b/vendor/rustix/src/backend/libc/mm/syscalls.rs
index a1d2df1af..16636f1b9 100644
--- a/vendor/rustix/src/backend/libc/mm/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/mm/syscalls.rs
@@ -7,7 +7,7 @@ use super::super::conv::{borrowed_fd, no_fd, ret};
use super::super::offset::libc_mmap;
#[cfg(not(target_os = "redox"))]
use super::types::Advice;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "emscripten", target_os = "linux"))]
use super::types::MremapFlags;
use super::types::{MapFlags, MprotectFlags, MsyncFlags, ProtFlags};
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -130,7 +130,7 @@ pub(crate) unsafe fn munmap(ptr: *mut c::c_void, len: usize) -> io::Result<()> {
///
/// `mremap` is primarily unsafe due to the `old_address` parameter, as
/// anything working with memory pointed to by raw pointers is unsafe.
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "emscripten", target_os = "linux"))]
pub(crate) unsafe fn mremap(
old_address: *mut c::c_void,
old_size: usize,
@@ -150,7 +150,7 @@ pub(crate) unsafe fn mremap(
/// `mremap_fixed` is primarily unsafe due to the `old_address` and
/// `new_address` parameters, as anything working with memory pointed to by raw
/// pointers is unsafe.
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "emscripten", target_os = "linux"))]
pub(crate) unsafe fn mremap_fixed(
old_address: *mut c::c_void,
old_size: usize,
diff --git a/vendor/rustix/src/backend/libc/mm/types.rs b/vendor/rustix/src/backend/libc/mm/types.rs
index 11ab708cf..cd6e521d2 100644
--- a/vendor/rustix/src/backend/libc/mm/types.rs
+++ b/vendor/rustix/src/backend/libc/mm/types.rs
@@ -51,165 +51,109 @@ bitflags! {
const SHARED = c::MAP_SHARED;
/// `MAP_SHARED_VALIDATE`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const SHARED_VALIDATE = c::MAP_SHARED_VALIDATE;
/// `MAP_PRIVATE`
const PRIVATE = c::MAP_PRIVATE;
/// `MAP_DENYWRITE`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const DENYWRITE = c::MAP_DENYWRITE;
/// `MAP_FIXED`
const FIXED = c::MAP_FIXED;
/// `MAP_FIXED_NOREPLACE`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const FIXED_NOREPLACE = c::MAP_FIXED_NOREPLACE;
/// `MAP_GROWSDOWN`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const GROWSDOWN = c::MAP_GROWSDOWN;
/// `MAP_HUGETLB`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const HUGETLB = c::MAP_HUGETLB;
/// `MAP_HUGE_2MB`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const HUGE_2MB = c::MAP_HUGE_2MB;
/// `MAP_HUGE_1GB`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const HUGE_1GB = c::MAP_HUGE_1GB;
/// `MAP_LOCKED`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const LOCKED = c::MAP_LOCKED;
/// `MAP_NOCORE`
- #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
+ #[cfg(freebsdlike)]
const NOCORE = c::MAP_NOCORE;
/// `MAP_NORESERVE`
- #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "redox")))]
+ #[cfg(not(any(freebsdlike, target_os = "redox")))]
const NORESERVE = c::MAP_NORESERVE;
/// `MAP_NOSYNC`
- #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
+ #[cfg(freebsdlike)]
const NOSYNC = c::MAP_NOSYNC;
/// `MAP_POPULATE`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const POPULATE = c::MAP_POPULATE;
/// `MAP_STACK`
#[cfg(not(any(
+ apple,
+ solarish,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
)))]
const STACK = c::MAP_STACK;
/// `MAP_PREFAULT_READ`
@@ -217,19 +161,13 @@ bitflags! {
const PREFAULT_READ = c::MAP_PREFAULT_READ;
/// `MAP_SYNC`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
all(
any(target_os = "android", target_os = "linux"),
any(target_arch = "mips", target_arch = "mips64"),
@@ -242,7 +180,7 @@ bitflags! {
}
}
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "emscripten", target_os = "linux"))]
bitflags! {
/// `MREMAP_*` flags for use with [`mremap`].
///
diff --git a/vendor/rustix/src/backend/libc/mod.rs b/vendor/rustix/src/backend/libc/mod.rs
index 70029282f..1961d1291 100644
--- a/vendor/rustix/src/backend/libc/mod.rs
+++ b/vendor/rustix/src/backend/libc/mod.rs
@@ -49,11 +49,8 @@ pub(crate) mod fd {
// On Windows we emulate selected libc-compatible interfaces. On non-Windows,
// we just use libc here, since this is the libc backend.
-#[cfg(windows)]
-#[path = "winsock_c.rs"]
+#[cfg_attr(windows, path = "winsock_c.rs")]
pub(crate) mod c;
-#[cfg(not(windows))]
-pub(crate) use libc as c;
#[cfg(not(windows))]
#[cfg(feature = "fs")]
diff --git a/vendor/rustix/src/backend/libc/net/addr.rs b/vendor/rustix/src/backend/libc/net/addr.rs
index ba64ed279..d00a48626 100644
--- a/vendor/rustix/src/backend/libc/net/addr.rs
+++ b/vendor/rustix/src/backend/libc/net/addr.rs
@@ -20,14 +20,7 @@ use core::slice;
#[doc(alias = "sockaddr_un")]
pub struct SocketAddrUnix {
pub(crate) unix: c::sockaddr_un,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len: c::socklen_t,
}
@@ -50,28 +43,14 @@ impl SocketAddrUnix {
unix.sun_path[i] = *b as c::c_char;
}
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
unix.sun_len = (offsetof_sun_path() + bytes.len()).try_into().unwrap();
}
Ok(Self {
unix,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len: (offsetof_sun_path() + bytes.len()).try_into().unwrap(),
})
}
@@ -92,49 +71,19 @@ impl SocketAddrUnix {
let len = len.try_into().unwrap();
Ok(Self {
unix,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
len,
})
}
fn init() -> c::sockaddr_un {
c::sockaddr_un {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_len: 0,
sun_family: c::AF_UNIX as _,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
sun_path: [0; 104],
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_path: [0; 108],
#[cfg(target_os = "haiku")]
sun_path: [0; 126],
@@ -148,7 +97,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] != b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
// `from_bytes_with_nul_unchecked` since the string is NUL-terminated.
unsafe {
Some(CStr::from_bytes_with_nul_unchecked(slice::from_raw_parts(
@@ -169,7 +118,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] == b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[1..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
unsafe { Some(slice::from_raw_parts(bytes.as_ptr().cast(), bytes.len())) }
} else {
None
@@ -178,25 +127,11 @@ impl SocketAddrUnix {
#[inline]
pub(crate) fn addr_len(&self) -> c::socklen_t {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
{
self.len
}
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
c::socklen_t::from(self.unix.sun_len)
}
@@ -274,54 +209,15 @@ pub type SocketAddrStorage = c::sockaddr_storage;
#[inline]
pub(crate) fn offsetof_sun_path() -> usize {
let z = c::sockaddr_un {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_len: 0_u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sun_family: 0_u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_family: 0_u16,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(bsd)]
sun_path: [0; 104],
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sun_path: [0; 108],
#[cfg(target_os = "haiku")]
sun_path: [0; 126],
diff --git a/vendor/rustix/src/backend/libc/net/ext.rs b/vendor/rustix/src/backend/libc/net/ext.rs
index 1c8f9f65c..f4ad316dd 100644
--- a/vendor/rustix/src/backend/libc/net/ext.rs
+++ b/vendor/rustix/src/backend/libc/net/ext.rs
@@ -130,16 +130,7 @@ pub(crate) fn sockaddr_in6_sin6_scope_id(addr: c::sockaddr_in6) -> u32 {
#[cfg(not(windows))]
#[inline]
pub(crate) const fn sockaddr_in6_new(
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
- sin6_len: u8,
+ #[cfg(any(bsd, target_os = "haiku"))] sin6_len: u8,
sin6_family: c::sa_family_t,
sin6_port: u16,
sin6_flowinfo: u32,
@@ -147,22 +138,14 @@ pub(crate) const fn sockaddr_in6_new(
sin6_scope_id: u32,
) -> c::sockaddr_in6 {
c::sockaddr_in6 {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sin6_len,
sin6_family,
sin6_port,
sin6_flowinfo,
sin6_addr,
sin6_scope_id,
- #[cfg(any(target_os = "illumos", target_os = "solaris"))]
+ #[cfg(solarish)]
__sin6_src_id: 0,
}
}
diff --git a/vendor/rustix/src/backend/libc/net/read_sockaddr.rs b/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
index 5a946fbeb..575102c27 100644
--- a/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
+++ b/vendor/rustix/src/backend/libc/net/read_sockaddr.rs
@@ -13,32 +13,11 @@ use core::mem::size_of;
// This must match the header of `sockaddr`.
#[repr(C)]
struct sockaddr_header {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_len: u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
ss_family: u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
ss_family: u16,
}
@@ -46,35 +25,11 @@ struct sockaddr_header {
unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 {
// Assert that we know the layout of `sockaddr`.
let _ = c::sockaddr {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_len: 0_u8,
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sa_family: 0_u8,
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
sa_family: 0_u16,
#[cfg(not(target_os = "haiku"))]
sa_data: [0; 14],
diff --git a/vendor/rustix/src/backend/libc/net/send_recv.rs b/vendor/rustix/src/backend/libc/net/send_recv.rs
index 8d1cc8ab7..114807808 100644
--- a/vendor/rustix/src/backend/libc/net/send_recv.rs
+++ b/vendor/rustix/src/backend/libc/net/send_recv.rs
@@ -6,16 +6,10 @@ bitflags! {
pub struct SendFlags: i32 {
/// `MSG_CONFIRM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const CONFIRM = c::MSG_CONFIRM;
/// `MSG_DONTROUTE`
@@ -28,19 +22,13 @@ bitflags! {
const EOT = c::MSG_EOR;
/// `MSG_MORE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const MORE = c::MSG_MORE;
- #[cfg(not(any(windows, target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows)))]
/// `MSG_NOSIGNAL`
const NOSIGNAL = c::MSG_NOSIGNAL;
/// `MSG_OOB`
@@ -51,7 +39,7 @@ bitflags! {
bitflags! {
/// `MSG_*`
pub struct RecvFlags: i32 {
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
+ #[cfg(not(any(apple, solarish, windows, target_os = "haiku")))]
/// `MSG_CMSG_CLOEXEC`
const CMSG_CLOEXEC = c::MSG_CMSG_CLOEXEC;
/// `MSG_DONTWAIT`
@@ -59,16 +47,10 @@ bitflags! {
const DONTWAIT = c::MSG_DONTWAIT;
/// `MSG_ERRQUEUE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
const ERRQUEUE = c::MSG_ERRQUEUE;
/// `MSG_OOB`
diff --git a/vendor/rustix/src/backend/libc/net/syscalls.rs b/vendor/rustix/src/backend/libc/net/syscalls.rs
index 3d8a849c7..ed4494394 100644
--- a/vendor/rustix/src/backend/libc/net/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/net/syscalls.rs
@@ -251,10 +251,9 @@ pub(crate) fn accept(sockfd: BorrowedFd<'_>) -> io::Result<OwnedFd> {
}
#[cfg(not(any(
+ apple,
windows,
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
target_os = "wasi",
)))]
@@ -288,10 +287,9 @@ pub(crate) fn acceptfrom(sockfd: BorrowedFd<'_>) -> io::Result<(OwnedFd, Option<
}
#[cfg(not(any(
+ apple,
windows,
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
target_os = "wasi",
)))]
@@ -317,14 +315,14 @@ pub(crate) fn acceptfrom_with(
/// Darwin lacks `accept4`, but does have `accept`. We define
/// `AcceptFlags` to have no flags, so we can discard it here.
-#[cfg(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos"))]
+#[cfg(any(apple, windows, target_os = "haiku"))]
pub(crate) fn accept_with(sockfd: BorrowedFd<'_>, _flags: AcceptFlags) -> io::Result<OwnedFd> {
accept(sockfd)
}
/// Darwin lacks `accept4`, but does have `accept`. We define
/// `AcceptFlags` to have no flags, so we can discard it here.
-#[cfg(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos"))]
+#[cfg(any(apple, windows, target_os = "haiku"))]
pub(crate) fn acceptfrom_with(
sockfd: BorrowedFd<'_>,
_flags: AcceptFlags,
@@ -555,11 +553,12 @@ pub(crate) mod sockopt {
return Err(io::Errno::INVAL);
}
- let tv_sec = timeout.as_secs().try_into();
- #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
- let tv_sec = tv_sec.unwrap_or(c::c_long::MAX);
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
- let tv_sec = tv_sec.unwrap_or(i64::MAX);
+ // Rust's musl libc bindings deprecated `time_t` while they
+ // transition to 64-bit `time_t`. What we want here is just
+ // "whatever type `timeval`'s `tv_sec` is", so we're ok using
+ // the deprecated type.
+ #[allow(deprecated)]
+ let tv_sec = timeout.as_secs().try_into().unwrap_or(c::time_t::MAX);
// `subsec_micros` rounds down, so we use `subsec_nanos` and
// manually round up.
@@ -635,6 +634,28 @@ pub(crate) mod sockopt {
}
}
+ #[cfg(any(apple, target_os = "freebsd"))]
+ #[inline]
+ pub(crate) fn getsockopt_nosigpipe(fd: BorrowedFd<'_>) -> io::Result<bool> {
+ getsockopt(fd, c::SOL_SOCKET, c::SO_NOSIGPIPE).map(to_bool)
+ }
+
+ #[cfg(any(apple, target_os = "freebsd"))]
+ #[inline]
+ pub(crate) fn setsockopt_nosigpipe(fd: BorrowedFd<'_>, val: bool) -> io::Result<()> {
+ setsockopt(fd, c::SOL_SOCKET, c::SO_NOSIGPIPE, from_bool(val))
+ }
+
+ #[inline]
+ pub(crate) fn get_socket_error(fd: BorrowedFd<'_>) -> io::Result<Result<(), crate::io::Errno>> {
+ let err: c::c_int = getsockopt(fd, c::SOL_SOCKET as _, c::SO_ERROR)?;
+ Ok(if err == 0 {
+ Ok(())
+ } else {
+ Err(crate::io::Errno::from_raw_os_error(err))
+ })
+ }
+
#[inline]
pub(crate) fn set_ip_ttl(fd: BorrowedFd<'_>, ttl: u32) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_IP as _, c::IP_TTL, ttl)
@@ -735,31 +756,9 @@ pub(crate) mod sockopt {
multiaddr: &Ipv6Addr,
interface: u32,
) -> io::Result<()> {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "haiku", target_os = "l4re")))]
use c::IPV6_ADD_MEMBERSHIP;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- ))]
+ #[cfg(any(bsd, solarish, target_os = "haiku", target_os = "l4re"))]
use c::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
let mreq = to_ipv6mr(multiaddr, interface);
@@ -782,31 +781,9 @@ pub(crate) mod sockopt {
multiaddr: &Ipv6Addr,
interface: u32,
) -> io::Result<()> {
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "haiku", target_os = "l4re")))]
use c::IPV6_DROP_MEMBERSHIP;
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- ))]
+ #[cfg(any(bsd, solarish, target_os = "haiku", target_os = "l4re"))]
use c::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
let mreq = to_ipv6mr(multiaddr, interface);
diff --git a/vendor/rustix/src/backend/libc/net/types.rs b/vendor/rustix/src/backend/libc/net/types.rs
index 19d97e7c7..54f60ca50 100644
--- a/vendor/rustix/src/backend/libc/net/types.rs
+++ b/vendor/rustix/src/backend/libc/net/types.rs
@@ -62,16 +62,10 @@ impl AddressFamily {
pub const INET6: Self = Self(c::AF_INET6 as _);
/// `AF_NETLINK`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETLINK: Self = Self(c::AF_NETLINK as _);
/// `AF_UNIX`, aka `AF_LOCAL`
@@ -79,16 +73,10 @@ impl AddressFamily {
pub const UNIX: Self = Self(c::AF_UNIX as _);
/// `AF_AX25`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const AX25: Self = Self(c::AF_AX25 as _);
/// `AF_IPX`
@@ -97,70 +85,41 @@ impl AddressFamily {
pub const APPLETALK: Self = Self(c::AF_APPLETALK as _);
/// `AF_NETROM`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETROM: Self = Self(c::AF_NETROM as _);
/// `AF_BRIDGE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const BRIDGE: Self = Self(c::AF_BRIDGE as _);
/// `AF_ATMPVC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ATMPVC: Self = Self(c::AF_ATMPVC as _);
/// `AF_X25`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const X25: Self = Self(c::AF_X25 as _);
/// `AF_ROSE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ROSE: Self = Self(c::AF_ROSE as _);
/// `AF_DECnet`
@@ -169,110 +128,64 @@ impl AddressFamily {
pub const DECnet: Self = Self(c::AF_DECnet as _);
/// `AF_NETBEUI`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const NETBEUI: Self = Self(c::AF_NETBEUI as _);
/// `AF_SECURITY`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const SECURITY: Self = Self(c::AF_SECURITY as _);
/// `AF_KEY`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const KEY: Self = Self(c::AF_KEY as _);
/// `AF_PACKET`
#[cfg(not(any(
+ bsd,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
)))]
pub const PACKET: Self = Self(c::AF_PACKET as _);
/// `AF_ASH`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ASH: Self = Self(c::AF_ASH as _);
/// `AF_ECONET`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ECONET: Self = Self(c::AF_ECONET as _);
/// `AF_ATMSVC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const ATMSVC: Self = Self(c::AF_ATMSVC as _);
/// `AF_RDS`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const RDS: Self = Self(c::AF_RDS as _);
/// `AF_SNA`
@@ -280,147 +193,87 @@ impl AddressFamily {
pub const SNA: Self = Self(c::AF_SNA as _);
/// `AF_IRDA`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IRDA: Self = Self(c::AF_IRDA as _);
/// `AF_PPPOX`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const PPPOX: Self = Self(c::AF_PPPOX as _);
/// `AF_WANPIPE`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const WANPIPE: Self = Self(c::AF_WANPIPE as _);
/// `AF_LLC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const LLC: Self = Self(c::AF_LLC as _);
/// `AF_CAN`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const CAN: Self = Self(c::AF_CAN as _);
/// `AF_TIPC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const TIPC: Self = Self(c::AF_TIPC as _);
/// `AF_BLUETOOTH`
- #[cfg(not(any(windows, target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
+ #[cfg(not(any(apple, solarish, windows)))]
pub const BLUETOOTH: Self = Self(c::AF_BLUETOOTH as _);
/// `AF_IUCV`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IUCV: Self = Self(c::AF_IUCV as _);
/// `AF_RXRPC`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const RXRPC: Self = Self(c::AF_RXRPC as _);
/// `AF_ISDN`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const ISDN: Self = Self(c::AF_ISDN as _);
/// `AF_PHONET`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const PHONET: Self = Self(c::AF_PHONET as _);
/// `AF_IEEE802154`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const IEEE802154: Self = Self(c::AF_IEEE802154 as _);
@@ -453,164 +306,134 @@ impl Protocol {
/// `IPPROTO_ICMP`
pub const ICMP: Self = Self(c::IPPROTO_ICMP as _);
/// `IPPROTO_IGMP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const IGMP: Self = Self(c::IPPROTO_IGMP as _);
/// `IPPROTO_IPIP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const IPIP: Self = Self(c::IPPROTO_IPIP as _);
/// `IPPROTO_TCP`
pub const TCP: Self = Self(c::IPPROTO_TCP as _);
/// `IPPROTO_EGP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const EGP: Self = Self(c::IPPROTO_EGP as _);
/// `IPPROTO_PUP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const PUP: Self = Self(c::IPPROTO_PUP as _);
/// `IPPROTO_UDP`
pub const UDP: Self = Self(c::IPPROTO_UDP as _);
/// `IPPROTO_IDP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const IDP: Self = Self(c::IPPROTO_IDP as _);
/// `IPPROTO_TP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const TP: Self = Self(c::IPPROTO_TP as _);
/// `IPPROTO_DCCP`
#[cfg(not(any(
+ apple,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd",
- target_os = "solaris",
)))]
pub const DCCP: Self = Self(c::IPPROTO_DCCP as _);
/// `IPPROTO_IPV6`
pub const IPV6: Self = Self(c::IPPROTO_IPV6 as _);
/// `IPPROTO_RSVP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const RSVP: Self = Self(c::IPPROTO_RSVP as _);
/// `IPPROTO_GRE`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const GRE: Self = Self(c::IPPROTO_GRE as _);
/// `IPPROTO_ESP`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const ESP: Self = Self(c::IPPROTO_ESP as _);
/// `IPPROTO_AH`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const AH: Self = Self(c::IPPROTO_AH as _);
/// `IPPROTO_MTP`
#[cfg(not(any(
+ solarish,
+ netbsdlike,
windows,
target_os = "haiku",
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MTP: Self = Self(c::IPPROTO_MTP as _);
/// `IPPROTO_BEETPH`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const BEETPH: Self = Self(c::IPPROTO_BEETPH as _);
/// `IPPROTO_ENCAP`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, windows, target_os = "haiku")))]
pub const ENCAP: Self = Self(c::IPPROTO_ENCAP as _);
/// `IPPROTO_PIM`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const PIM: Self = Self(c::IPPROTO_PIM as _);
/// `IPPROTO_COMP`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const COMP: Self = Self(c::IPPROTO_COMP as _);
/// `IPPROTO_SCTP`
- #[cfg(not(any(target_os = "dragonfly", target_os = "haiku", target_os = "illumos", target_os = "openbsd", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "dragonfly", target_os = "haiku", target_os = "openbsd")))]
pub const SCTP: Self = Self(c::IPPROTO_SCTP as _);
/// `IPPROTO_UDPLITE`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const UDPLITE: Self = Self(c::IPPROTO_UDPLITE as _);
/// `IPPROTO_MPLS`
#[cfg(not(any(
+ apple,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
- target_os = "solaris",
)))]
pub const MPLS: Self = Self(c::IPPROTO_MPLS as _);
/// `IPPROTO_RAW`
pub const RAW: Self = Self(c::IPPROTO_RAW as _);
/// `IPPROTO_MPTCP`
#[cfg(not(any(
+ bsd,
+ solarish,
windows,
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MPTCP: Self = Self(c::IPPROTO_MPTCP as _);
/// `IPPROTO_FRAGMENT`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const FRAGMENT: Self = Self(c::IPPROTO_FRAGMENT as _);
/// `IPPROTO_ICMPV6`
pub const ICMPV6: Self = Self(c::IPPROTO_ICMPV6 as _);
/// `IPPROTO_MH`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
windows,
target_os = "dragonfly",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
pub const MH: Self = Self(c::IPPROTO_MH as _);
/// `IPPROTO_ROUTING`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
pub const ROUTING: Self = Self(c::IPPROTO_ROUTING as _);
/// Constructs a `Protocol` from a raw integer.
@@ -647,11 +470,11 @@ bitflags! {
/// [`acceptfrom_with`]: crate::net::acceptfrom_with
pub struct AcceptFlags: c::c_int {
/// `SOCK_NONBLOCK`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const NONBLOCK = c::SOCK_NONBLOCK;
/// `SOCK_CLOEXEC`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const CLOEXEC = c::SOCK_CLOEXEC;
}
}
@@ -662,11 +485,11 @@ bitflags! {
/// [`socket`]: crate::net::socket
pub struct SocketFlags: c::c_int {
/// `SOCK_NONBLOCK`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const NONBLOCK = c::SOCK_NONBLOCK;
/// `SOCK_CLOEXEC`
- #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(apple, windows, target_os = "haiku")))]
const CLOEXEC = c::SOCK_CLOEXEC;
}
}
diff --git a/vendor/rustix/src/backend/libc/net/write_sockaddr.rs b/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
index f44284a0b..f8ab62966 100644
--- a/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
+++ b/vendor/rustix/src/backend/libc/net/write_sockaddr.rs
@@ -23,15 +23,7 @@ pub(crate) unsafe fn write_sockaddr(
pub(crate) unsafe fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in {
c::sockaddr_in {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
sin_len: size_of::<c::sockaddr_in>() as _,
sin_family: c::AF_INET as _,
sin_port: u16::to_be(v4.port()),
@@ -50,15 +42,7 @@ unsafe fn write_sockaddr_v4(v4: &SocketAddrV4, storage: *mut SocketAddrStorage)
}
pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
- #[cfg(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- ))]
+ #[cfg(any(bsd, target_os = "haiku"))]
{
sockaddr_in6_new(
size_of::<c::sockaddr_in6>() as _,
@@ -69,15 +53,7 @@ pub(crate) unsafe fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
v6.scope_id(),
)
}
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
{
sockaddr_in6_new(
c::AF_INET6 as _,
diff --git a/vendor/rustix/src/backend/libc/offset.rs b/vendor/rustix/src/backend/libc/offset.rs
index 8aae9d073..9747eb954 100644
--- a/vendor/rustix/src/backend/libc/offset.rs
+++ b/vendor/rustix/src/backend/libc/offset.rs
@@ -3,96 +3,47 @@
#[cfg(not(windows))]
use super::c;
-#[cfg(not(any(
- windows,
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
-)))]
+#[cfg(not(any(linux_like, windows)))]
#[cfg(feature = "fs")]
pub(super) use c::{
fstat as libc_fstat, fstatat as libc_fstatat, ftruncate as libc_ftruncate, lseek as libc_lseek,
off_t as libc_off_t,
};
-#[cfg(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
-))]
+#[cfg(linux_like)]
#[cfg(feature = "fs")]
pub(super) use c::{
fstat64 as libc_fstat, fstatat64 as libc_fstatat, ftruncate64 as libc_ftruncate,
lseek64 as libc_lseek, off64_t as libc_off_t,
};
-#[cfg(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
-))]
+#[cfg(linux_like)]
pub(super) use c::rlimit64 as libc_rlimit;
-#[cfg(not(any(
- windows,
- target_os = "android",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
- target_os = "wasi",
-)))]
+#[cfg(not(any(linux_like, windows, target_os = "wasi")))]
#[cfg(feature = "mm")]
pub(super) use c::mmap as libc_mmap;
#[cfg(not(any(
+ linux_like,
windows,
- target_os = "android",
- target_os = "emscripten",
target_os = "fuchsia",
- target_os = "l4re",
- target_os = "linux",
target_os = "redox",
target_os = "wasi",
)))]
pub(super) use c::{rlimit as libc_rlimit, RLIM_INFINITY as LIBC_RLIM_INFINITY};
-#[cfg(not(any(
- windows,
- target_os = "android",
- target_os = "fuchsia",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "linux",
- target_os = "wasi",
-)))]
+#[cfg(not(any(linux_like, windows, target_os = "fuchsia", target_os = "wasi")))]
pub(super) use c::{getrlimit as libc_getrlimit, setrlimit as libc_setrlimit};
// TODO: Add `RLIM64_INFINITY` to upstream libc.
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
pub(super) const LIBC_RLIM_INFINITY: u64 = !0_u64;
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
pub(super) use c::{getrlimit64 as libc_getrlimit, setrlimit64 as libc_setrlimit};
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
#[cfg(feature = "mm")]
pub(super) use c::mmap64 as libc_mmap;
@@ -152,22 +103,10 @@ pub(super) unsafe fn libc_prlimit(
prlimit64(pid, resource, new_limit, old_limit)
}
-#[cfg(not(any(
- windows,
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
- target_os = "redox",
-)))]
+#[cfg(not(any(linux_like, windows, target_os = "redox")))]
#[cfg(feature = "fs")]
pub(super) use c::openat as libc_openat;
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
#[cfg(feature = "fs")]
pub(super) use c::openat64 as libc_openat;
@@ -178,29 +117,18 @@ pub(super) use c::fallocate as libc_fallocate;
#[cfg(feature = "fs")]
pub(super) use c::fallocate64 as libc_fallocate;
#[cfg(not(any(
+ apple,
+ linux_like,
+ netbsdlike,
+ solarish,
windows,
- target_os = "android",
target_os = "dragonfly",
- target_os = "emscripten",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "linux",
- target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
#[cfg(feature = "fs")]
pub(super) use c::posix_fadvise as libc_posix_fadvise;
-#[cfg(any(
- target_os = "android",
- target_os = "emscripten",
- target_os = "linux",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
#[cfg(feature = "fs")]
pub(super) use c::posix_fadvise64 as libc_posix_fadvise;
@@ -213,8 +141,20 @@ pub(super) use c::posix_fadvise64 as libc_posix_fadvise;
pub(super) use c::{pread as libc_pread, pwrite as libc_pwrite};
#[cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten"))]
pub(super) use c::{pread64 as libc_pread, pwrite64 as libc_pwrite};
+#[cfg(not(any(
+ apple,
+ windows,
+ target_os = "android",
+ target_os = "emscripten",
+ target_os = "haiku",
+ target_os = "linux",
+ target_os = "redox",
+ target_os = "solaris",
+)))]
+pub(super) use c::{preadv as libc_preadv, pwritev as libc_pwritev};
#[cfg(any(target_os = "linux", target_os = "emscripten"))]
pub(super) use c::{preadv64 as libc_preadv, pwritev64 as libc_pwritev};
+
#[cfg(target_os = "android")]
mod readwrite_pv64 {
use super::c;
@@ -302,22 +242,11 @@ mod readwrite_pv64 {
}
}
}
-#[cfg(not(any(
- windows,
- target_os = "android",
- target_os = "emscripten",
- target_os = "haiku",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
- target_os = "redox",
- target_os = "solaris",
-)))]
-pub(super) use c::{preadv as libc_preadv, pwritev as libc_pwritev};
#[cfg(target_os = "android")]
pub(super) use readwrite_pv64::{preadv64 as libc_preadv, pwritev64 as libc_pwritev};
+
// macOS added preadv and pwritev in version 11.0
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
mod readwrite_pv {
use super::c;
@@ -337,26 +266,116 @@ mod readwrite_pv {
) -> c::ssize_t
}
}
-#[cfg(all(target_os = "linux", target_env = "gnu"))]
-pub(super) use c::{preadv64v2 as libc_preadv2, pwritev64v2 as libc_pwritev2};
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
pub(super) use readwrite_pv::{preadv as libc_preadv, pwritev as libc_pwritev};
+// GLIBC added `preadv64v2` and `pwritev64v2` in version 2.26.
+#[cfg(all(target_os = "linux", target_env = "gnu"))]
+mod readwrite_pv64v2 {
+ use super::c;
+
+ // 64-bit offsets on 32-bit platforms are passed in endianness-specific
+ // lo/hi pairs. See src/backend/linux_raw/conv.rs for details.
+ #[cfg(all(target_endian = "little", target_pointer_width = "32"))]
+ fn lo(x: u64) -> usize {
+ (x >> 32) as usize
+ }
+ #[cfg(all(target_endian = "little", target_pointer_width = "32"))]
+ fn hi(x: u64) -> usize {
+ (x & 0xffff_ffff) as usize
+ }
+ #[cfg(all(target_endian = "big", target_pointer_width = "32"))]
+ fn lo(x: u64) -> usize {
+ (x & 0xffff_ffff) as usize
+ }
+ #[cfg(all(target_endian = "big", target_pointer_width = "32"))]
+ fn hi(x: u64) -> usize {
+ (x >> 32) as usize
+ }
+
+ pub(in super::super) unsafe fn preadv64v2(
+ fd: c::c_int,
+ iov: *const c::iovec,
+ iovcnt: c::c_int,
+ offset: c::off64_t,
+ flags: c::c_int,
+ ) -> c::ssize_t {
+ // Older GLIBC lacks `preadv64v2`, so use the `weak!` mechanism to
+ // test for it, and call back to `c::syscall`. We don't use
+ // `weak_or_syscall` here because we need to pass the 64-bit offset
+ // specially.
+ weak! {
+ fn preadv64v2(c::c_int, *const c::iovec, c::c_int, c::off64_t, c::c_int) -> c::ssize_t
+ }
+ if let Some(fun) = preadv64v2.get() {
+ fun(fd, iov, iovcnt, offset, flags)
+ } else {
+ #[cfg(target_pointer_width = "32")]
+ {
+ c::syscall(
+ c::SYS_preadv,
+ fd,
+ iov,
+ iovcnt,
+ hi(offset as u64),
+ lo(offset as u64),
+ flags,
+ ) as c::ssize_t
+ }
+ #[cfg(target_pointer_width = "64")]
+ {
+ c::syscall(c::SYS_preadv2, fd, iov, iovcnt, offset, flags) as c::ssize_t
+ }
+ }
+ }
+ pub(in super::super) unsafe fn pwritev64v2(
+ fd: c::c_int,
+ iov: *const c::iovec,
+ iovcnt: c::c_int,
+ offset: c::off64_t,
+ flags: c::c_int,
+ ) -> c::ssize_t {
+ // See the comments in `preadv64v2`.
+ weak! {
+ fn pwritev64v2(c::c_int, *const c::iovec, c::c_int, c::off64_t, c::c_int) -> c::ssize_t
+ }
+ if let Some(fun) = pwritev64v2.get() {
+ fun(fd, iov, iovcnt, offset, flags)
+ } else {
+ #[cfg(target_pointer_width = "32")]
+ {
+ c::syscall(
+ c::SYS_pwritev,
+ fd,
+ iov,
+ iovcnt,
+ hi(offset as u64),
+ lo(offset as u64),
+ flags,
+ ) as c::ssize_t
+ }
+ #[cfg(target_pointer_width = "64")]
+ {
+ c::syscall(c::SYS_pwritev2, fd, iov, iovcnt, offset, flags) as c::ssize_t
+ }
+ }
+ }
+}
+#[cfg(all(target_os = "linux", target_env = "gnu"))]
+pub(super) use readwrite_pv64v2::{preadv64v2 as libc_preadv2, pwritev64v2 as libc_pwritev2};
+
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
windows,
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
target_os = "linux",
target_os = "l4re",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
#[cfg(feature = "fs")]
pub(super) use c::posix_fallocate as libc_posix_fallocate;
@@ -364,41 +383,28 @@ pub(super) use c::posix_fallocate as libc_posix_fallocate;
#[cfg(feature = "fs")]
pub(super) use c::posix_fallocate64 as libc_posix_fallocate;
#[cfg(not(any(
+ linux_like,
+ solarish,
windows,
- target_os = "android",
- target_os = "emscripten",
target_os = "haiku",
- target_os = "illumos",
- target_os = "linux",
- target_os = "l4re",
target_os = "netbsd",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[cfg(feature = "fs")]
pub(super) use {c::fstatfs as libc_fstatfs, c::statfs as libc_statfs};
#[cfg(not(any(
+ linux_like,
+ solarish,
windows,
- target_os = "android",
- target_os = "emscripten",
target_os = "haiku",
- target_os = "illumos",
- target_os = "linux",
- target_os = "l4re",
target_os = "redox",
- target_os = "solaris",
target_os = "wasi",
)))]
#[cfg(feature = "fs")]
pub(super) use {c::fstatvfs as libc_fstatvfs, c::statvfs as libc_statvfs};
-#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "emscripten",
- target_os = "l4re",
-))]
+#[cfg(linux_like)]
#[cfg(feature = "fs")]
pub(super) use {
c::fstatfs64 as libc_fstatfs, c::fstatvfs64 as libc_fstatvfs, c::statfs64 as libc_statfs,
diff --git a/vendor/rustix/src/backend/libc/process/cpu_set.rs b/vendor/rustix/src/backend/libc/process/cpu_set.rs
index 14ad8d208..a9d6d89c2 100644
--- a/vendor/rustix/src/backend/libc/process/cpu_set.rs
+++ b/vendor/rustix/src/backend/libc/process/cpu_set.rs
@@ -1,3 +1,5 @@
+//! Rust implementation of the `CPU_*` macro API.
+
#![allow(non_snake_case)]
use super::super::c;
diff --git a/vendor/rustix/src/backend/libc/process/syscalls.rs b/vendor/rustix/src/backend/libc/process/syscalls.rs
index 6f4e85916..d208bda7a 100644
--- a/vendor/rustix/src/backend/libc/process/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/process/syscalls.rs
@@ -3,9 +3,9 @@
use super::super::c;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
use super::super::conv::borrowed_fd;
-#[cfg(not(target_os = "wasi"))]
-use super::super::conv::ret_pid_t;
use super::super::conv::{c_str, ret, ret_c_int, ret_discarded_char_ptr};
+#[cfg(not(target_os = "wasi"))]
+use super::super::conv::{ret_infallible, ret_pid_t};
#[cfg(any(target_os = "android", target_os = "linux"))]
use super::super::conv::{syscall_ret, syscall_ret_u32};
#[cfg(any(
@@ -17,21 +17,28 @@ use super::super::conv::{syscall_ret, syscall_ret_u32};
use super::types::RawCpuSet;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
use crate::fd::BorrowedFd;
+#[cfg(target_os = "linux")]
+use crate::fd::{AsRawFd, OwnedFd};
use crate::ffi::CStr;
+#[cfg(feature = "fs")]
+use crate::fs::Mode;
use crate::io;
+#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
+use crate::process::{WaitId, WaitidOptions, WaitidStatus};
use core::mem::MaybeUninit;
+#[cfg(target_os = "linux")]
+use {super::super::conv::syscall_ret_owned_fd, crate::process::PidfdFlags};
+#[cfg(any(target_os = "android", target_os = "linux"))]
+use {
+ super::super::offset::libc_prlimit,
+ crate::process::{Cpuid, MembarrierCommand, MembarrierQuery},
+};
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
use {
- super::super::conv::ret_infallible,
super::super::offset::{libc_getrlimit, libc_rlimit, libc_setrlimit, LIBC_RLIM_INFINITY},
crate::process::{Resource, Rlimit},
core::convert::TryInto,
};
-#[cfg(any(target_os = "android", target_os = "linux"))]
-use {
- super::super::offset::libc_prlimit,
- crate::process::{Cpuid, MembarrierCommand, MembarrierQuery},
-};
#[cfg(not(target_os = "wasi"))]
use {
super::types::RawUname,
@@ -214,11 +221,19 @@ pub(crate) fn sched_yield() {
pub(crate) fn uname() -> RawUname {
let mut uname = MaybeUninit::<RawUname>::uninit();
unsafe {
- ret(c::uname(uname.as_mut_ptr())).unwrap();
+ ret_infallible(c::uname(uname.as_mut_ptr()));
uname.assume_init()
}
}
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "fs")]
+#[inline]
+pub(crate) fn umask(mask: Mode) -> Mode {
+ // TODO: Use `from_bits_retain` when we switch to bitflags 2.0.
+ unsafe { Mode::from_bits_truncate(c::umask(mask.bits() as _) as _) }
+}
+
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
#[inline]
pub(crate) fn nice(inc: i32) -> io::Result<i32> {
@@ -394,6 +409,85 @@ pub(crate) fn _waitpid(
}
}
+#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
+#[inline]
+pub(crate) fn waitid(id: WaitId<'_>, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ // Get the id to wait on.
+ match id {
+ WaitId::All => _waitid_all(options),
+ WaitId::Pid(pid) => _waitid_pid(pid, options),
+ #[cfg(target_os = "linux")]
+ WaitId::PidFd(fd) => _waitid_pidfd(fd, options),
+ #[cfg(not(target_os = "linux"))]
+ WaitId::__EatLifetime(_) => unreachable!(),
+ }
+}
+
+#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
+#[inline]
+fn _waitid_all(options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(c::waitid(
+ c::P_ALL,
+ 0,
+ status.as_mut_ptr(),
+ options.bits() as _,
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
+#[inline]
+fn _waitid_pid(pid: Pid, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(c::waitid(
+ c::P_PID,
+ Pid::as_raw(Some(pid)) as _,
+ status.as_mut_ptr(),
+ options.bits() as _,
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+#[cfg(target_os = "linux")]
+#[inline]
+fn _waitid_pidfd(fd: BorrowedFd<'_>, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(c::waitid(
+ c::P_PIDFD,
+ fd.as_raw_fd() as _,
+ status.as_mut_ptr(),
+ options.bits() as _,
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+/// Convert a `siginfo_t` to a `WaitidStatus`.
+///
+/// # Safety
+///
+/// The caller must ensure that `status` is initialized and that `waitid`
+/// returned successfully.
+#[cfg(not(any(target_os = "wasi", target_os = "redox", target_os = "openbsd")))]
+#[inline]
+unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitidStatus> {
+ let status = status.assume_init();
+ if status.si_signo == 0 {
+ None
+ } else {
+ Some(WaitidStatus(status))
+ }
+}
+
#[inline]
pub(crate) fn exit_group(code: c::c_int) -> ! {
// `_exit` and `_Exit` are the same; it's just a matter of which ones
@@ -453,7 +547,7 @@ pub(crate) unsafe fn prctl(
ret_c_int(c::prctl(option, arg2, arg3, arg4, arg5))
}
-#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+#[cfg(freebsdlike)]
#[inline]
pub(crate) unsafe fn procctl(
idtype: c::idtype_t,
@@ -463,3 +557,14 @@ pub(crate) unsafe fn procctl(
) -> io::Result<()> {
ret(c::procctl(idtype, id, option, data))
}
+
+#[cfg(target_os = "linux")]
+pub(crate) fn pidfd_open(pid: Pid, flags: PidfdFlags) -> io::Result<OwnedFd> {
+ unsafe {
+ syscall_ret_owned_fd(libc::syscall(
+ c::SYS_pidfd_open,
+ pid.as_raw_nonzero().get(),
+ flags.bits(),
+ ))
+ }
+}
diff --git a/vendor/rustix/src/backend/libc/process/types.rs b/vendor/rustix/src/backend/libc/process/types.rs
index f8e3b8bf4..203186b20 100644
--- a/vendor/rustix/src/backend/libc/process/types.rs
+++ b/vendor/rustix/src/backend/libc/process/types.rs
@@ -57,119 +57,47 @@ pub enum Resource {
#[cfg(not(target_os = "haiku"))]
Core = c::RLIMIT_CORE as c::c_int,
/// `RLIMIT_RSS`
- #[cfg(not(any(
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(apple, solarish, target_os = "haiku")))]
Rss = c::RLIMIT_RSS as c::c_int,
/// `RLIMIT_NPROC`
- #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ #[cfg(not(any(solarish, target_os = "haiku")))]
Nproc = c::RLIMIT_NPROC as c::c_int,
/// `RLIMIT_NOFILE`
Nofile = c::RLIMIT_NOFILE as c::c_int,
/// `RLIMIT_MEMLOCK`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "solaris"
- )))]
+ #[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
Memlock = c::RLIMIT_MEMLOCK as c::c_int,
/// `RLIMIT_AS`
#[cfg(not(target_os = "openbsd"))]
As = c::RLIMIT_AS as c::c_int,
/// `RLIMIT_LOCKS`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
Locks = c::RLIMIT_LOCKS as c::c_int,
/// `RLIMIT_SIGPENDING`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
Sigpending = c::RLIMIT_SIGPENDING as c::c_int,
/// `RLIMIT_MSGQUEUE`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
Msgqueue = c::RLIMIT_MSGQUEUE as c::c_int,
/// `RLIMIT_NICE`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
Nice = c::RLIMIT_NICE as c::c_int,
/// `RLIMIT_RTPRIO`
- #[cfg(not(any(
- target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
Rtprio = c::RLIMIT_RTPRIO as c::c_int,
/// `RLIMIT_RTTIME`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "aix",
target_os = "android",
- target_os = "dragonfly",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
)))]
Rttime = c::RLIMIT_RTTIME as c::c_int,
}
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
impl Resource {
/// `RLIMIT_RSS`
#[allow(non_upper_case_globals)]
@@ -221,16 +149,10 @@ pub enum Signal {
Term = c::SIGTERM,
/// `SIGSTKFLT`
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
all(
any(target_os = "android", target_os = "linux"),
any(
@@ -273,20 +195,25 @@ pub enum Signal {
#[cfg(not(target_os = "haiku"))]
Io = c::SIGIO,
/// `SIGPWR`
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
#[doc(alias = "Pwr")]
Power = c::SIGPWR,
/// `SIGSYS`, aka `SIGUNUSED`
#[doc(alias = "Unused")]
Sys = c::SIGSYS,
+ /// `SIGEMT`
+ #[cfg(bsd)]
+ Emt = c::SIGEMT,
+ /// `SIGINFO`
+ #[cfg(bsd)]
+ Info = c::SIGINFO,
+ /// `SIGTHR`
+ #[cfg(target_os = "freebsd")]
+ #[doc(alias = "Lwp")]
+ Thr = c::SIGTHR,
+ /// `SIGLIBRT`
+ #[cfg(target_os = "freebsd")]
+ Librt = c::SIGLIBRT,
}
#[cfg(not(target_os = "wasi"))]
@@ -310,16 +237,10 @@ impl Signal {
c::SIGALRM => Some(Self::Alarm),
c::SIGTERM => Some(Self::Term),
#[cfg(not(any(
+ bsd,
+ solarish,
target_os = "aix",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
all(
any(target_os = "android", target_os = "linux"),
any(
@@ -345,17 +266,17 @@ impl Signal {
c::SIGWINCH => Some(Self::Winch),
#[cfg(not(target_os = "haiku"))]
c::SIGIO => Some(Self::Io),
- #[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- )))]
+ #[cfg(not(any(bsd, target_os = "haiku")))]
c::SIGPWR => Some(Self::Power),
c::SIGSYS => Some(Self::Sys),
+ #[cfg(bsd)]
+ c::SIGEMT => Some(Self::Emt),
+ #[cfg(bsd)]
+ c::SIGINFO => Some(Self::Info),
+ #[cfg(target_os = "freebsd")]
+ c::SIGTHR => Some(Self::Thr),
+ #[cfg(target_os = "freebsd")]
+ c::SIGLIBRT => Some(Self::Librt),
_ => None,
}
}
diff --git a/vendor/rustix/src/backend/libc/process/wait.rs b/vendor/rustix/src/backend/libc/process/wait.rs
index 6de79955d..c09ee1002 100644
--- a/vendor/rustix/src/backend/libc/process/wait.rs
+++ b/vendor/rustix/src/backend/libc/process/wait.rs
@@ -4,3 +4,6 @@ pub(crate) use c::{
WCONTINUED, WEXITSTATUS, WIFCONTINUED, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG,
WTERMSIG, WUNTRACED,
};
+
+#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "wasi")))]
+pub(crate) use c::{WEXITED, WNOWAIT, WSTOPPED};
diff --git a/vendor/rustix/src/backend/libc/rand/syscalls.rs b/vendor/rustix/src/backend/libc/rand/syscalls.rs
index 1c4286235..ce1746055 100644
--- a/vendor/rustix/src/backend/libc/rand/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/rand/syscalls.rs
@@ -1,9 +1,9 @@
//! libc syscalls supporting `rustix::rand`.
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
use {super::super::c, super::super::conv::ret_ssize_t, crate::io, crate::rand::GetRandomFlags};
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
pub(crate) fn getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize> {
// `getrandom` wasn't supported in glibc until 2.25.
weak_or_syscall! {
diff --git a/vendor/rustix/src/backend/libc/rand/types.rs b/vendor/rustix/src/backend/libc/rand/types.rs
index 2ba3f1119..e12bd9cbd 100644
--- a/vendor/rustix/src/backend/libc/rand/types.rs
+++ b/vendor/rustix/src/backend/libc/rand/types.rs
@@ -1,9 +1,9 @@
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
use super::super::c;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
use bitflags::bitflags;
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
/// `GRND_*` flags for use with [`getrandom`].
///
diff --git a/vendor/rustix/src/backend/libc/termios/syscalls.rs b/vendor/rustix/src/backend/libc/termios/syscalls.rs
index f54e9a6f3..097d368ed 100644
--- a/vendor/rustix/src/backend/libc/termios/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/termios/syscalls.rs
@@ -27,6 +27,27 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
}
}
+#[cfg(all(
+ any(target_os = "android", target_os = "linux"),
+ any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+ )
+))]
+pub(crate) fn tcgetattr2(fd: BorrowedFd<'_>) -> io::Result<crate::termios::Termios2> {
+ let mut result = MaybeUninit::<crate::termios::Termios2>::uninit();
+ unsafe {
+ ret(c::ioctl(borrowed_fd(fd), c::TCGETS2, result.as_mut_ptr()))?;
+ Ok(result.assume_init())
+ }
+}
+
#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
unsafe {
@@ -56,6 +77,33 @@ pub(crate) fn tcsetattr(
}
}
+#[cfg(all(
+ any(target_os = "android", target_os = "linux"),
+ any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+ )
+))]
+pub(crate) fn tcsetattr2(
+ fd: BorrowedFd,
+ optional_actions: OptionalActions,
+ termios: &crate::termios::Termios2,
+) -> io::Result<()> {
+ unsafe {
+ ret(c::ioctl(
+ borrowed_fd(fd),
+ (c::TCSETS2 as u32 + optional_actions as u32) as _,
+ termios,
+ ))
+ }
+}
+
#[cfg(not(target_os = "wasi"))]
pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(c::tcsendbreak(borrowed_fd(fd), 0)) }
diff --git a/vendor/rustix/src/backend/libc/termios/types.rs b/vendor/rustix/src/backend/libc/termios/types.rs
index 6dda70064..bbacdbea0 100644
--- a/vendor/rustix/src/backend/libc/termios/types.rs
+++ b/vendor/rustix/src/backend/libc/termios/types.rs
@@ -7,13 +7,16 @@ use super::super::c;
#[repr(i32)]
pub enum OptionalActions {
/// `TCSANOW`—Make the change immediately.
+ #[doc(alias = "TCSANOW")]
Now = c::TCSANOW,
/// `TCSADRAIN`—Make the change after all output has been transmitted.
+ #[doc(alias = "TCSADRAIN")]
Drain = c::TCSADRAIN,
/// `TCSAFLUSH`—Discard any pending input and then make the change
/// after all output has been transmitted.
+ #[doc(alias = "TCSAFLUSH")]
Flush = c::TCSAFLUSH,
}
@@ -24,12 +27,15 @@ pub enum OptionalActions {
#[repr(i32)]
pub enum QueueSelector {
/// `TCIFLUSH`—Flush data received but not read.
+ #[doc(alias = "TCIFLUSH")]
IFlush = c::TCIFLUSH,
/// `TCOFLUSH`—Flush data written but not transmitted.
+ #[doc(alias = "TCOFLUSH")]
OFlush = c::TCOFLUSH,
/// `TCIOFLUSH`—`IFlush` and `OFlush` combined.
+ #[doc(alias = "TCIOFLUSH")]
IOFlush = c::TCIOFLUSH,
}
@@ -40,34 +46,63 @@ pub enum QueueSelector {
#[repr(i32)]
pub enum Action {
/// `TCOOFF`—Suspend output.
+ #[doc(alias = "TCOOFF")]
OOff = c::TCOOFF,
/// `TCOON`—Restart suspended output.
+ #[doc(alias = "TCOON")]
OOn = c::TCOON,
/// `TCIOFF`—Transmits a STOP byte.
+ #[doc(alias = "TCIOFF")]
IOff = c::TCIOFF,
/// `TCION`—Transmits a START byte.
+ #[doc(alias = "TCION")]
IOn = c::TCION,
}
-/// `struct termios` for use with [`tcgetattr`].
+/// `struct termios` for use with [`tcgetattr`] and [`tcsetattr`].
///
/// [`tcgetattr`]: crate::termios::tcgetattr
+/// [`tcsetattr`]: crate::termios::tcsetattr
+#[doc(alias = "termios")]
pub type Termios = c::termios;
+/// `struct termios2` for use with [`tcgetattr2`] and [`tcsetattr2`].
+///
+/// [`tcgetattr2`]: crate::termios::tcgetattr2
+/// [`tcsetattr2`]: crate::termios::tcsetattr2
+#[cfg(all(
+ any(target_os = "android", target_os = "linux"),
+ any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+ )
+))]
+#[doc(alias = "termios2")]
+pub type Termios2 = c::termios2;
+
/// `struct winsize` for use with [`tcgetwinsize`].
///
/// [`tcgetwinsize`]: crate::termios::tcgetwinsize
+#[doc(alias = "winsize")]
pub type Winsize = c::winsize;
/// `tcflag_t`—A type for the flags fields of [`Termios`].
+#[doc(alias = "tcflag_t")]
pub type Tcflag = c::tcflag_t;
/// `speed_t`—A return type for [`cfsetspeed`] and similar.
///
/// [`cfsetspeed`]: crate::termios::cfsetspeed
+#[doc(alias = "speed_t")]
pub type Speed = c::speed_t;
/// `VINTR`
@@ -93,15 +128,14 @@ pub const VMIN: usize = c::VMIN as usize;
/// `VSWTC`
#[cfg(not(any(
+ apple,
+ solarish,
+ target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
- target_os = "solaris",
)))]
pub const VSWTC: usize = c::VSWTC as usize;
@@ -122,11 +156,11 @@ pub const VEOL: usize = c::VEOL as usize;
pub const VREPRINT: usize = c::VREPRINT as usize;
/// `VDISCARD`
-#[cfg(not(target_os = "haiku"))]
+#[cfg(not(any(target_os = "aix", target_os = "haiku")))]
pub const VDISCARD: usize = c::VDISCARD as usize;
/// `VWERASE`
-#[cfg(not(target_os = "haiku"))]
+#[cfg(not(any(target_os = "aix", target_os = "haiku")))]
pub const VWERASE: usize = c::VWERASE as usize;
/// `VLNEXT`
@@ -137,473 +171,276 @@ pub const VLNEXT: usize = c::VLNEXT as usize;
pub const VEOL2: usize = c::VEOL2 as usize;
/// `IGNBRK`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IGNBRK: c::c_uint = c::IGNBRK;
/// `BRKINT`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const BRKINT: c::c_uint = c::BRKINT;
/// `IGNPAR`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IGNPAR: c::c_uint = c::IGNPAR;
/// `PARMRK`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const PARMRK: c::c_uint = c::PARMRK;
/// `INPCK`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const INPCK: c::c_uint = c::INPCK;
/// `ISTRIP`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ISTRIP: c::c_uint = c::ISTRIP;
/// `INLCR`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const INLCR: c::c_uint = c::INLCR;
/// `IGNCR`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IGNCR: c::c_uint = c::IGNCR;
/// `ICRNL`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ICRNL: c::c_uint = c::ICRNL;
/// `IUCLC`
-#[cfg(any(target_os = "haiku", target_os = "illumos", target_os = "solaris"))]
+#[cfg(any(solarish, target_os = "haiku"))]
pub const IUCLC: c::c_uint = c::IUCLC;
/// `IXON`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IXON: c::c_uint = c::IXON;
/// `IXANY`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const IXANY: c::c_uint = c::IXANY;
/// `IXOFF`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IXOFF: c::c_uint = c::IXOFF;
/// `IMAXBEL`
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "redox"
-)))]
+#[cfg(not(any(apple, target_os = "haiku", target_os = "redox")))]
pub const IMAXBEL: c::c_uint = c::IMAXBEL;
/// `IUTF8`
#[cfg(not(any(
+ apple,
+ solarish,
+ target_os = "aix",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const IUTF8: c::c_uint = c::IUTF8;
/// `OPOST`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const OPOST: c::c_uint = c::OPOST;
/// `OLCUC`
#[cfg(not(any(
+ apple,
+ target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
target_os = "netbsd",
target_os = "redox",
)))]
pub const OLCUC: c::c_uint = c::OLCUC;
/// `ONLCR`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ONLCR: c::c_uint = c::ONLCR;
/// `OCRNL`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const OCRNL: c::c_uint = c::OCRNL;
/// `ONOCR`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ONOCR: c::c_uint = c::ONOCR;
/// `ONLRET`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ONLRET: c::c_uint = c::ONLRET;
/// `OFILL`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
-)))]
+#[cfg(not(bsd))]
pub const OFILL: c::c_uint = c::OFILL;
/// `OFDEL`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
-)))]
+#[cfg(not(bsd))]
pub const OFDEL: c::c_uint = c::OFDEL;
/// `NLDLY`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "redox")))]
pub const NLDLY: c::c_uint = c::NLDLY;
/// `NL0`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const NL0: c::c_uint = c::NL0;
/// `NL1`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const NL1: c::c_uint = c::NL1;
/// `CRDLY`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "redox")))]
pub const CRDLY: c::c_uint = c::CRDLY;
/// `CR0`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const CR0: c::c_uint = c::CR0;
/// `CR1`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const CR1: c::c_uint = c::CR1;
/// `CR2`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const CR2: c::c_uint = c::CR2;
/// `CR3`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const CR3: c::c_uint = c::CR3;
/// `TABDLY`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "illumos",
target_os = "redox",
- target_os = "solaris",
)))]
pub const TABDLY: c::c_uint = c::TABDLY;
/// `TAB0`
#[cfg(not(any(
+ apple,
+ netbsdlike,
+ solarish,
target_os = "dragonfly",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const TAB0: c::c_uint = c::TAB0;
/// `TAB1`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const TAB1: c::c_uint = c::TAB1;
/// `TAB2`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const TAB2: c::c_uint = c::TAB2;
/// `TAB3`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const TAB3: c::c_uint = c::TAB3;
/// `BSDLY`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "redox")))]
pub const BSDLY: c::c_uint = c::BSDLY;
/// `BS0`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const BS0: c::c_uint = c::BS0;
/// `BS1`
#[cfg(not(any(
target_env = "musl",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "dragonfly",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const BS1: c::c_uint = c::BS1;
/// `FFDLY`
-#[cfg(not(any(
- target_env = "musl",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(target_env = "musl", bsd, solarish, target_os = "redox")))]
pub const FFDLY: c::c_uint = c::FFDLY;
/// `FF0`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const FF0: c::c_uint = c::FF0;
/// `FF1`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const FF1: c::c_uint = c::FF1;
/// `VTDLY`
-#[cfg(not(any(
- target_env = "musl",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(target_env = "musl", bsd, solarish, target_os = "redox")))]
pub const VTDLY: c::c_uint = c::VTDLY;
/// `VT0`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "fuchsia", target_os = "redox")))]
pub const VT0: c::c_uint = c::VT0;
/// `VT1`
#[cfg(not(any(
target_env = "musl",
- target_os = "dragonfly",
+ bsd,
+ solarish,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "fuchsia",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const VT1: c::c_uint = c::VT1;
@@ -656,125 +493,68 @@ pub const B19200: Speed = c::B19200;
pub const B38400: Speed = c::B38400;
/// `B57600`
+#[cfg(not(target_os = "aix"))]
pub const B57600: Speed = c::B57600;
/// `B115200`
+#[cfg(not(target_os = "aix"))]
pub const B115200: Speed = c::B115200;
/// `B230400`
+#[cfg(not(target_os = "aix"))]
pub const B230400: Speed = c::B230400;
/// `B460800`
#[cfg(not(any(
+ apple,
+ target_os = "aix",
target_os = "dragonfly",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd"
)))]
pub const B460800: Speed = c::B460800;
/// `B500000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
pub const B500000: Speed = c::B500000;
/// `B576000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, solarish, target_os = "aix", target_os = "haiku")))]
pub const B576000: Speed = c::B576000;
/// `B921600`
#[cfg(not(any(
+ apple,
+ target_os = "aix",
target_os = "dragonfly",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd"
)))]
pub const B921600: Speed = c::B921600;
/// `B1000000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
pub const B1000000: Speed = c::B1000000;
/// `B1152000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
pub const B1152000: Speed = c::B1152000;
/// `B1500000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
pub const B1500000: Speed = c::B1500000;
/// `B2000000`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
-)))]
+#[cfg(not(any(bsd, target_os = "aix", target_os = "haiku", target_os = "solaris")))]
pub const B2000000: Speed = c::B2000000;
/// `B2500000`
#[cfg(not(any(
target_arch = "sparc",
target_arch = "sparc64",
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ target_os = "aix",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "solaris",
)))]
pub const B2500000: Speed = c::B2500000;
@@ -783,13 +563,9 @@ pub const B2500000: Speed = c::B2500000;
#[cfg(not(any(
target_arch = "sparc",
target_arch = "sparc64",
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ target_os = "aix",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "solaris",
)))]
pub const B3000000: Speed = c::B3000000;
@@ -798,13 +574,9 @@ pub const B3000000: Speed = c::B3000000;
#[cfg(not(any(
target_arch = "sparc",
target_arch = "sparc64",
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ target_os = "aix",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "solaris",
)))]
pub const B3500000: Speed = c::B3500000;
@@ -813,63 +585,63 @@ pub const B3500000: Speed = c::B3500000;
#[cfg(not(any(
target_arch = "sparc",
target_arch = "sparc64",
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ target_os = "aix",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "solaris",
)))]
pub const B4000000: Speed = c::B4000000;
+/// `BOTHER`
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub const BOTHER: c::c_uint = c::BOTHER;
+
/// `CSIZE`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CSIZE: c::c_uint = c::CSIZE;
/// `CS5`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CS5: c::c_uint = c::CS5;
/// `CS6`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CS6: c::c_uint = c::CS6;
/// `CS7`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CS7: c::c_uint = c::CS7;
/// `CS8`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CS8: c::c_uint = c::CS8;
/// `CSTOPB`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CSTOPB: c::c_uint = c::CSTOPB;
/// `CREAD`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CREAD: c::c_uint = c::CREAD;
/// `PARENB`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const PARENB: c::c_uint = c::PARENB;
/// `PARODD`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const PARODD: c::c_uint = c::PARODD;
/// `HUPCL`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const HUPCL: c::c_uint = c::HUPCL;
/// `CLOCAL`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const CLOCAL: c::c_uint = c::CLOCAL;
/// `ISIG`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ISIG: c::c_uint = c::ISIG;
/// `ICANON`—A flag for the `c_lflag` field of [`Termios`] indicating
@@ -877,98 +649,75 @@ pub const ISIG: c::c_uint = c::ISIG;
pub const ICANON: Tcflag = c::ICANON;
/// `ECHO`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ECHO: c::c_uint = c::ECHO;
/// `ECHOE`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ECHOE: c::c_uint = c::ECHOE;
/// `ECHOK`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ECHOK: c::c_uint = c::ECHOK;
/// `ECHONL`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const ECHONL: c::c_uint = c::ECHONL;
/// `NOFLSH`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const NOFLSH: c::c_uint = c::NOFLSH;
/// `TOSTOP`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const TOSTOP: c::c_uint = c::TOSTOP;
/// `IEXTEN`
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(not(apple))]
pub const IEXTEN: c::c_uint = c::IEXTEN;
/// `EXTA`
#[cfg(not(any(
+ apple,
+ solarish,
target_os = "emscripten",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
- target_os = "solaris",
)))]
pub const EXTA: c::c_uint = c::EXTA;
/// `EXTB`
#[cfg(not(any(
+ apple,
+ solarish,
target_os = "emscripten",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
target_os = "redox",
- target_os = "solaris",
)))]
pub const EXTB: c::c_uint = c::EXTB;
/// `CBAUD`
-#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
-)))]
+#[cfg(not(any(bsd, target_os = "haiku", target_os = "redox")))]
pub const CBAUD: c::c_uint = c::CBAUD;
/// `CBAUDEX`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
+ target_os = "aix",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const CBAUDEX: c::c_uint = c::CBAUDEX;
/// `CIBAUD`
#[cfg(not(any(
- target_os = "dragonfly",
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ bsd,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_arch = "powerpc",
- target_arch = "powerpc64",
)))]
pub const CIBAUD: c::tcflag_t = c::CIBAUD;
@@ -979,22 +728,17 @@ pub const CIBAUD: c::tcflag_t = 0o77600000;
/// `CMSPAR`
#[cfg(not(any(
- target_os = "dragonfly",
+ bsd,
+ solarish,
+ target_os = "aix",
target_os = "emscripten",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const CMSPAR: c::c_uint = c::CMSPAR;
/// `CRTSCTS`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "aix", target_os = "redox")))]
pub const CRTSCTS: c::c_uint = c::CRTSCTS;
/// `XCASE`
@@ -1002,45 +746,35 @@ pub const CRTSCTS: c::c_uint = c::CRTSCTS;
pub const XCASE: c::c_uint = c::XCASE;
/// `ECHOCTL`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const ECHOCTL: c::c_uint = c::ECHOCTL;
/// `ECHOPRT`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const ECHOPRT: c::c_uint = c::ECHOPRT;
/// `ECHOKE`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const ECHOKE: c::c_uint = c::ECHOKE;
/// `FLUSHO`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const FLUSHO: c::c_uint = c::FLUSHO;
/// `PENDIN`
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
+#[cfg(not(any(apple, target_os = "redox")))]
pub const PENDIN: c::c_uint = c::PENDIN;
/// `EXTPROC`
-#[cfg(not(any(
- target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
- target_os = "redox"
-)))]
+#[cfg(not(any(apple, target_os = "aix", target_os = "haiku", target_os = "redox")))]
pub const EXTPROC: c::c_uint = c::EXTPROC;
/// `XTABS`
#[cfg(not(any(
- target_os = "dragonfly",
- target_os = "freebsd",
+ bsd,
+ solarish,
+ target_os = "aix",
target_os = "haiku",
- target_os = "illumos",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd",
target_os = "redox",
- target_os = "solaris",
)))]
pub const XTABS: c::c_uint = c::XTABS;
diff --git a/vendor/rustix/src/backend/libc/thread/syscalls.rs b/vendor/rustix/src/backend/libc/thread/syscalls.rs
index 4f69b8f63..adf4bb700 100644
--- a/vendor/rustix/src/backend/libc/thread/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/thread/syscalls.rs
@@ -3,7 +3,7 @@
use super::super::c;
use super::super::conv::ret;
#[cfg(any(target_os = "android", target_os = "linux"))]
-use super::super::conv::{borrowed_fd, ret_c_int};
+use super::super::conv::{borrowed_fd, ret_c_int, syscall_ret};
use super::super::time::types::LibcTimespec;
#[cfg(any(target_os = "android", target_os = "linux"))]
use crate::fd::BorrowedFd;
@@ -14,12 +14,10 @@ use crate::process::{Pid, RawNonZeroPid};
use crate::thread::{NanosleepRelativeResult, Timespec};
use core::mem::MaybeUninit;
#[cfg(not(any(
- target_os = "dragonfly",
+ apple,
+ freebsdlike,
target_os = "emscripten",
- target_os = "freebsd",
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
@@ -38,12 +36,11 @@ weak!(fn __clock_nanosleep_time64(c::clockid_t, c::c_int, *const LibcTimespec, *
weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int);
#[cfg(not(any(
+ apple,
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
@@ -132,12 +129,11 @@ unsafe fn clock_nanosleep_relative_old(id: ClockId, request: &Timespec) -> Nanos
}
#[cfg(not(any(
+ apple,
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "haiku",
- target_os = "ios",
- target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
@@ -291,7 +287,13 @@ pub(crate) fn gettid() -> Pid {
#[cfg(any(target_os = "android", target_os = "linux"))]
#[inline]
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)) }
+ // `setns` wasn't supported in glibc until 2.14, and musl until 0.9.5,
+ // so use `syscall`.
+ weak_or_syscall! {
+ fn setns(fd: c::c_int, nstype: c::c_int) via SYS_setns -> c::c_int
+ }
+
+ unsafe { ret_c_int(setns(borrowed_fd(fd), nstype)) }
}
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -299,3 +301,63 @@ pub(crate) fn setns(fd: BorrowedFd, nstype: c::c_int) -> io::Result<c::c_int> {
pub(crate) fn unshare(flags: crate::thread::UnshareFlags) -> io::Result<()> {
unsafe { ret(c::unshare(flags.bits() as i32)) }
}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn capget(
+ header: &mut linux_raw_sys::general::__user_cap_header_struct,
+ data: &mut [MaybeUninit<linux_raw_sys::general::__user_cap_data_struct>],
+) -> io::Result<()> {
+ let header: *mut _ = header;
+ unsafe { syscall_ret(c::syscall(c::SYS_capget, header, data.as_mut_ptr())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn capset(
+ header: &mut linux_raw_sys::general::__user_cap_header_struct,
+ data: &[linux_raw_sys::general::__user_cap_data_struct],
+) -> io::Result<()> {
+ let header: *mut _ = header;
+ unsafe { syscall_ret(c::syscall(c::SYS_capset, header, data.as_ptr())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn setuid_thread(uid: crate::process::Uid) -> io::Result<()> {
+ unsafe { syscall_ret(c::syscall(c::SYS_setuid, uid.as_raw())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn setresuid_thread(
+ ruid: crate::process::Uid,
+ euid: crate::process::Uid,
+ suid: crate::process::Uid,
+) -> io::Result<()> {
+ #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc"))]
+ const SYS: c::c_long = c::SYS_setresuid32 as c::c_long;
+ #[cfg(not(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc")))]
+ const SYS: c::c_long = c::SYS_setresuid as c::c_long;
+ unsafe { syscall_ret(c::syscall(SYS, ruid.as_raw(), euid.as_raw(), suid.as_raw())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn setgid_thread(gid: crate::process::Gid) -> io::Result<()> {
+ unsafe { syscall_ret(c::syscall(c::SYS_setgid, gid.as_raw())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn setresgid_thread(
+ rgid: crate::process::Gid,
+ egid: crate::process::Gid,
+ sgid: crate::process::Gid,
+) -> io::Result<()> {
+ #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc"))]
+ const SYS: c::c_long = c::SYS_setresgid32 as c::c_long;
+ #[cfg(not(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc")))]
+ const SYS: c::c_long = c::SYS_setresgid as c::c_long;
+ unsafe { syscall_ret(c::syscall(SYS, rgid.as_raw(), egid.as_raw(), sgid.as_raw())) }
+}
diff --git a/vendor/rustix/src/backend/libc/time/syscalls.rs b/vendor/rustix/src/backend/libc/time/syscalls.rs
index c9e075e53..9d341d886 100644
--- a/vendor/rustix/src/backend/libc/time/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/time/syscalls.rs
@@ -28,6 +28,11 @@ weak!(fn __clock_gettime64(c::clockid_t, *mut LibcTimespec) -> c::c_int);
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
+weak!(fn __clock_settime64(c::clockid_t, *const LibcTimespec) -> c::c_int);
+#[cfg(all(
+ any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
+ target_env = "gnu",
+))]
weak!(fn __clock_getres64(c::clockid_t, *mut LibcTimespec) -> c::c_int);
#[cfg(all(
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
@@ -232,6 +237,59 @@ unsafe fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
})
}
+#[cfg(not(any(
+ target_os = "redox",
+ target_os = "wasi",
+ all(apple, not(target_os = "macos"))
+)))]
+#[inline]
+pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
+ #[cfg(all(
+ any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
+ target_env = "gnu",
+ ))]
+ unsafe {
+ if let Some(libc_clock_settime) = __clock_settime64.get() {
+ let mut new_timespec = core::mem::zeroed::<LibcTimespec>();
+ new_timespec.tv_sec = timespec.tv_sec;
+ new_timespec.tv_nsec = timespec.tv_nsec as _;
+ ret(libc_clock_settime(id as c::clockid_t, &new_timespec))
+ } else {
+ clock_settime_old(id, timespec)
+ }
+ }
+
+ #[cfg(not(all(
+ any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
+ target_env = "gnu",
+ )))]
+ unsafe {
+ ret(c::clock_settime(id as c::clockid_t, &timespec))
+ }
+}
+
+#[cfg(not(any(
+ target_os = "redox",
+ target_os = "wasi",
+ all(apple, not(target_os = "macos"))
+)))]
+#[cfg(all(
+ any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
+ target_env = "gnu",
+))]
+#[must_use]
+unsafe fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
+ use core::convert::TryInto;
+ let old_timespec = c::timespec {
+ tv_sec: timespec
+ .tv_sec
+ .try_into()
+ .map_err(|_| io::Errno::OVERFLOW)?,
+ tv_nsec: timespec.tv_nsec as _,
+ };
+ ret(c::clock_settime(id as c::clockid_t, &old_timespec))
+}
+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
#[cfg(feature = "time")]
pub(crate) fn timerfd_create(id: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
diff --git a/vendor/rustix/src/backend/libc/time/types.rs b/vendor/rustix/src/backend/libc/time/types.rs
index 080f64431..47cd85701 100644
--- a/vendor/rustix/src/backend/libc/time/types.rs
+++ b/vendor/rustix/src/backend/libc/time/types.rs
@@ -16,7 +16,7 @@ pub type Timespec = c::timespec;
any(target_arch = "arm", target_arch = "mips", target_arch = "x86"),
target_env = "gnu",
))]
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct Timespec {
/// Seconds.
@@ -114,7 +114,7 @@ impl From<Timespec> for LibcTimespec {
/// all of them are always supported.
///
/// [`clock_gettime`]: crate::time::clock_gettime
-#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
+#[cfg(not(any(apple, target_os = "wasi")))]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(not(target_os = "dragonfly"), repr(i32))]
#[cfg_attr(target_os = "dragonfly", repr(u64))]
@@ -126,32 +126,24 @@ pub enum ClockId {
/// `CLOCK_MONOTONIC`
Monotonic = c::CLOCK_MONOTONIC,
+ /// `CLOCK_UPTIME`
+ #[cfg(any(freebsdlike))]
+ Uptime = c::CLOCK_UPTIME,
+
/// `CLOCK_PROCESS_CPUTIME_ID`
- #[cfg(not(any(
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(netbsdlike, solarish, target_os = "redox")))]
ProcessCPUTime = c::CLOCK_PROCESS_CPUTIME_ID,
/// `CLOCK_THREAD_CPUTIME_ID`
- #[cfg(not(any(
- target_os = "illumos",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "redox",
- target_os = "solaris",
- )))]
+ #[cfg(not(any(netbsdlike, solarish, target_os = "redox")))]
ThreadCPUTime = c::CLOCK_THREAD_CPUTIME_ID,
/// `CLOCK_REALTIME_COARSE`
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))]
RealtimeCoarse = c::CLOCK_REALTIME_COARSE,
/// `CLOCK_MONOTONIC_COARSE`
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))]
MonotonicCoarse = c::CLOCK_MONOTONIC_COARSE,
/// `CLOCK_MONOTONIC_RAW`
@@ -165,7 +157,7 @@ pub enum ClockId {
/// has to fail with `INVAL` due to an unsupported clock. See
/// [`DynamicClockId`] for a greater set of clocks, with the caveat that not
/// all of them are always supported.
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(apple)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(u32)]
#[non_exhaustive]
@@ -312,7 +304,7 @@ bitflags! {
/// `TFD_TIMER_CANCEL_ON_SET`
#[cfg(any(target_os = "android", target_os = "linux"))]
- const CANCEL_ON_SET = 2; // TODO: upstream TFD_TIMER_CANCEL_ON_SET
+ const CANCEL_ON_SET = c::TFD_TIMER_CANCEL_ON_SET;
}
}
diff --git a/vendor/rustix/src/backend/libc/weak.rs b/vendor/rustix/src/backend/libc/weak.rs
index d578038cd..b7f185da3 100644
--- a/vendor/rustix/src/backend/libc/weak.rs
+++ b/vendor/rustix/src/backend/libc/weak.rs
@@ -111,7 +111,7 @@ unsafe fn fetch(name: &str) -> *mut c_void {
Ok(c_str) => c_str,
Err(..) => return null_mut(),
};
- libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr().cast())
+ libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr())
}
#[cfg(not(any(target_os = "android", target_os = "linux")))]
diff --git a/vendor/rustix/src/backend/libc/winsock_c.rs b/vendor/rustix/src/backend/libc/winsock_c.rs
index 7d78aef65..521a7bbb1 100644
--- a/vendor/rustix/src/backend/libc/winsock_c.rs
+++ b/vendor/rustix/src/backend/libc/winsock_c.rs
@@ -24,6 +24,7 @@ pub(crate) const SO_LINGER: i32 = WinSock::SO_LINGER as _;
pub(crate) const SOL_SOCKET: i32 = WinSock::SOL_SOCKET as _;
pub(crate) const SO_RCVTIMEO: i32 = WinSock::SO_RCVTIMEO as _;
pub(crate) const SO_SNDTIMEO: i32 = WinSock::SO_SNDTIMEO as _;
+pub(crate) const SO_ERROR: i32 = WinSock::SO_ERROR as _;
pub(crate) const IP_TTL: i32 = WinSock::IP_TTL as _;
pub(crate) const TCP_NODELAY: i32 = WinSock::TCP_NODELAY as _;
pub(crate) const IP_ADD_MEMBERSHIP: i32 = WinSock::IP_ADD_MEMBERSHIP as _;
diff --git a/vendor/rustix/src/backend/linux_raw/c.rs b/vendor/rustix/src/backend/linux_raw/c.rs
index a6f0b8ff6..e7263305a 100644
--- a/vendor/rustix/src/backend/linux_raw/c.rs
+++ b/vendor/rustix/src/backend/linux_raw/c.rs
@@ -9,21 +9,23 @@ pub(crate) use linux_raw_sys::ctypes::*;
pub(crate) use linux_raw_sys::errno::EINVAL;
pub(crate) use linux_raw_sys::general::{
AF_DECnet, __kernel_sa_family_t as sa_family_t, __kernel_sockaddr_storage as sockaddr_storage,
- in6_addr, in_addr, iovec, ip_mreq, ipv6_mreq, linger, sockaddr, sockaddr_in, sockaddr_in6,
- sockaddr_un, socklen_t, AF_APPLETALK, AF_ASH, AF_ATMPVC, AF_ATMSVC, AF_AX25, AF_BLUETOOTH,
- AF_BRIDGE, AF_CAN, AF_ECONET, AF_IEEE802154, AF_INET, AF_INET6, AF_IPX, AF_IRDA, AF_ISDN,
- AF_IUCV, AF_KEY, AF_LLC, AF_NETBEUI, AF_NETLINK, AF_NETROM, AF_PACKET, AF_PHONET, AF_PPPOX,
- AF_RDS, AF_ROSE, AF_RXRPC, AF_SECURITY, AF_SNA, AF_TIPC, AF_UNIX, AF_UNSPEC, AF_WANPIPE,
- AF_X25, IPPROTO_AH, IPPROTO_BEETPH, IPPROTO_COMP, IPPROTO_DCCP, IPPROTO_EGP, IPPROTO_ENCAP,
- IPPROTO_ESP, IPPROTO_ETHERNET, IPPROTO_FRAGMENT, IPPROTO_GRE, IPPROTO_ICMP, IPPROTO_ICMPV6,
- IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP, IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_MH, IPPROTO_MPLS,
- IPPROTO_MPTCP, IPPROTO_MTP, IPPROTO_PIM, IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
- IPPROTO_RSVP, IPPROTO_SCTP, IPPROTO_TCP, IPPROTO_TP, IPPROTO_UDP, IPPROTO_UDPLITE,
- IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_MULTICAST_LOOP, IPV6_V6ONLY, IP_ADD_MEMBERSHIP,
- IP_DROP_MEMBERSHIP, IP_MULTICAST_LOOP, 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, O_CLOEXEC, O_NONBLOCK, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM,
- SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_LINGER,
+ in6_addr, in_addr, iovec, ip_mreq, ipv6_mreq, linger, siginfo_t, sockaddr, sockaddr_in,
+ sockaddr_in6, sockaddr_un, socklen_t, AF_APPLETALK, AF_ASH, AF_ATMPVC, AF_ATMSVC, AF_AX25,
+ AF_BLUETOOTH, AF_BRIDGE, AF_CAN, AF_ECONET, AF_IEEE802154, AF_INET, AF_INET6, AF_IPX, AF_IRDA,
+ AF_ISDN, AF_IUCV, AF_KEY, AF_LLC, AF_NETBEUI, AF_NETLINK, AF_NETROM, AF_PACKET, AF_PHONET,
+ AF_PPPOX, AF_RDS, AF_ROSE, AF_RXRPC, AF_SECURITY, AF_SNA, AF_TIPC, AF_UNIX, AF_UNSPEC,
+ AF_WANPIPE, AF_X25, IPPROTO_AH, IPPROTO_BEETPH, IPPROTO_COMP, IPPROTO_DCCP, IPPROTO_EGP,
+ IPPROTO_ENCAP, IPPROTO_ESP, IPPROTO_ETHERNET, IPPROTO_FRAGMENT, IPPROTO_GRE, IPPROTO_ICMP,
+ IPPROTO_ICMPV6, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP, IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_MH,
+ IPPROTO_MPLS, IPPROTO_MPTCP, IPPROTO_MTP, IPPROTO_PIM, IPPROTO_PUP, IPPROTO_RAW,
+ IPPROTO_ROUTING, IPPROTO_RSVP, IPPROTO_SCTP, IPPROTO_TCP, IPPROTO_TP, IPPROTO_UDP,
+ IPPROTO_UDPLITE, IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_MULTICAST_LOOP, IPV6_V6ONLY,
+ IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_LOOP, 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, O_CLOEXEC, O_NONBLOCK,
+ O_NONBLOCK as PIDFD_NONBLOCK, P_ALL, P_PID, P_PIDFD, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM,
+ SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER,
SO_PASSCRED, SO_RCVTIMEO_NEW, SO_RCVTIMEO_OLD, SO_REUSEADDR, SO_SNDTIMEO_NEW, SO_SNDTIMEO_OLD,
SO_TYPE, TCP_NODELAY,
};
+pub(crate) use linux_raw_sys::general::{NFS_SUPER_MAGIC, PROC_SUPER_MAGIC, UTIME_NOW, UTIME_OMIT};
diff --git a/vendor/rustix/src/backend/linux_raw/conv.rs b/vendor/rustix/src/backend/linux_raw/conv.rs
index 7e09cdf80..b9fe725bb 100644
--- a/vendor/rustix/src/backend/linux_raw/conv.rs
+++ b/vendor/rustix/src/backend/linux_raw/conv.rs
@@ -15,12 +15,12 @@
use super::c;
use super::fd::{AsRawFd, BorrowedFd, FromRawFd, RawFd};
-#[cfg(not(debug_assertions))]
-use super::io::errno::decode_usize_infallible;
#[cfg(feature = "runtime")]
use super::io::errno::try_decode_error;
#[cfg(target_pointer_width = "64")]
use super::io::errno::try_decode_u64;
+#[cfg(not(debug_assertions))]
+use super::io::errno::{decode_c_uint_infallible, decode_usize_infallible};
use super::io::errno::{
try_decode_c_int, try_decode_c_uint, try_decode_raw_fd, try_decode_usize, try_decode_void,
try_decode_void_star,
@@ -143,7 +143,7 @@ impl<'a, Num: ArgNumber> From<Option<&'a CStr>> for ArgReg<'a, Num> {
impl<'a, Num: ArgNumber> From<BorrowedFd<'a>> for ArgReg<'a, Num> {
#[inline]
fn from(fd: BorrowedFd<'a>) -> Self {
- // Safety: `BorrowedFd` ensures that the file descriptor is valid, and the
+ // SAFETY: `BorrowedFd` ensures that the file descriptor is valid, and the
// lifetime parameter on the resulting `ArgReg` ensures that the result is
// bounded by the `BorrowedFd`'s lifetime.
unsafe { raw_fd(fd.as_raw_fd()) }
@@ -314,6 +314,22 @@ impl<'a, Num: ArgNumber> From<crate::fs::AtFlags> for ArgReg<'a, Num> {
}
#[cfg(feature = "fs")]
+impl<'a, Num: ArgNumber> From<crate::fs::inotify::CreateFlags> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(flags: crate::fs::inotify::CreateFlags) -> Self {
+ c_uint(flags.bits())
+ }
+}
+
+#[cfg(feature = "fs")]
+impl<'a, Num: ArgNumber> From<crate::fs::inotify::WatchFlags> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(flags: crate::fs::inotify::WatchFlags) -> Self {
+ c_uint(flags.bits())
+ }
+}
+
+#[cfg(feature = "fs")]
impl<'a, Num: ArgNumber> From<crate::fs::MemfdFlags> for ArgReg<'a, Num> {
#[inline]
fn from(flags: crate::fs::MemfdFlags) -> Self {
@@ -665,6 +681,38 @@ impl<'a, Num: ArgNumber, T> From<&'a mut MaybeUninit<T>> for ArgReg<'a, Num> {
}
}
+#[cfg(feature = "fs")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
+impl<'a, Num: ArgNumber> From<crate::backend::fs::types::MountFlagsArg> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(flags: crate::backend::fs::types::MountFlagsArg) -> Self {
+ c_uint(flags.0)
+ }
+}
+
+#[cfg(feature = "fs")]
+#[cfg(any(target_os = "android", target_os = "linux"))]
+impl<'a, Num: ArgNumber> From<crate::backend::fs::types::UnmountFlags> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(flags: crate::backend::fs::types::UnmountFlags) -> Self {
+ c_uint(flags.bits())
+ }
+}
+
+impl<'a, Num: ArgNumber> From<crate::process::Uid> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(t: crate::process::Uid) -> Self {
+ c_uint(t.as_raw())
+ }
+}
+
+impl<'a, Num: ArgNumber> From<crate::process::Gid> for ArgReg<'a, Num> {
+ #[inline]
+ fn from(t: crate::process::Gid) -> Self {
+ c_uint(t.as_raw())
+ }
+}
+
/// Convert a `usize` returned from a syscall that effectively returns `()` on
/// success.
///
@@ -754,6 +802,25 @@ pub(super) unsafe fn ret_usize_infallible(raw: RetReg<R0>) -> usize {
}
}
+/// Convert a `c_uint` returned from a syscall that effectively always
+/// returns a `c_uint`.
+///
+/// # Safety
+///
+/// This function must only be used with return values from infallible
+/// syscalls.
+#[inline]
+pub(super) unsafe fn ret_c_uint_infallible(raw: RetReg<R0>) -> c::c_uint {
+ #[cfg(debug_assertions)]
+ {
+ try_decode_c_uint(raw).unwrap()
+ }
+ #[cfg(not(debug_assertions))]
+ {
+ decode_c_uint_infallible(raw)
+ }
+}
+
/// Convert a `usize` returned from a syscall that effectively returns an
/// `OwnedFd` on success.
///
diff --git a/vendor/rustix/src/backend/linux_raw/fs/inotify.rs b/vendor/rustix/src/backend/linux_raw/fs/inotify.rs
new file mode 100644
index 000000000..4221565a6
--- /dev/null
+++ b/vendor/rustix/src/backend/linux_raw/fs/inotify.rs
@@ -0,0 +1,108 @@
+//! inotify support for working with inotifies
+
+use super::super::c;
+use crate::backend::fs::syscalls;
+use crate::fd::{BorrowedFd, OwnedFd};
+use crate::io;
+use bitflags::bitflags;
+
+bitflags! {
+ /// `IN_*` for use with [`inotify_init`].
+ ///
+ /// [`inotify_init`]: crate::fs::inotify::inotify_init
+ pub struct CreateFlags: c::c_uint {
+ /// `IN_CLOEXEC`
+ const CLOEXEC = linux_raw_sys::general::IN_CLOEXEC;
+ /// `IN_NONBLOCK`
+ const NONBLOCK = linux_raw_sys::general::IN_NONBLOCK;
+ }
+}
+
+bitflags! {
+ /// `IN*` for use with [`inotify_add_watch`].
+ ///
+ /// [`inotify_add_watch`]: crate::fs::inotify::inotify_add_watch
+ #[derive(Default)]
+ pub struct WatchFlags: c::c_uint {
+ /// `IN_ACCESS`
+ const ACCESS = linux_raw_sys::general::IN_ACCESS;
+ /// `IN_ATTRIB`
+ const ATTRIB = linux_raw_sys::general::IN_ATTRIB;
+ /// `IN_CLOSE_NOWRITE`
+ const CLOSE_NOWRITE = linux_raw_sys::general::IN_CLOSE_NOWRITE;
+ /// `IN_CLOSE_WRITE`
+ const CLOSE_WRITE = linux_raw_sys::general::IN_CLOSE_WRITE;
+ /// `IN_CREATE `
+ const CREATE = linux_raw_sys::general::IN_CREATE;
+ /// `IN_DELETE`
+ const DELETE = linux_raw_sys::general::IN_DELETE;
+ /// `IN_DELETE_SELF`
+ const DELETE_SELF = linux_raw_sys::general::IN_DELETE_SELF;
+ /// `IN_MODIFY`
+ const MODIFY = linux_raw_sys::general::IN_MODIFY;
+ /// `IN_MOVE_SELF`
+ const MOVE_SELF = linux_raw_sys::general::IN_MOVE_SELF;
+ /// `IN_MOVED_FROM`
+ const MOVED_FROM = linux_raw_sys::general::IN_MOVED_FROM;
+ /// `IN_MOVED_TO`
+ const MOVED_TO = linux_raw_sys::general::IN_MOVED_TO;
+ /// `IN_OPEN`
+ const OPEN = linux_raw_sys::general::IN_OPEN;
+
+ /// `IN_CLOSE`
+ const CLOSE = linux_raw_sys::general::IN_CLOSE;
+ /// `IN_MOVE`
+ const MOVE = linux_raw_sys::general::IN_MOVE;
+ /// `IN_ALL_EVENTS`
+ const ALL_EVENTS = linux_raw_sys::general::IN_ALL_EVENTS;
+
+ /// `IN_DONT_FOLLOW`
+ const DONT_FOLLOW = linux_raw_sys::general::IN_DONT_FOLLOW;
+ /// `IN_EXCL_UNLINK`
+ const EXCL_UNLINK = linux_raw_sys::general::IN_EXCL_UNLINK;
+ /// `IN_MASK_ADD`
+ const MASK_ADD = linux_raw_sys::general::IN_MASK_ADD;
+ /// `IN_MASK_CREATE`
+ const MASK_CREATE = linux_raw_sys::general::IN_MASK_CREATE;
+ /// `IN_ONESHOT`
+ const ONESHOT = linux_raw_sys::general::IN_ONESHOT;
+ /// `IN_ONLYDIR`
+ const ONLYDIR = linux_raw_sys::general::IN_ONLYDIR;
+ }
+}
+
+/// `inotify_init1(flags)`—Creates a new inotify object.
+///
+/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
+/// descriptor from being implicitly passed across `exec` boundaries.
+#[doc(alias = "inotify_init1")]
+pub fn inotify_init(flags: CreateFlags) -> io::Result<OwnedFd> {
+ syscalls::inotify_init1(flags)
+}
+
+/// `inotify_add_watch(self, path, flags)`—Adds a watch to inotify
+///
+/// This registers or updates a watch for the filesystem path `path`
+/// and returns a watch descriptor corresponding to this watch.
+///
+/// Note: Due to the existence of hardlinks, providing two
+/// different paths to this method may result in it returning
+/// the same watch descriptor. An application should keep track of this
+/// externally to avoid logic errors.
+pub fn inotify_add_watch<P: crate::path::Arg>(
+ inot: BorrowedFd<'_>,
+ path: P,
+ flags: WatchFlags,
+) -> io::Result<i32> {
+ let path = path.as_cow_c_str().unwrap();
+ 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.
+#[doc(alias = "inotify_rm_watch")]
+pub fn inotify_remove_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
+ syscalls::inotify_rm_watch(inot, wd)
+}
diff --git a/vendor/rustix/src/backend/linux_raw/fs/mod.rs b/vendor/rustix/src/backend/linux_raw/fs/mod.rs
index 015c6baec..acf43ce4f 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/mod.rs
@@ -1,4 +1,5 @@
pub(crate) mod dir;
+pub mod inotify;
pub(crate) mod makedev;
pub(crate) mod syscalls;
pub(crate) mod types;
diff --git a/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs b/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
index ff58f0a7b..8bd9ccc27 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/syscalls.rs
@@ -10,7 +10,7 @@
use super::super::c;
use super::super::conv::{
by_ref, c_int, c_uint, dev_t, oflags_for_open_how, opt_mut, pass_usize, raw_fd, ret, ret_c_int,
- ret_c_uint, ret_owned_fd, ret_usize, size_of, slice_mut, zero,
+ ret_c_uint, ret_infallible, ret_owned_fd, ret_usize, size_of, slice_mut, zero,
};
#[cfg(target_pointer_width = "64")]
use super::super::conv::{loff_t, loff_t_from_u64, ret_u64};
@@ -24,12 +24,13 @@ use crate::fd::AsFd;
use crate::fd::{BorrowedFd, OwnedFd};
use crate::ffi::CStr;
use crate::fs::{
- Access, Advice, AtFlags, FallocateFlags, FileType, FlockOperation, MemfdFlags, Mode, OFlags,
- RenameFlags, ResolveFlags, SealFlags, Stat, StatFs, StatVfs, StatVfsMountFlags, StatxFlags,
- Timestamps,
+ inotify, Access, Advice, AtFlags, FallocateFlags, FileType, FlockOperation, MemfdFlags, Mode,
+ OFlags, RenameFlags, ResolveFlags, SealFlags, Stat, StatFs, StatVfs, StatVfsMountFlags,
+ StatxFlags, Timestamps,
};
use crate::io::{self, SeekFrom};
use crate::process::{Gid, Uid};
+#[cfg(any(target_pointer_width = "32", target_arch = "mips64"))]
use core::convert::TryInto;
use core::mem::MaybeUninit;
#[cfg(target_arch = "mips64")]
@@ -37,7 +38,8 @@ 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_GETLEASE, F_GETOWN, F_GETPIPE_SZ, F_GETSIG,
- F_GET_SEALS, F_SETFL, F_SETPIPE_SZ, SEEK_CUR, SEEK_END, SEEK_SET, STATX__RESERVED,
+ F_GET_SEALS, F_SETFL, F_SETPIPE_SZ, SEEK_CUR, SEEK_DATA, SEEK_END, SEEK_HOLE, SEEK_SET,
+ STATX__RESERVED,
};
#[cfg(target_pointer_width = "32")]
use {
@@ -136,7 +138,18 @@ pub(crate) fn chmod(filename: &CStr, mode: Mode) -> io::Result<()> {
}
#[inline]
-pub(crate) fn chmodat(dirfd: BorrowedFd<'_>, filename: &CStr, mode: Mode) -> io::Result<()> {
+pub(crate) fn chmodat(
+ dirfd: BorrowedFd<'_>,
+ filename: &CStr,
+ mode: Mode,
+ flags: AtFlags,
+) -> io::Result<()> {
+ if flags == AtFlags::SYMLINK_NOFOLLOW {
+ return Err(io::Errno::OPNOTSUPP);
+ }
+ if !flags.is_empty() {
+ return Err(io::Errno::INVAL);
+ }
unsafe { ret(syscall_readonly!(__NR_fchmodat, dirfd, filename, mode)) }
}
@@ -214,6 +227,10 @@ pub(crate) fn seek(fd: BorrowedFd<'_>, pos: SeekFrom) -> io::Result<u64> {
}
SeekFrom::End(offset) => (SEEK_END, offset),
SeekFrom::Current(offset) => (SEEK_CUR, offset),
+ #[cfg(any(freebsdlike, target_os = "linux", target_os = "solaris"))]
+ SeekFrom::Data(offset) => (SEEK_DATA, offset),
+ #[cfg(any(freebsdlike, target_os = "linux", target_os = "solaris"))]
+ SeekFrom::Hole(offset) => (SEEK_HOLE, offset),
};
_seek(fd, offset, whence)
}
@@ -404,7 +421,23 @@ pub(crate) fn fdatasync(fd: BorrowedFd<'_>) -> io::Result<()> {
#[inline]
pub(crate) fn flock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
- unsafe { ret(syscall!(__NR_flock, fd, c_uint(operation as c::c_uint))) }
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_flock,
+ fd,
+ c_uint(operation as c::c_uint)
+ ))
+ }
+}
+
+#[inline]
+pub(crate) fn syncfs(fd: BorrowedFd<'_>) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_syncfs, fd)) }
+}
+
+#[inline]
+pub(crate) fn sync() {
+ unsafe { ret_infallible(syscall_readonly!(__NR_sync)) }
}
#[inline]
@@ -1017,6 +1050,58 @@ pub(crate) fn fcntl_add_seals(fd: BorrowedFd<'_>, seals: SealFlags) -> io::Resul
}
#[inline]
+pub(crate) fn fcntl_lock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
+ #[cfg(target_pointer_width = "64")]
+ use linux_raw_sys::general::{flock, F_SETLK, F_SETLKW};
+ #[cfg(target_pointer_width = "32")]
+ use linux_raw_sys::general::{flock64 as flock, F_SETLK64 as F_SETLK, F_SETLKW64 as F_SETLKW};
+ use linux_raw_sys::general::{F_RDLCK, F_UNLCK, F_WRLCK};
+
+ let (cmd, l_type) = match operation {
+ FlockOperation::LockShared => (F_SETLKW, F_RDLCK),
+ FlockOperation::LockExclusive => (F_SETLKW, F_WRLCK),
+ FlockOperation::Unlock => (F_SETLKW, F_UNLCK),
+ FlockOperation::NonBlockingLockShared => (F_SETLK, F_RDLCK),
+ FlockOperation::NonBlockingLockExclusive => (F_SETLK, F_WRLCK),
+ FlockOperation::NonBlockingUnlock => (F_SETLK, F_UNLCK),
+ };
+
+ unsafe {
+ 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,
+
+ ..core::mem::zeroed()
+ };
+
+ #[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)
+ ))
+ }
+ }
+}
+
+#[inline]
pub(crate) fn rename(oldname: &CStr, newname: &CStr) -> io::Result<()> {
#[cfg(target_arch = "riscv64")]
unsafe {
@@ -1196,6 +1281,16 @@ pub(crate) fn getdents(fd: BorrowedFd<'_>, dirent: &mut [u8]) -> io::Result<usiz
}
#[inline]
+pub(crate) fn getdents_uninit(
+ fd: BorrowedFd<'_>,
+ dirent: &mut [MaybeUninit<u8>],
+) -> io::Result<usize> {
+ let (dirent_addr_mut, dirent_len) = slice_mut(dirent);
+
+ unsafe { ret_usize(syscall!(__NR_getdents64, fd, dirent_addr_mut, dirent_len)) }
+}
+
+#[inline]
pub(crate) fn utimensat(
dirfd: BorrowedFd<'_>,
pathname: &CStr,
@@ -1321,20 +1416,7 @@ pub(crate) fn copy_file_range(
off_in: Option<&mut u64>,
fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
- len: u64,
-) -> io::Result<u64> {
- let len: usize = len.try_into().unwrap_or(usize::MAX);
- _copy_file_range(fd_in, off_in, fd_out, off_out, len, 0).map(|result| result as u64)
-}
-
-#[inline]
-fn _copy_file_range(
- fd_in: BorrowedFd<'_>,
- off_in: Option<&mut u64>,
- fd_out: BorrowedFd<'_>,
- off_out: Option<&mut u64>,
len: usize,
- flags: c::c_uint,
) -> io::Result<usize> {
unsafe {
ret_usize(syscall!(
@@ -1344,7 +1426,7 @@ fn _copy_file_range(
fd_out,
opt_mut(off_out),
pass_usize(len),
- c_uint(flags)
+ c_uint(0)
))
}
}
@@ -1382,3 +1464,49 @@ pub(crate) fn sendfile(
))
}
}
+
+#[inline]
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn mount(
+ source: Option<&CStr>,
+ target: &CStr,
+ file_system_type: Option<&CStr>,
+ flags: super::types::MountFlagsArg,
+ data: Option<&CStr>,
+) -> io::Result<()> {
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_mount,
+ source,
+ target,
+ file_system_type,
+ flags,
+ data
+ ))
+ }
+}
+
+#[inline]
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn unmount(target: &CStr, flags: super::types::UnmountFlags) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_umount2, target, flags)) }
+}
+
+#[inline]
+pub(crate) fn inotify_init1(flags: inotify::CreateFlags) -> io::Result<OwnedFd> {
+ unsafe { ret_owned_fd(syscall_readonly!(__NR_inotify_init1, flags)) }
+}
+
+#[inline]
+pub(crate) fn inotify_add_watch(
+ infd: BorrowedFd<'_>,
+ path: &CStr,
+ flags: inotify::WatchFlags,
+) -> io::Result<i32> {
+ unsafe { ret_c_int(syscall_readonly!(__NR_inotify_add_watch, infd, path, flags)) }
+}
+
+#[inline]
+pub(crate) fn inotify_rm_watch(infd: BorrowedFd<'_>, wfd: i32) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_inotify_rm_watch, infd, c_int(wfd))) }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/fs/types.rs b/vendor/rustix/src/backend/linux_raw/fs/types.rs
index a8d225ede..9bafb8ac0 100644
--- a/vendor/rustix/src/backend/linux_raw/fs/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/fs/types.rs
@@ -122,6 +122,32 @@ impl Mode {
}
}
+impl From<RawMode> for Mode {
+ /// Support conversions from raw mode values to `Mode`.
+ ///
+ /// ```
+ /// use rustix::fs::{Mode, RawMode};
+ /// assert_eq!(Mode::from(0o700), Mode::RWXU);
+ /// ```
+ #[inline]
+ fn from(st_mode: RawMode) -> Self {
+ Self::from_raw_mode(st_mode)
+ }
+}
+
+impl From<Mode> for RawMode {
+ /// Support conversions from `Mode to raw mode values.
+ ///
+ /// ```
+ /// use rustix::fs::{Mode, RawMode};
+ /// assert_eq!(RawMode::from(Mode::RWXU), 0o700);
+ /// ```
+ #[inline]
+ fn from(mode: Mode) -> Self {
+ mode.as_raw_mode()
+ }
+}
+
bitflags! {
/// `O_*` constants for use with [`openat`].
///
@@ -198,6 +224,9 @@ bitflags! {
/// `O_NOATIME`
const NOATIME = linux_raw_sys::general::O_NOATIME;
+
+ /// `O_DIRECT`
+ const DIRECT = linux_raw_sys::general::O_DIRECT;
}
}
@@ -515,9 +544,10 @@ bitflags! {
}
}
-/// `LOCK_*` constants for use with [`flock`]
+/// `LOCK_*` constants for use with [`flock`] and [`fcntl_lock`].
///
/// [`flock`]: crate::fs::flock
+/// [`fcntl_lock`]: crate::fs::fcntl_lock
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u32)]
pub enum FlockOperation {
@@ -637,10 +667,106 @@ pub type FsWord = linux_raw_sys::general::__fsword_t;
#[cfg(target_arch = "mips64")]
pub type FsWord = i64;
-pub use linux_raw_sys::general::{UTIME_NOW, UTIME_OMIT};
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MS_*` constants for use with [`mount`].
+ ///
+ /// [`mount`]: crate::fs::mount
+ pub struct MountFlags: c::c_uint {
+ /// `MS_BIND`
+ const BIND = linux_raw_sys::general::MS_BIND;
+
+ /// `MS_DIRSYNC`
+ const DIRSYNC = linux_raw_sys::general::MS_DIRSYNC;
+
+ /// `MS_LAZYTIME`
+ const LAZYTIME = linux_raw_sys::general::MS_LAZYTIME;
+
+ /// `MS_MANDLOCK`
+ #[doc(alias = "MANDLOCK")]
+ const PERMIT_MANDATORY_FILE_LOCKING = linux_raw_sys::general::MS_MANDLOCK;
+
+ /// `MS_NOATIME`
+ const NOATIME = linux_raw_sys::general::MS_NOATIME;
+
+ /// `MS_NODEV`
+ const NODEV = linux_raw_sys::general::MS_NODEV;
+
+ /// `MS_NODIRATIME`
+ const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME;
+
+ /// `MS_NOEXEC`
+ const NOEXEC = linux_raw_sys::general::MS_NOEXEC;
+
+ /// `MS_NOSUID`
+ const NOSUID = linux_raw_sys::general::MS_NOSUID;
+
+ /// `MS_RDONLY`
+ const RDONLY = linux_raw_sys::general::MS_RDONLY;
-/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
-pub const PROC_SUPER_MAGIC: FsWord = linux_raw_sys::general::PROC_SUPER_MAGIC as FsWord;
+ /// `MS_REC`
+ const REC = linux_raw_sys::general::MS_REC;
-/// `NFS_SUPER_MAGIC`—The magic number for the NFS filesystem.
-pub const NFS_SUPER_MAGIC: FsWord = linux_raw_sys::general::NFS_SUPER_MAGIC as FsWord;
+ /// `MS_RELATIME`
+ const RELATIME = linux_raw_sys::general::MS_RELATIME;
+
+ /// `MS_SILENT`
+ const SILENT = linux_raw_sys::general::MS_SILENT;
+
+ /// `MS_STRICTATIME`
+ const STRICTATIME = linux_raw_sys::general::MS_STRICTATIME;
+
+ /// `MS_SYNCHRONOUS`
+ const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS;
+
+ /// `MS_NOSYMFOLLOW`
+ const NOSYMFOLLOW = linux_raw_sys::general::MS_NOSYMFOLLOW;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MS_*` constants for use with [`change_mount`].
+ ///
+ /// [`change_mount`]: crate::fs::mount::change_mount
+ pub struct MountPropagationFlags: c::c_uint {
+ /// `MS_SHARED`
+ const SHARED = linux_raw_sys::general::MS_SHARED;
+ /// `MS_PRIVATE`
+ const PRIVATE = linux_raw_sys::general::MS_PRIVATE;
+ /// `MS_SLAVE`
+ const SLAVE = linux_raw_sys::general::MS_SLAVE;
+ /// `MS_UNBINDABLE`
+ const UNBINDABLE = linux_raw_sys::general::MS_UNBINDABLE;
+ /// `MS_REC`
+ const REC = linux_raw_sys::general::MS_REC;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ pub(crate) struct InternalMountFlags: c::c_uint {
+ const REMOUNT = linux_raw_sys::general::MS_REMOUNT;
+ const MOVE = linux_raw_sys::general::MS_MOVE;
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) struct MountFlagsArg(pub(crate) c::c_uint);
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+bitflags! {
+ /// `MNT_*` constants for use with [`unmount`].
+ ///
+ /// [`unmount`]: crate::fs::mount::unmount
+ pub struct UnmountFlags: c::c_uint {
+ /// `MNT_FORCE`
+ const FORCE = linux_raw_sys::general::MNT_FORCE;
+ /// `MNT_DETACH`
+ const DETACH = linux_raw_sys::general::MNT_DETACH;
+ /// `MNT_EXPIRE`
+ const EXPIRE = linux_raw_sys::general::MNT_EXPIRE;
+ /// `UMOUNT_NOFOLLOW`
+ const NOFOLLOW = linux_raw_sys::general::UMOUNT_NOFOLLOW;
+ }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/io/epoll.rs b/vendor/rustix/src/backend/linux_raw/io/epoll.rs
index d55ad75b1..3fc6462a2 100644
--- a/vendor/rustix/src/backend/linux_raw/io/epoll.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/epoll.rs
@@ -6,17 +6,17 @@
//!
//! # Examples
//!
-//! ```rust,no_run
+//! ```no_run
//! # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
//! # #[cfg(feature = "net")]
//! # fn main() -> std::io::Result<()> {
//! use io_lifetimes::AsFd;
-//! use rustix::io::epoll::{self, Epoll};
-//! use rustix::io::{ioctl_fionbio, read, write};
+//! use rustix::io::{epoll, ioctl_fionbio, read, write};
//! use rustix::net::{
//! accept, bind_v4, listen, socket, AddressFamily, Ipv4Addr, Protocol, SocketAddrV4,
//! SocketType,
//! };
+//! use std::collections::HashMap;
//! use std::os::unix::io::AsRawFd;
//!
//! // Create a socket and listen on it.
@@ -26,29 +26,40 @@
//!
//! // Create an epoll object. Using `Owning` here means the epoll object will
//! // take ownership of the file descriptors registered with it.
-//! let epoll = Epoll::new(epoll::CreateFlags::CLOEXEC, epoll::Owning::new())?;
-//!
-//! // Remember the socket raw fd, which we use for comparisons only.
-//! let raw_listen_sock = listen_sock.as_fd().as_raw_fd();
+//! let epoll = epoll::epoll_create(epoll::CreateFlags::CLOEXEC)?;
//!
//! // Register the socket with the epoll object.
-//! epoll.add(listen_sock, epoll::EventFlags::IN)?;
+//! epoll::epoll_add(&epoll, &listen_sock, 1, epoll::EventFlags::IN)?;
+//!
+//! // Keep track of the sockets we've opened.
+//! let mut next_id = 2;
+//! let mut sockets = HashMap::new();
//!
//! // Process events.
//! let mut event_list = epoll::EventVec::with_capacity(4);
//! loop {
-//! epoll.wait(&mut event_list, -1)?;
+//! epoll::epoll_wait(&epoll, &mut event_list, -1)?;
//! for (_event_flags, target) in &event_list {
-//! if target.as_raw_fd() == raw_listen_sock {
+//! if target == 1 {
//! // Accept a new connection, set it to non-blocking, and
//! // register to be notified when it's ready to write to.
-//! let conn_sock = accept(&*target)?;
+//! let conn_sock = accept(&listen_sock)?;
//! ioctl_fionbio(&conn_sock, true)?;
-//! epoll.add(conn_sock, epoll::EventFlags::OUT | epoll::EventFlags::ET)?;
+//! epoll::epoll_add(
+//! &epoll,
+//! &conn_sock,
+//! next_id,
+//! epoll::EventFlags::OUT | epoll::EventFlags::ET,
+//! )?;
+//!
+//! // Keep track of the socket.
+//! sockets.insert(next_id, conn_sock);
+//! next_id += 1;
//! } else {
//! // Write a message to the stream and then unregister it.
-//! write(&*target, b"hello\n")?;
-//! let _ = epoll.del(target)?;
+//! let target = sockets.remove(&target).unwrap();
+//! write(&target, b"hello\n")?;
+//! let _ = epoll::epoll_del(&epoll, &target)?;
//! }
//! }
//! }
@@ -60,17 +71,11 @@
#![allow(unsafe_code)]
use super::super::c;
-use crate::backend::io::syscalls::{epoll_add, epoll_create, epoll_del, epoll_mod, epoll_wait};
-use crate::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
-#[cfg(feature = "std")]
-use crate::fd::{FromRawFd, IntoRawFd};
+use crate::backend::io::syscalls;
+use crate::fd::{AsFd, AsRawFd, OwnedFd};
use crate::io;
use alloc::vec::Vec;
use bitflags::bitflags;
-use core::fmt;
-use core::marker::PhantomData;
-use core::ops::Deref;
-use core::ptr::null;
bitflags! {
/// `EPOLL_*` for use with [`Epoll::new`].
@@ -99,6 +104,24 @@ bitflags! {
/// `EPOLLHUP`
const HUP = linux_raw_sys::general::EPOLLHUP as u32;
+ /// `EPOLLRDNORM`
+ const RDNORM = linux_raw_sys::general::EPOLLRDNORM as u32;
+
+ /// `EPOLLRDBAND`
+ const RDBAND = linux_raw_sys::general::EPOLLRDBAND as u32;
+
+ /// `EPOLLWRNORM`
+ const WRNORM = linux_raw_sys::general::EPOLLWRNORM as u32;
+
+ /// `EPOLLWRBAND`
+ const WRBAND = linux_raw_sys::general::EPOLLWRBAND as u32;
+
+ /// `EPOLLMSG`
+ const MSG = linux_raw_sys::general::EPOLLMSG as u32;
+
+ /// `EPOLLRDHUP`
+ const RDHUP = linux_raw_sys::general::EPOLLRDHUP as u32;
+
/// `EPOLLET`
const ET = linux_raw_sys::general::EPOLLET as u32;
@@ -113,351 +136,127 @@ bitflags! {
}
}
-/// A reference to a `T`.
-pub struct Ref<'a, T> {
- t: T,
- _phantom: PhantomData<&'a T>,
-}
-
-impl<'a, T> Ref<'a, T> {
- #[inline]
- fn new(t: T) -> Self {
- Self {
- t,
- _phantom: PhantomData,
- }
- }
-
- #[inline]
- fn consume(self) -> T {
- self.t
- }
-}
-
-impl<'a, T> Deref for Ref<'a, T> {
- type Target = T;
-
- #[inline]
- fn deref(&self) -> &T {
- &self.t
- }
-}
-
-impl<'a, T: fmt::Debug> fmt::Debug for Ref<'a, T> {
- fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
- self.t.fmt(fmt)
- }
-}
-
-/// A trait for data stored within an [`Epoll`] instance.
-pub trait Context {
- /// The type of an element owned by this context.
- type Data;
-
- /// The type of a value used to refer to an element owned by this context.
- type Target: AsFd;
-
- /// Assume ownership of `data`, and returning a `Target`.
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target>;
-
- /// Encode `target` as a `u64`. The only requirement on this value is that
- /// it be decodable by `decode`.
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64;
-
- /// Decode `raw`, which is a value encoded by `encode`, into a `Target`.
- ///
- /// # Safety
- ///
- /// `raw` must be a `u64` value returned from `encode`, from the same
- /// context, and within the context's lifetime.
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target>;
-
- /// Release ownership of the value referred to by `target` and return it.
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data;
-}
-
-/// A type implementing [`Context`] where the `Data` type is `BorrowedFd<'a>`.
-pub struct Borrowing<'a> {
- _phantom: PhantomData<BorrowedFd<'a>>,
-}
-
-impl<'a> Context for Borrowing<'a> {
- type Data = BorrowedFd<'a>;
- type Target = BorrowedFd<'a>;
-
- #[inline]
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target> {
- Ref::new(data)
- }
-
- #[inline]
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64 {
- target.as_raw_fd() as u64
- }
-
- #[inline]
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target> {
- Ref::new(BorrowedFd::<'a>::borrow_raw(raw as RawFd))
- }
-
- #[inline]
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data {
- target.consume()
- }
-}
-
-/// A type implementing [`Context`] where the `Data` type is `T`, a type
-/// implementing `From<OwnedFd>` and `From<T> of OwnedFd`.
+/// `epoll_create1(flags)`—Creates a new `Epoll`.
///
-/// This may be used with [`OwnedFd`], or higher-level types like
-/// [`std::fs::File`] or [`std::net::TcpStream`].
-#[cfg(feature = "std")]
-pub struct Owning<'context, T: Into<OwnedFd> + From<OwnedFd>> {
- _phantom: PhantomData<&'context T>,
+/// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
+/// descriptor from being implicitly passed across `exec` boundaries.
+#[inline]
+#[doc(alias = "epoll_create1")]
+pub fn epoll_create(flags: CreateFlags) -> io::Result<OwnedFd> {
+ syscalls::epoll_create(flags)
}
-#[cfg(feature = "std")]
-impl<'context, T: Into<OwnedFd> + From<OwnedFd>> Owning<'context, T> {
- /// Creates a new empty `Owning`.
- #[allow(clippy::new_without_default)] // This is a specialized type that doesn't need to be generically constructible.
- #[inline]
- pub fn new() -> Self {
- Self {
- _phantom: PhantomData,
- }
- }
-}
-
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> Context for Owning<'context, T> {
- type Data = T;
- type Target = BorrowedFd<'context>;
-
- #[inline]
- fn acquire<'call>(&self, data: Self::Data) -> Ref<'call, Self::Target> {
- let raw_fd = data.into().into_raw_fd();
- // Safety: `epoll` will assign ownership of the file descriptor to the
- // kernel epoll object. We use `Into<OwnedFd>`+`IntoRawFd` to consume
- // the `Data` and extract the raw file descriptor and then "borrow" it
- // with `borrow_raw` knowing that the borrow won't outlive the
- // kernel epoll object.
- unsafe { Ref::new(BorrowedFd::<'context>::borrow_raw(raw_fd)) }
- }
-
- #[inline]
- fn encode(&self, target: Ref<'_, Self::Target>) -> u64 {
- target.as_fd().as_raw_fd() as u64
- }
-
- #[inline]
- unsafe fn decode<'call>(&self, raw: u64) -> Ref<'call, Self::Target> {
- Ref::new(BorrowedFd::<'context>::borrow_raw(raw as RawFd))
- }
-
- #[inline]
- fn release(&self, target: Ref<'_, Self::Target>) -> Self::Data {
- let raw_fd = target.consume().as_raw_fd();
-
- // Safety: The file descriptor was held by the kernel epoll object and
- // is now being released, so we can create a new `OwnedFd` that assumes
- // ownership.
- unsafe { T::from(io_lifetimes::OwnedFd::from_raw_fd(raw_fd)) }
- }
-}
-
-/// An "epoll", an interface to an OS object allowing one to repeatedly wait
-/// for events from a set of file descriptors efficiently.
-pub struct Epoll<Context: self::Context> {
- epoll_fd: OwnedFd,
- context: Context,
-}
-
-impl<Context: self::Context> Epoll<Context> {
- /// `epoll_create1(flags)`—Creates a new `Epoll`.
- ///
- /// Use the [`CreateFlags::CLOEXEC`] flag to prevent the resulting file
- /// descriptor from being implicitly passed across `exec` boundaries.
- #[inline]
- #[doc(alias = "epoll_create1")]
- pub fn new(flags: CreateFlags, context: Context) -> io::Result<Self> {
- // Safety: We're calling `epoll_create1` via FFI and we know how it
- // behaves.
- Ok(Self {
- epoll_fd: epoll_create(flags)?,
- context,
- })
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
- /// `Epoll`.
- ///
- /// This registers interest in any of the events set in `events` occurring
- /// on the file descriptor associated with `data`.
- #[doc(alias = "epoll_ctl")]
- pub fn add(
- &self,
- data: Context::Data,
- event_flags: EventFlags,
- ) -> io::Result<Ref<'_, Context::Target>> {
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- let target = self.context.acquire(data);
- let raw_fd = target.as_fd().as_raw_fd();
- let encoded = self.context.encode(target);
- epoll_add(
- self.epoll_fd.as_fd(),
- raw_fd,
- &linux_raw_sys::general::epoll_event {
- events: event_flags.bits(),
- data: encoded,
- },
- )?;
- Ok(self.context.decode(encoded))
- }
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in
- /// this `Epoll`.
- ///
- /// This sets the events of interest with `target` to `events`.
- #[doc(alias = "epoll_ctl")]
- pub fn mod_(
- &self,
- target: Ref<'_, Context::Target>,
- event_flags: EventFlags,
- ) -> io::Result<()> {
- let raw_fd = target.as_fd().as_raw_fd();
- let encoded = self.context.encode(target);
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- epoll_mod(
- self.epoll_fd.as_fd(),
- raw_fd,
- &linux_raw_sys::general::epoll_event {
- events: event_flags.bits(),
- data: encoded,
- },
- )
- }
- }
-
- /// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in
- /// this `Epoll`.
- ///
- /// This also returns the owning `Data`.
- #[doc(alias = "epoll_ctl")]
- pub fn del(&self, target: Ref<'_, Context::Target>) -> io::Result<Context::Data> {
- // Safety: We're calling `epoll_ctl` via FFI and we know how it
- // behaves.
- unsafe {
- let raw_fd = target.as_fd().as_raw_fd();
- epoll_del(self.epoll_fd.as_fd(), raw_fd)?;
- }
- Ok(self.context.release(target))
- }
-
- /// `epoll_wait(self, events, timeout)`—Waits for registered events of
- /// interest.
- ///
- /// For each event of interest, an element is written to `events`. On
- /// success, this returns the number of written elements.
- #[doc(alias = "epoll_wait")]
- pub fn wait<'context>(
- &'context self,
- event_list: &mut EventVec<'context, Context>,
- timeout: c::c_int,
- ) -> io::Result<()> {
- // Safety: We're calling `epoll_wait` via FFI and we know how it
- // behaves.
- unsafe {
- event_list.events.set_len(0);
- let nfds = epoll_wait(
- self.epoll_fd.as_fd(),
- event_list.events[..].as_mut_ptr().cast(),
- event_list.events.capacity(),
- timeout,
- )?;
- event_list.events.set_len(nfds);
- event_list.context = &self.context;
- }
-
- Ok(())
- }
-}
-
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> AsRawFd for Epoll<Owning<'context, T>> {
- fn as_raw_fd(&self) -> RawFd {
- self.epoll_fd.as_raw_fd()
- }
-}
-
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> IntoRawFd for Epoll<Owning<'context, T>> {
- fn into_raw_fd(self) -> RawFd {
- self.epoll_fd.into_raw_fd()
- }
-}
-
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> FromRawFd for Epoll<Owning<'context, T>> {
- unsafe fn from_raw_fd(fd: RawFd) -> Self {
- Self {
- epoll_fd: OwnedFd::from_raw_fd(fd),
- context: Owning::new(),
- }
+/// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
+/// `Epoll`.
+///
+/// This registers interest in any of the events set in `events` occurring
+/// on the file descriptor associated with `data`.
+///
+/// Note that if `epoll_del` 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 source is still registered with it. This can lead to
+/// spurious events being returned from `epoll_wait`. If a file descriptor
+/// is an `Arc<dyn SystemResource>`, then `epoll` can be thought to maintain
+/// a `Weak<dyn SystemResource>` to the file descriptor.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_add(
+ epoll: impl AsFd,
+ source: impl AsFd,
+ data: u64,
+ event_flags: EventFlags,
+) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ syscalls::epoll_add(
+ epoll.as_fd(),
+ source.as_fd().as_raw_fd(),
+ &linux_raw_sys::general::epoll_event {
+ events: event_flags.bits(),
+ data,
+ },
+ )
}
}
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> AsFd for Epoll<Owning<'context, T>> {
- fn as_fd(&self) -> BorrowedFd<'_> {
- self.epoll_fd.as_fd()
+/// `epoll_ctl(self, EPOLL_CTL_MOD, target, event)`—Modifies an element in
+/// this `Epoll`.
+///
+/// This sets the events of interest with `target` to `events`.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_mod(
+ epoll: impl AsFd,
+ source: impl AsFd,
+ data: u64,
+ event_flags: EventFlags,
+) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ let raw_fd = source.as_fd().as_raw_fd();
+ syscalls::epoll_mod(
+ epoll.as_fd(),
+ raw_fd,
+ &linux_raw_sys::general::epoll_event {
+ events: event_flags.bits(),
+ data,
+ },
+ )
}
}
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> From<Epoll<Owning<'context, T>>>
- for OwnedFd
-{
- fn from(epoll: Epoll<Owning<'context, T>>) -> Self {
- epoll.epoll_fd
+/// `epoll_ctl(self, EPOLL_CTL_DEL, target, NULL)`—Removes an element in
+/// this `Epoll`.
+///
+/// This also returns the owning `Data`.
+#[doc(alias = "epoll_ctl")]
+pub fn epoll_del(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_ctl` via FFI and we know how it
+ // behaves.
+ unsafe {
+ let raw_fd = source.as_fd().as_raw_fd();
+ syscalls::epoll_del(epoll.as_fd(), raw_fd)
}
}
-#[cfg(feature = "std")]
-impl<'context, T: AsFd + Into<OwnedFd> + From<OwnedFd>> From<OwnedFd>
- for Epoll<Owning<'context, T>>
-{
- fn from(fd: OwnedFd) -> Self {
- Self {
- epoll_fd: fd,
- context: Owning::new(),
- }
- }
+/// `epoll_wait(self, events, timeout)`—Waits for registered events of
+/// interest.
+///
+/// For each event of interest, an element is written to `events`. On
+/// success, this returns the number of written elements.
+pub fn epoll_wait(
+ epoll: impl AsFd,
+ event_list: &mut EventVec,
+ timeout: c::c_int,
+) -> io::Result<()> {
+ // SAFETY: We're calling `epoll_wait` via FFI and we know how it
+ // behaves.
+ unsafe {
+ event_list.events.set_len(0);
+ let nfds = syscalls::epoll_wait(
+ epoll.as_fd(),
+ event_list.events[..].as_mut_ptr().cast(),
+ event_list.events.capacity(),
+ timeout,
+ )?;
+ event_list.events.set_len(nfds);
+ }
+
+ Ok(())
}
/// An iterator over the `Event`s in an `EventVec`.
-pub struct Iter<'context, Context: self::Context> {
- iter: core::slice::Iter<'context, Event>,
- context: *const Context,
- _phantom: PhantomData<&'context Context>,
+pub struct Iter<'a> {
+ iter: core::slice::Iter<'a, Event>,
}
-impl<'context, Context: self::Context> Iterator for Iter<'context, Context> {
- type Item = (EventFlags, Ref<'context, Context::Target>);
+impl<'a> Iterator for Iter<'a> {
+ type Item = (EventFlags, u64);
fn next(&mut self) -> Option<Self::Item> {
- self.iter.next().map(|event| {
- // Safety: `self.context` is guaranteed to be valid because we hold
- // `'context` for it. And we know this event is associated with this
- // context because `wait` sets both.
- let decoded = unsafe { (*self.context).decode(event.encoded) };
-
- (event.event_flags, decoded)
- })
+ self.iter
+ .next()
+ .map(|event| (event.event_flags, event.data))
}
}
@@ -466,28 +265,22 @@ impl<'context, Context: self::Context> Iterator for Iter<'context, Context> {
#[cfg_attr(target_arch = "x86_64", repr(packed))]
struct Event {
// Match the layout of `linux_raw_sys::general::epoll_event`. We just use a
- // `u64` instead of the full union; `Context` implementations will simply
- // need to deal with casting the value into and out of the `u64`
- // themselves.
+ // `u64` instead of the full union.
event_flags: EventFlags,
- encoded: u64,
+ data: u64,
}
/// A vector of `Event`s, plus context for interpreting them.
-pub struct EventVec<'context, Context: self::Context> {
+pub struct EventVec {
events: Vec<Event>,
- context: *const Context,
- _phantom: PhantomData<&'context Context>,
}
-impl<'context, Context: self::Context> EventVec<'context, Context> {
+impl EventVec {
/// Constructs an `EventVec` with memory for `capacity` `Event`s.
#[inline]
pub fn with_capacity(capacity: usize) -> Self {
Self {
events: Vec::with_capacity(capacity),
- context: null(),
- _phantom: PhantomData,
}
}
@@ -523,11 +316,9 @@ impl<'context, Context: self::Context> EventVec<'context, Context> {
/// Returns an iterator over the `Event`s in this `EventVec`.
#[inline]
- pub fn iter(&self) -> Iter<'_, Context> {
+ pub fn iter(&self) -> Iter<'_> {
Iter {
iter: self.events.iter(),
- context: self.context,
- _phantom: PhantomData,
}
}
@@ -544,9 +335,9 @@ impl<'context, Context: self::Context> EventVec<'context, Context> {
}
}
-impl<'context, Context: self::Context> IntoIterator for &'context EventVec<'context, Context> {
- type IntoIter = Iter<'context, Context>;
- type Item = (EventFlags, Ref<'context, Context::Target>);
+impl<'a> IntoIterator for &'a EventVec {
+ type IntoIter = Iter<'a>;
+ type Item = (EventFlags, u64);
#[inline]
fn into_iter(self) -> Self::IntoIter {
diff --git a/vendor/rustix/src/backend/linux_raw/io/errno.rs b/vendor/rustix/src/backend/linux_raw/io/errno.rs
index 5c7b2fcd5..b01910138 100644
--- a/vendor/rustix/src/backend/linux_raw/io/errno.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/errno.rs
@@ -69,7 +69,7 @@ impl Errno {
// TODO: Use Range::contains, once that's `const`.
const_assert!(encoded >= 0xf001);
- // Safety: Linux syscalls return negated error values in the range
+ // SAFETY: Linux syscalls return negated error values in the range
// `-4095..0`, which we just asserted.
unsafe { Self(encoded) }
}
@@ -82,7 +82,7 @@ pub(in crate::backend) fn try_decode_c_int<Num: RetNumber>(
raw: RetReg<Num>,
) -> io::Result<c::c_int> {
if raw.is_in_range(-4095..0) {
- // Safety: `raw` must be in `-4095..0`, and we just checked that raw is
+ // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
// in that range.
return Err(unsafe { Errno(raw.decode_error_code()) });
}
@@ -97,7 +97,7 @@ pub(in crate::backend) fn try_decode_c_uint<Num: RetNumber>(
raw: RetReg<Num>,
) -> io::Result<c::c_uint> {
if raw.is_in_range(-4095..0) {
- // Safety: `raw` must be in `-4095..0`, and we just checked that raw is
+ // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
// in that range.
return Err(unsafe { Errno(raw.decode_error_code()) });
}
@@ -110,7 +110,7 @@ pub(in crate::backend) fn try_decode_c_uint<Num: RetNumber>(
#[inline]
pub(in crate::backend) fn try_decode_usize<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<usize> {
if raw.is_in_range(-4095..0) {
- // Safety: `raw` must be in `-4095..0`, and we just checked that raw is
+ // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
// in that range.
return Err(unsafe { Errno(raw.decode_error_code()) });
}
@@ -125,7 +125,7 @@ pub(in crate::backend) fn try_decode_void_star<Num: RetNumber>(
raw: RetReg<Num>,
) -> io::Result<*mut c::c_void> {
if raw.is_in_range(-4095..0) {
- // Safety: `raw` must be in `-4095..0`, and we just checked that raw is
+ // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
// in that range.
return Err(unsafe { Errno(raw.decode_error_code()) });
}
@@ -139,7 +139,7 @@ pub(in crate::backend) fn try_decode_void_star<Num: RetNumber>(
#[inline]
pub(in crate::backend) fn try_decode_u64<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<u64> {
if raw.is_in_range(-4095..0) {
- // Safety: `raw` must be in `-4095..0`, and we just checked that raw is
+ // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
// in that range.
return Err(unsafe { Errno(raw.decode_error_code()) });
}
@@ -236,6 +236,13 @@ pub(in crate::backend) fn decode_usize_infallible<Num: RetNumber>(raw: RetReg<Nu
raw.decode_usize()
}
+/// Return the contained `c_int` value.
+#[cfg(not(debug_assertions))]
+#[inline]
+pub(in crate::backend) fn decode_c_uint_infallible<Num: RetNumber>(raw: RetReg<Num>) -> c::c_uint {
+ raw.decode_c_uint()
+}
+
impl Errno {
/// `EACCES`
#[doc(alias = "ACCES")]
diff --git a/vendor/rustix/src/backend/linux_raw/io/syscalls.rs b/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
index 2cc7898af..3acf9ffdb 100644
--- a/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/syscalls.rs
@@ -32,7 +32,7 @@ use linux_raw_sys::general::{
epoll_event, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD,
UIO_MAXIOV,
};
-use linux_raw_sys::ioctl::{BLKPBSZGET, BLKSSZGET, FIONBIO, FIONREAD, TIOCEXCL, TIOCNXCL};
+use linux_raw_sys::ioctl::{BLKPBSZGET, BLKSSZGET, FICLONE, FIONBIO, FIONREAD, TIOCEXCL, TIOCNXCL};
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
use {
super::super::conv::{opt_ref, size_of},
@@ -352,6 +352,11 @@ pub(crate) fn ioctl_blkpbszget(fd: BorrowedFd) -> io::Result<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)) }
+}
+
#[cfg(all(feature = "fs", feature = "net"))]
pub(crate) fn is_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> {
let (mut read, mut write) = crate::fs::fd::_is_file_read_write(fd)?;
diff --git a/vendor/rustix/src/backend/linux_raw/io/types.rs b/vendor/rustix/src/backend/linux_raw/io/types.rs
index 51ab61d94..cb6c6acef 100644
--- a/vendor/rustix/src/backend/linux_raw/io/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/io/types.rs
@@ -94,9 +94,10 @@ pub(crate) const STDOUT_FILENO: c::c_uint = linux_raw_sys::general::STDOUT_FILEN
pub(crate) const STDERR_FILENO: c::c_uint = linux_raw_sys::general::STDERR_FILENO;
/// A buffer type used with `vmsplice`.
-/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms and WSABUF on Windows.
-/// Unlike `IoSlice` and `IoSliceMut` it is semantically like a raw pointer,
-/// and therefore can be shared or mutated as needed.
+/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms
+/// and `WSABUF` on Windows. Unlike `IoSlice` and `IoSliceMut` it is
+/// semantically like a raw pointer, and therefore can be shared or mutated as
+/// needed.
#[repr(transparent)]
pub struct IoSliceRaw<'a> {
_buf: c::iovec,
@@ -104,7 +105,7 @@ pub struct IoSliceRaw<'a> {
}
impl<'a> IoSliceRaw<'a> {
- /// Creates a new IoSlice wrapping a byte slice.
+ /// Creates a new `IoSlice` wrapping a byte slice.
pub fn from_slice(buf: &'a [u8]) -> Self {
IoSliceRaw {
_buf: c::iovec {
@@ -115,7 +116,7 @@ impl<'a> IoSliceRaw<'a> {
}
}
- /// Creates a new IoSlice wrapping a mutable byte slice.
+ /// Creates a new `IoSlice` wrapping a mutable byte slice.
pub fn from_slice_mut(buf: &'a mut [u8]) -> Self {
IoSliceRaw {
_buf: c::iovec {
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 196676985..16655fe77 100644
--- a/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/io_uring/syscalls.rs
@@ -6,7 +6,7 @@
#![allow(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)]
-use super::super::conv::{by_mut, c_uint, pass_usize, ret, ret_c_uint, ret_owned_fd};
+use super::super::conv::{by_mut, c_uint, pass_usize, ret_c_uint, ret_owned_fd};
use crate::fd::{BorrowedFd, OwnedFd};
use crate::io;
use crate::io_uring::{io_uring_params, IoringEnterFlags, IoringRegisterOp};
@@ -29,8 +29,8 @@ pub(crate) unsafe fn io_uring_register(
opcode: IoringRegisterOp,
arg: *const c_void,
nr_args: u32,
-) -> io::Result<()> {
- ret(syscall_readonly!(
+) -> io::Result<u32> {
+ ret_c_uint(syscall_readonly!(
__NR_io_uring_register,
fd,
c_uint(opcode as u32),
diff --git a/vendor/rustix/src/backend/linux_raw/mod.rs b/vendor/rustix/src/backend/linux_raw/mod.rs
index e7e073e32..1b91fc3ab 100644
--- a/vendor/rustix/src/backend/linux_raw/mod.rs
+++ b/vendor/rustix/src/backend/linux_raw/mod.rs
@@ -14,6 +14,11 @@
//! such as which pointers are array slices, out parameters, or in-out
//! parameters, which integers are owned or borrowed file descriptors, etc.
+// Weak symbols used by the use-libc-auxv feature for glibc 2.15 support.
+#[cfg(feature = "use-libc-auxv")]
+#[macro_use]
+mod weak;
+
#[macro_use]
mod arch;
mod conv;
diff --git a/vendor/rustix/src/backend/linux_raw/net/addr.rs b/vendor/rustix/src/backend/linux_raw/net/addr.rs
index d5683f34e..b69c6deca 100644
--- a/vendor/rustix/src/backend/linux_raw/net/addr.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/addr.rs
@@ -71,7 +71,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] != b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`. And
// `from_bytes_with_nul_unchecked` since the string is NUL-terminated.
unsafe {
Some(CStr::from_bytes_with_nul_unchecked(slice::from_raw_parts(
@@ -91,7 +91,7 @@ impl SocketAddrUnix {
if len != 0 && self.unix.sun_path[0] == b'\0' as c::c_char {
let end = len as usize - offsetof_sun_path();
let bytes = &self.unix.sun_path[1..end];
- // Safety: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
+ // SAFETY: `from_raw_parts` to convert from `&[c_char]` to `&[u8]`.
unsafe { Some(slice::from_raw_parts(bytes.as_ptr().cast(), bytes.len())) }
} else {
None
diff --git a/vendor/rustix/src/backend/linux_raw/net/syscalls.rs b/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
index 7b9947a03..6093cd3a5 100644
--- a/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/net/syscalls.rs
@@ -1066,6 +1066,16 @@ pub(crate) mod sockopt {
}
#[inline]
+ pub(crate) fn get_socket_error(fd: BorrowedFd<'_>) -> io::Result<Result<(), crate::io::Errno>> {
+ let err: c::c_int = getsockopt(fd, c::SOL_SOCKET as _, c::SO_ERROR)?;
+ Ok(if err == 0 {
+ Ok(())
+ } else {
+ Err(crate::io::Errno::from_raw_os_error(err))
+ })
+ }
+
+ #[inline]
pub(crate) fn set_ip_ttl(fd: BorrowedFd<'_>, ttl: u32) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_IP as _, c::IP_TTL, ttl)
}
diff --git a/vendor/rustix/src/backend/linux_raw/param/auxv.rs b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
index acdd9d0e7..741a0564f 100644
--- a/vendor/rustix/src/backend/linux_raw/param/auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/auxv.rs
@@ -77,7 +77,7 @@ pub(crate) fn linux_execfn() -> &'static CStr {
execfn = EXECFN.load(Relaxed);
}
- // Safety: We assume the `AT_EXECFN` value provided by the kernel is a
+ // SAFETY: We assume the `AT_EXECFN` value provided by the kernel is a
// valid pointer to a valid NUL-terminated array of bytes.
unsafe { CStr::from_ptr(execfn.cast()) }
}
@@ -102,7 +102,7 @@ pub(crate) fn exe_phdrs() -> (*const c::c_void, usize) {
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
+ // 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) }
}
@@ -177,7 +177,7 @@ fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
buffer.resize(cur + n, 0_u8);
}
- // Safety: We loaded from an auxv file into the buffer.
+ // SAFETY: We loaded from an auxv file into the buffer.
unsafe { init_from_auxp(buffer.as_ptr().cast()) }
}
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 1597fd727..a8e291ff6 100644
--- a/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/libc_auxv.rs
@@ -5,14 +5,15 @@
//! This uses raw pointers to locate and read the kernel-provided auxv array.
#![allow(unsafe_code)]
-#[cfg(any(feature = "param", feature = "runtime"))]
-use super::super::c;
use super::super::elf::*;
#[cfg(feature = "param")]
use crate::ffi::CStr;
#[cfg(feature = "runtime")]
use core::slice;
+// `getauxval` wasn't supported in glibc until 2.16.
+weak!(fn getauxval(libc::c_ulong) -> *mut libc::c_void);
+
#[cfg(feature = "param")]
#[inline]
pub(crate) fn page_size() -> usize {
@@ -22,35 +23,39 @@ pub(crate) fn page_size() -> usize {
#[cfg(feature = "param")]
#[inline]
pub(crate) fn clock_ticks_per_second() -> u64 {
- unsafe { libc::getauxval(libc::AT_CLKTCK) as u64 }
+ unsafe { libc::sysconf(libc::_SC_CLK_TCK) as u64 }
}
#[cfg(feature = "param")]
#[inline]
pub(crate) fn linux_hwcap() -> (usize, usize) {
- unsafe {
- (
- libc::getauxval(libc::AT_HWCAP) as usize,
- libc::getauxval(libc::AT_HWCAP2) as usize,
- )
+ if let Some(libc_getauxval) = getauxval.get() {
+ unsafe {
+ let hwcap = libc_getauxval(libc::AT_HWCAP) as usize;
+ let hwcap2 = libc_getauxval(libc::AT_HWCAP2) as usize;
+ (hwcap, hwcap2)
+ }
+ } else {
+ (0, 0)
}
}
#[cfg(feature = "param")]
#[inline]
pub(crate) fn linux_execfn() -> &'static CStr {
- unsafe {
- let execfn = libc::getauxval(libc::AT_EXECFN) as *const c::c_char;
- CStr::from_ptr(execfn.cast())
+ if let Some(libc_getauxval) = getauxval.get() {
+ unsafe { CStr::from_ptr(libc_getauxval(libc::AT_EXECFN).cast()) }
+ } else {
+ cstr!("")
}
}
#[cfg(feature = "runtime")]
#[inline]
-pub(crate) fn exe_phdrs() -> (*const c::c_void, usize) {
+pub(crate) fn exe_phdrs() -> (*const libc::c_void, usize) {
unsafe {
(
- libc::getauxval(libc::AT_PHDR) as *const c::c_void,
+ libc::getauxval(libc::AT_PHDR) as *const libc::c_void,
libc::getauxval(libc::AT_PHNUM) as usize,
)
}
@@ -61,7 +66,7 @@ pub(crate) fn exe_phdrs() -> (*const c::c_void, usize) {
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
+ // 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) }
}
@@ -70,5 +75,9 @@ pub(in super::super) fn exe_phdrs_slice() -> &'static [Elf_Phdr] {
/// 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 { libc::getauxval(linux_raw_sys::general::AT_SYSINFO_EHDR.into()) as *const Elf_Ehdr }
+ if let Some(libc_getauxval) = getauxval.get() {
+ unsafe { libc_getauxval(linux_raw_sys::general::AT_SYSINFO_EHDR.into()) as *const Elf_Ehdr }
+ } else {
+ core::ptr::null()
+ }
}
diff --git a/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs b/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs
index e9b89b500..49cb1457c 100644
--- a/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs
+++ b/vendor/rustix/src/backend/linux_raw/param/mustang_auxv.rs
@@ -22,28 +22,28 @@ use linux_raw_sys::general::{
#[cfg(feature = "param")]
#[inline]
pub(crate) fn page_size() -> usize {
- // Safety: This is initialized during program startup.
+ // 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.
+ // 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.
+ // 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
+ // 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()) }
}
@@ -51,7 +51,7 @@ pub(crate) fn linux_execfn() -> &'static CStr {
#[cfg(feature = "runtime")]
#[inline]
pub(crate) fn exe_phdrs() -> (*const c_void, usize) {
- // Safety: This is initialized during program startup.
+ // SAFETY: This is initialized during program startup.
unsafe { (PHDR.0.cast(), PHNUM) }
}
@@ -60,7 +60,7 @@ pub(crate) fn exe_phdrs() -> (*const c_void, usize) {
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
+ // 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) }
}
@@ -69,7 +69,7 @@ pub(in super::super) fn exe_phdrs_slice() -> &'static [Elf_Phdr] {
/// 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.
+ // SAFETY: This is initialized during program startup.
unsafe { SYSINFO_EHDR.0 }
}
diff --git a/vendor/rustix/src/backend/linux_raw/process/cpu_set.rs b/vendor/rustix/src/backend/linux_raw/process/cpu_set.rs
index 10c5f478e..fc81859d8 100644
--- a/vendor/rustix/src/backend/linux_raw/process/cpu_set.rs
+++ b/vendor/rustix/src/backend/linux_raw/process/cpu_set.rs
@@ -1,3 +1,5 @@
+//! Rust implementation of the `CPU_*` macro API.
+
#![allow(non_snake_case)]
use super::types::RawCpuSet;
diff --git a/vendor/rustix/src/backend/linux_raw/process/syscalls.rs b/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
index ac62e6944..f86f8e5b9 100644
--- a/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/process/syscalls.rs
@@ -12,12 +12,13 @@ use super::super::conv::{
ret_infallible, ret_usize, ret_usize_infallible, size_of, slice_just_addr, slice_mut, zero,
};
use super::types::{RawCpuSet, RawUname};
-use crate::fd::BorrowedFd;
+use crate::backend::conv::ret_owned_fd;
+use crate::fd::{AsRawFd, BorrowedFd, OwnedFd};
use crate::ffi::CStr;
use crate::io;
use crate::process::{
- Cpuid, Gid, MembarrierCommand, MembarrierQuery, Pid, RawNonZeroPid, RawPid, Resource, Rlimit,
- Signal, Uid, WaitOptions, WaitStatus,
+ Cpuid, Gid, MembarrierCommand, MembarrierQuery, Pid, PidfdFlags, RawNonZeroPid, RawPid,
+ Resource, Rlimit, Signal, Uid, WaitId, WaitOptions, WaitStatus, WaitidOptions, WaitidStatus,
};
use core::convert::TryInto;
use core::mem::MaybeUninit;
@@ -27,6 +28,9 @@ use linux_raw_sys::general::{
__kernel_gid_t, __kernel_pid_t, __kernel_uid_t, membarrier_cmd, membarrier_cmd_flag, rlimit,
rlimit64, PRIO_PGRP, PRIO_PROCESS, PRIO_USER, RLIM64_INFINITY, RLIM_INFINITY,
};
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "fs")]
+use {super::super::conv::ret_c_uint_infallible, crate::fs::Mode};
#[inline]
pub(crate) fn chdir(filename: &CStr) -> io::Result<()> {
@@ -53,7 +57,7 @@ pub(crate) fn membarrier_query() -> MembarrierQuery {
c_uint(0)
)) {
Ok(query) => {
- // Safety: The safety of `from_bits_unchecked` is discussed
+ // SAFETY: The safety of `from_bits_unchecked` is discussed
// [here]. Our "source of truth" is Linux, and here, the
// `query` value is coming from Linux, so we know it only
// contains "source of truth" valid bits.
@@ -235,11 +239,20 @@ pub(crate) fn sched_yield() {
pub(crate) fn uname() -> RawUname {
let mut uname = MaybeUninit::<RawUname>::uninit();
unsafe {
- ret(syscall!(__NR_uname, &mut uname)).unwrap();
+ ret_infallible(syscall!(__NR_uname, &mut uname));
uname.assume_init()
}
}
+#[cfg(feature = "fs")]
+#[inline]
+pub(crate) fn umask(mode: Mode) -> Mode {
+ unsafe {
+ // TODO: Use `from_bits_retain` when we switch to bitflags 2.0.
+ Mode::from_bits_truncate(ret_c_uint_infallible(syscall_readonly!(__NR_umask, mode)))
+ }
+}
+
#[inline]
pub(crate) fn nice(inc: i32) -> io::Result<i32> {
let priority = if inc > -40 && inc < 40 {
@@ -516,6 +529,83 @@ pub(crate) fn _waitpid(
}
}
+#[inline]
+pub(crate) fn waitid(id: WaitId<'_>, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ // Get the id to wait on.
+ match id {
+ WaitId::All => _waitid_all(options),
+ WaitId::Pid(pid) => _waitid_pid(pid, options),
+ WaitId::PidFd(fd) => _waitid_pidfd(fd, options),
+ }
+}
+
+#[inline]
+fn _waitid_all(options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(syscall!(
+ __NR_waitid,
+ c_uint(c::P_ALL),
+ c_uint(0),
+ by_mut(&mut status),
+ c_int(options.bits() as _),
+ zero()
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+#[inline]
+fn _waitid_pid(pid: Pid, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(syscall!(
+ __NR_waitid,
+ c_uint(c::P_PID),
+ c_uint(Pid::as_raw(Some(pid))),
+ by_mut(&mut status),
+ c_int(options.bits() as _),
+ zero()
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+#[inline]
+fn _waitid_pidfd(fd: BorrowedFd<'_>, options: WaitidOptions) -> io::Result<Option<WaitidStatus>> {
+ let mut status = MaybeUninit::<c::siginfo_t>::uninit();
+ unsafe {
+ ret(syscall!(
+ __NR_waitid,
+ c_uint(c::P_PIDFD),
+ c_uint(fd.as_raw_fd() as _),
+ by_mut(&mut status),
+ c_int(options.bits() as _),
+ zero()
+ ))?
+ };
+
+ Ok(unsafe { cvt_waitid_status(status) })
+}
+
+/// Convert a `siginfo_t` to a `WaitidStatus`.
+///
+/// # Safety
+///
+/// The caller must ensure that `status` is initialized and that `waitid`
+/// returned successfully.
+#[inline]
+unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitidStatus> {
+ let status = status.assume_init();
+ if status.__bindgen_anon_1.__bindgen_anon_1.si_signo == 0 {
+ None
+ } else {
+ Some(WaitidStatus(status))
+ }
+}
+
#[cfg(feature = "runtime")]
#[inline]
pub(crate) fn exit_group(code: c::c_int) -> ! {
@@ -558,3 +648,14 @@ pub(crate) unsafe fn prctl(
) -> io::Result<c::c_int> {
ret_c_int(syscall!(__NR_prctl, c_int(option), arg2, arg3, arg4, arg5))
}
+
+#[inline]
+pub(crate) fn pidfd_open(pid: Pid, flags: PidfdFlags) -> io::Result<OwnedFd> {
+ unsafe {
+ ret_owned_fd(syscall_readonly!(
+ __NR_pidfd_open,
+ pid,
+ c_int(flags.bits() as _)
+ ))
+ }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/process/wait.rs b/vendor/rustix/src/backend/linux_raw/process/wait.rs
index 701b4ac0c..edc564a9f 100644
--- a/vendor/rustix/src/backend/linux_raw/process/wait.rs
+++ b/vendor/rustix/src/backend/linux_raw/process/wait.rs
@@ -1,7 +1,9 @@
// The functions replacing the C macros use the same names as in libc.
#![allow(non_snake_case)]
-pub(crate) use linux_raw_sys::general::{WCONTINUED, WNOHANG, WUNTRACED};
+pub(crate) use linux_raw_sys::general::{
+ WCONTINUED, WEXITED, WNOHANG, WNOWAIT, WSTOPPED, WUNTRACED,
+};
#[inline]
pub(crate) fn WIFSTOPPED(status: u32) -> bool {
diff --git a/vendor/rustix/src/backend/linux_raw/runtime/tls.rs b/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
index 43ed25d7d..8cc156a71 100644
--- a/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
+++ b/vendor/rustix/src/backend/linux_raw/runtime/tls.rs
@@ -1,3 +1,9 @@
+//! TLS utilities.
+//!
+//! # Safety
+//!
+//! This file contains code that reads the raw phdr array pointed to by the
+//! kernel-provided AUXV values.
#![allow(unsafe_code)]
use super::super::c;
@@ -18,7 +24,7 @@ pub(crate) fn startup_tls_info() -> StartupTlsInfo {
let phdrs = exe_phdrs_slice();
- // Safety: We assume the phdr array pointer and length the kernel provided
+ // 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 {
diff --git a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
index a8dda5f81..f5643f3c3 100644
--- a/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/termios/syscalls.rs
@@ -42,6 +42,30 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
}
#[inline]
+#[cfg(any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+))]
+pub(crate) fn tcgetattr2(fd: BorrowedFd<'_>) -> io::Result<crate::termios::Termios2> {
+ unsafe {
+ let mut result = MaybeUninit::<crate::termios::Termios2>::uninit();
+ ret(syscall!(
+ __NR_ioctl,
+ fd,
+ c_uint(linux_raw_sys::ioctl::TCGETS2),
+ &mut result
+ ))?;
+ Ok(result.assume_init())
+ }
+}
+
+#[inline]
pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
unsafe {
let mut result = MaybeUninit::<__kernel_pid_t>::uninit();
@@ -78,6 +102,32 @@ pub(crate) fn tcsetattr(
}
#[inline]
+#[cfg(any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+))]
+pub(crate) fn tcsetattr2(
+ fd: BorrowedFd,
+ optional_actions: OptionalActions,
+ termios: &crate::termios::Termios2,
+) -> io::Result<()> {
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_ioctl,
+ fd,
+ c_uint(linux_raw_sys::ioctl::TCSETS2 + optional_actions as u32),
+ by_ref(termios)
+ ))
+ }
+}
+
+#[inline]
pub(crate) fn tcsendbreak(fd: BorrowedFd) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_ioctl, fd, c_uint(TCSBRK), c_uint(0))) }
}
diff --git a/vendor/rustix/src/backend/linux_raw/termios/types.rs b/vendor/rustix/src/backend/linux_raw/termios/types.rs
index a44f1eda5..3fe45af98 100644
--- a/vendor/rustix/src/backend/linux_raw/termios/types.rs
+++ b/vendor/rustix/src/backend/linux_raw/termios/types.rs
@@ -7,13 +7,16 @@ use super::super::c;
#[repr(u32)]
pub enum OptionalActions {
/// `TCSANOW`—Make the change immediately.
+ #[doc(alias = "TCSANOW")]
Now = linux_raw_sys::general::TCSANOW,
/// `TCSADRAIN`—Make the change after all output has been transmitted.
+ #[doc(alias = "TCSADRAIN")]
Drain = linux_raw_sys::general::TCSADRAIN,
/// `TCSAFLUSH`—Discard any pending input and then make the change
/// after all output has been transmitted.
+ #[doc(alias = "TCSAFLUSH")]
Flush = linux_raw_sys::general::TCSAFLUSH,
}
@@ -24,12 +27,15 @@ pub enum OptionalActions {
#[repr(u32)]
pub enum QueueSelector {
/// `TCIFLUSH`—Flush data received but not read.
+ #[doc(alias = "TCIFLUSH")]
IFlush = linux_raw_sys::general::TCIFLUSH,
/// `TCOFLUSH`—Flush data written but not transmitted.
+ #[doc(alias = "TCOFLUSH")]
OFlush = linux_raw_sys::general::TCOFLUSH,
/// `TCIOFLUSH`—`IFlush` and `OFlush` combined.
+ #[doc(alias = "TCIOFLUSH")]
IOFlush = linux_raw_sys::general::TCIOFLUSH,
}
@@ -40,34 +46,60 @@ pub enum QueueSelector {
#[repr(u32)]
pub enum Action {
/// `TCOOFF`—Suspend output.
+ #[doc(alias = "TCOOFF")]
OOff = linux_raw_sys::general::TCOOFF,
/// `TCOON`—Restart suspended output.
+ #[doc(alias = "TCOON")]
OOn = linux_raw_sys::general::TCOON,
/// `TCIOFF`—Transmits a STOP byte.
+ #[doc(alias = "TCIOFF")]
IOff = linux_raw_sys::general::TCIOFF,
/// `TCION`—Transmits a START byte.
+ #[doc(alias = "TCION")]
IOn = linux_raw_sys::general::TCION,
}
-/// `struct termios` for use with [`tcgetattr`].
+/// `struct termios` for use with [`tcgetattr`] and [`tcsetattr`].
///
/// [`tcgetattr`]: crate::termios::tcgetattr
+/// [`tcsetattr`]: crate::termios::tcsetattr
+#[doc(alias = "termios")]
pub type Termios = linux_raw_sys::general::termios;
+/// `struct termios2` for use with [`tcgetattr2`] and [`tcsetattr2`].
+///
+/// [`tcgetattr2`]: crate::termios::tcgetattr2
+/// [`tcsetattr2`]: crate::termios::tcsetattr2
+#[cfg(any(
+ target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "x32",
+ target_arch = "riscv64",
+ target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "mips64",
+))]
+#[doc(alias = "termios2")]
+pub type Termios2 = linux_raw_sys::general::termios2;
+
/// `struct winsize` for use with [`tcgetwinsize`].
///
/// [`tcgetwinsize`]: crate::termios::tcgetwinsize
+#[doc(alias = "winsize")]
pub type Winsize = linux_raw_sys::general::winsize;
/// `tcflag_t`—A type for the flags fields of [`Termios`].
+#[doc(alias = "tcflag_t")]
pub type Tcflag = linux_raw_sys::general::tcflag_t;
/// `speed_t`—A return type for [`cfsetspeed`] and similar.
///
/// [`cfsetspeed`]: crate::termios::cfsetspeed
+#[doc(alias = "speed_t")]
pub type Speed = linux_raw_sys::general::speed_t;
/// `VINTR`
@@ -353,6 +385,9 @@ pub const B3500000: Speed = linux_raw_sys::general::B3500000;
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))]
pub const B4000000: Speed = linux_raw_sys::general::B4000000;
+/// `BOTHER`
+pub const BOTHER: c::c_uint = linux_raw_sys::general::BOTHER;
+
/// `CSIZE`
pub const CSIZE: c::c_uint = linux_raw_sys::general::CSIZE;
diff --git a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
index 2ec3e43e8..af2c9ee8a 100644
--- a/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/thread/syscalls.rs
@@ -294,3 +294,65 @@ pub(crate) fn setns(fd: BorrowedFd, nstype: c::c_int) -> io::Result<c::c_int> {
pub(crate) fn unshare(flags: crate::thread::UnshareFlags) -> io::Result<()> {
unsafe { ret(syscall_readonly!(__NR_unshare, c_uint(flags.bits()))) }
}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn capget(
+ header: &mut linux_raw_sys::general::__user_cap_header_struct,
+ data: &mut [MaybeUninit<linux_raw_sys::general::__user_cap_data_struct>],
+) -> io::Result<()> {
+ let header: *mut _ = header;
+ unsafe { ret(syscall!(__NR_capget, header, data.as_mut_ptr())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn capset(
+ header: &mut linux_raw_sys::general::__user_cap_header_struct,
+ data: &[linux_raw_sys::general::__user_cap_data_struct],
+) -> io::Result<()> {
+ let header: *mut _ = header;
+ unsafe { ret(syscall!(__NR_capset, header, data.as_ptr())) }
+}
+
+#[inline]
+pub(crate) fn setuid_thread(uid: crate::process::Uid) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_setuid, uid)) }
+}
+
+#[inline]
+pub(crate) fn setresuid_thread(
+ ruid: crate::process::Uid,
+ euid: crate::process::Uid,
+ suid: crate::process::Uid,
+) -> io::Result<()> {
+ #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc"))]
+ unsafe {
+ ret(syscall_readonly!(__NR_setresuid32, ruid, euid, suid))
+ }
+ #[cfg(not(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc")))]
+ unsafe {
+ ret(syscall_readonly!(__NR_setresuid, ruid, euid, suid))
+ }
+}
+
+#[inline]
+pub(crate) fn setgid_thread(gid: crate::process::Gid) -> io::Result<()> {
+ unsafe { ret(syscall_readonly!(__NR_setgid, gid)) }
+}
+
+#[inline]
+pub(crate) fn setresgid_thread(
+ rgid: crate::process::Gid,
+ egid: crate::process::Gid,
+ sgid: crate::process::Gid,
+) -> io::Result<()> {
+ #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc"))]
+ unsafe {
+ ret(syscall_readonly!(__NR_setresgid32, rgid, egid, sgid))
+ }
+ #[cfg(not(any(target_arch = "x86", target_arch = "arm", target_arch = "sparc")))]
+ unsafe {
+ ret(syscall_readonly!(__NR_setresgid, rgid, egid, sgid))
+ }
+}
diff --git a/vendor/rustix/src/backend/linux_raw/time/syscalls.rs b/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
index 6e73a921b..c039393ef 100644
--- a/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
+++ b/vendor/rustix/src/backend/linux_raw/time/syscalls.rs
@@ -67,6 +67,47 @@ unsafe fn clock_getres_old(which_clock: ClockId, result: &mut MaybeUninit<__kern
#[cfg(feature = "time")]
#[inline]
+pub(crate) fn clock_settime(which_clock: ClockId, timespec: __kernel_timespec) -> io::Result<()> {
+ #[cfg(target_pointer_width = "32")]
+ unsafe {
+ match ret(syscall_readonly!(
+ __NR_clock_settime64,
+ which_clock,
+ by_ref(&timespec)
+ )) {
+ Err(io::Errno::NOSYS) => clock_settime_old(which_clock, timespec),
+ otherwise => otherwise,
+ }
+ }
+ #[cfg(target_pointer_width = "64")]
+ unsafe {
+ ret(syscall_readonly!(
+ __NR_clock_settime,
+ which_clock,
+ by_ref(&timespec)
+ ))
+ }
+}
+
+#[cfg(feature = "time")]
+#[cfg(target_pointer_width = "32")]
+unsafe fn clock_settime_old(which_clock: ClockId, timespec: __kernel_timespec) -> io::Result<()> {
+ let old_timespec = __kernel_old_timespec {
+ tv_sec: timespec
+ .tv_sec
+ .try_into()
+ .map_err(|_| io::Errno::OVERFLOW)?,
+ tv_nsec: timespec.tv_nsec as _,
+ };
+ ret(syscall_readonly!(
+ __NR_clock_settime,
+ which_clock,
+ by_ref(&old_timespec)
+ ))
+}
+
+#[cfg(feature = "time")]
+#[inline]
pub(crate) fn timerfd_create(clockid: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
unsafe { ret_owned_fd(syscall!(__NR_timerfd_create, clockid, flags)) }
}
diff --git a/vendor/rustix/src/backend/linux_raw/vdso.rs b/vendor/rustix/src/backend/linux_raw/vdso.rs
index da7910b88..480378b50 100644
--- a/vendor/rustix/src/backend/linux_raw/vdso.rs
+++ b/vendor/rustix/src/backend/linux_raw/vdso.rs
@@ -55,7 +55,7 @@ fn elf_hash(name: &CStr) -> u32 {
/// Create a `Vdso` value by parsing the vDSO at the `sysinfo_ehdr` address.
fn init_from_sysinfo_ehdr() -> Option<Vdso> {
- // Safety: the auxv initialization code does extensive checks to ensure
+ // SAFETY: the auxv initialization code does extensive checks to ensure
// that the value we get really is an `AT_SYSINFO_EHDR` value from the
// kernel.
unsafe {
@@ -255,7 +255,7 @@ impl Vdso {
let ver_hash = elf_hash(version);
let name_hash = elf_hash(name);
- // Safety: The pointers in `self` must be valid.
+ // SAFETY: The pointers in `self` must be valid.
unsafe {
let mut chain = *self.bucket.add((name_hash % self.nbucket) as usize);
diff --git a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
index aaa000622..5b2e084ea 100644
--- a/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
+++ b/vendor/rustix/src/backend/linux_raw/vdso_wrappers.rs
@@ -27,7 +27,7 @@ use linux_raw_sys::general::{__kernel_clockid_t, __kernel_timespec};
#[inline]
pub(crate) fn clock_gettime(which_clock: ClockId) -> __kernel_timespec {
- // Safety: `CLOCK_GETTIME` contains either null or the address of a
+ // SAFETY: `CLOCK_GETTIME` contains either null or the address of a
// function with an ABI like libc `clock_gettime`, and calling it has
// the side effect of writing to the result buffer, and no others.
unsafe {
@@ -64,7 +64,7 @@ pub(crate) fn clock_gettime_dynamic(which_clock: DynamicClockId<'_>) -> io::Resu
}
};
- // Safety: `CLOCK_GETTIME` contains either null or the address of a
+ // SAFETY: `CLOCK_GETTIME` contains either null or the address of a
// function with an ABI like libc `clock_gettime`, and calling it has
// the side effect of writing to the result buffer, and no others.
unsafe {
@@ -217,7 +217,7 @@ pub(super) type SyscallType = unsafe extern "C" fn();
/// Initialize `CLOCK_GETTIME` and return its value.
fn init_clock_gettime() -> ClockGettimeType {
init();
- // Safety: Load the function address from static storage that we
+ // SAFETY: Load the function address from static storage that we
// just initialized.
unsafe { transmute(CLOCK_GETTIME.load(Relaxed)) }
}
@@ -226,7 +226,7 @@ fn init_clock_gettime() -> ClockGettimeType {
#[cfg(target_arch = "x86")]
fn init_syscall() -> SyscallType {
init();
- // Safety: Load the function address from static storage that we
+ // SAFETY: Load the function address from static storage that we
// just initialized.
unsafe { transmute(SYSCALL.load(Relaxed)) }
}
@@ -309,7 +309,7 @@ extern "C" {
}
fn minimal_init() {
- // Safety: Store default function addresses in static storage so that if we
+ // SAFETY: Store default function addresses in static storage so that if we
// end up making any system calls while we read the vDSO, they'll work.
// If the memory happens to already be initialized, this is redundant, but
// not harmful.
@@ -375,7 +375,7 @@ fn init() {
if ok {
assert!(!ptr.is_null());
- // Safety: Store the computed function addresses in static storage
+ // SAFETY: Store the computed function addresses in static storage
// so that we don't need to compute it again (but if we do, it doesn't
// hurt anything).
unsafe {
@@ -389,7 +389,7 @@ fn init() {
let ptr = vdso.sym(cstr!("LINUX_2.5"), cstr!("__kernel_vsyscall"));
assert!(!ptr.is_null());
- // Safety: As above, store the computed function addresses in
+ // SAFETY: As above, store the computed function addresses in
// static storage.
unsafe {
SYSCALL.store(ptr.cast(), Relaxed);
diff --git a/vendor/rustix/src/backend/linux_raw/weak.rs b/vendor/rustix/src/backend/linux_raw/weak.rs
new file mode 100644
index 000000000..ae7d6832e
--- /dev/null
+++ b/vendor/rustix/src/backend/linux_raw/weak.rs
@@ -0,0 +1,228 @@
+// Implementation derived from `weak` in Rust's
+// library/std/src/sys/unix/weak.rs at revision
+// fd0cb0cdc21dd9c06025277d772108f8d42cb25f.
+
+#![allow(unsafe_code)]
+
+//! Support for "weak linkage" to symbols on Unix
+//!
+//! Some I/O operations we do in libstd require newer versions of OSes but we
+//! need to maintain binary compatibility with older releases for now. In order
+//! to use the new functionality when available we use this module for
+//! detection.
+//!
+//! One option to use here is weak linkage, but that is unfortunately only
+//! really workable on Linux. Hence, use dlsym to get the symbol value at
+//! runtime. This is also done for compatibility with older versions of glibc,
+//! and to avoid creating dependencies on `GLIBC_PRIVATE` symbols. It assumes
+//! that we've been dynamically linked to the library the symbol comes from,
+//! but that is currently always the case for things like libpthread/libc.
+//!
+//! A long time ago this used weak linkage for the `__pthread_get_minstack`
+//! symbol, but that caused Debian to detect an unnecessarily strict versioned
+//! dependency on libc6 (#23628).
+
+// There are a variety of `#[cfg]`s controlling which targets are involved in
+// each instance of `weak!` and `syscall!`. Rather than trying to unify all of
+// that, we'll just allow that some unix targets don't use this module at all.
+#![allow(dead_code, unused_macros)]
+#![allow(clippy::doc_markdown)]
+
+use crate::ffi::CStr;
+use core::ffi::c_void;
+use core::ptr::null_mut;
+use core::sync::atomic::{self, AtomicPtr, Ordering};
+use core::{marker, mem};
+
+const NULL: *mut c_void = null_mut();
+const INVALID: *mut c_void = 1 as *mut c_void;
+
+macro_rules! weak {
+ ($vis:vis fn $name:ident($($t:ty),*) -> $ret:ty) => (
+ #[allow(non_upper_case_globals)]
+ $vis static $name: $crate::backend::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
+ $crate::backend::weak::Weak::new(concat!(stringify!($name), '\0'));
+ )
+}
+
+pub(crate) struct Weak<F> {
+ name: &'static str,
+ addr: AtomicPtr<c_void>,
+ _marker: marker::PhantomData<F>,
+}
+
+impl<F> Weak<F> {
+ pub(crate) const fn new(name: &'static str) -> Self {
+ Self {
+ name,
+ addr: AtomicPtr::new(INVALID),
+ _marker: marker::PhantomData,
+ }
+ }
+
+ pub(crate) fn get(&self) -> Option<F> {
+ assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>());
+ unsafe {
+ // Relaxed is fine here because we fence before reading through the
+ // pointer (see the comment below).
+ match self.addr.load(Ordering::Relaxed) {
+ INVALID => self.initialize(),
+ NULL => None,
+ addr => {
+ let func = mem::transmute_copy::<*mut c_void, F>(&addr);
+ // The caller is presumably going to read through this value
+ // (by calling the function we've dlsymed). This means we'd
+ // need to have loaded it with at least C11's consume
+ // ordering in order to be guaranteed that the data we read
+ // from the pointer isn't from before the pointer was
+ // stored. Rust has no equivalent to memory_order_consume,
+ // so we use an acquire fence (sorry, ARM).
+ //
+ // Now, in practice this likely isn't needed even on CPUs
+ // where relaxed and consume mean different things. The
+ // symbols we're loading are probably present (or not) at
+ // init, and even if they aren't the runtime dynamic loader
+ // is extremely likely have sufficient barriers internally
+ // (possibly implicitly, for example the ones provided by
+ // invoking `mprotect`).
+ //
+ // That said, none of that's *guaranteed*, and so we fence.
+ atomic::fence(Ordering::Acquire);
+ Some(func)
+ }
+ }
+ }
+ }
+
+ // Cold because it should only happen during first-time initialization.
+ #[cold]
+ unsafe fn initialize(&self) -> Option<F> {
+ let val = fetch(self.name);
+ // This synchronizes with the acquire fence in `get`.
+ self.addr.store(val, Ordering::Release);
+
+ match val {
+ NULL => None,
+ addr => Some(mem::transmute_copy::<*mut c_void, F>(&addr)),
+ }
+ }
+}
+
+unsafe fn fetch(name: &str) -> *mut c_void {
+ let name = match CStr::from_bytes_with_nul(name.as_bytes()) {
+ Ok(c_str) => c_str,
+ Err(..) => return null_mut(),
+ };
+ libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr())
+}
+
+#[cfg(not(any(target_os = "android", target_os = "linux")))]
+macro_rules! syscall {
+ (fn $name:ident($($arg_name:ident: $t:ty),*) via $_sys_name:ident -> $ret:ty) => (
+ unsafe fn $name($($arg_name: $t),*) -> $ret {
+ weak! { fn $name($($t),*) -> $ret }
+
+ if let Some(fun) = $name.get() {
+ fun($($arg_name),*)
+ } else {
+ libc_errno::set_errno(libc_errno::Errno(libc::ENOSYS));
+ -1
+ }
+ }
+ )
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+macro_rules! syscall {
+ (fn $name:ident($($arg_name:ident: $t:ty),*) via $sys_name:ident -> $ret:ty) => (
+ unsafe fn $name($($arg_name:$t),*) -> $ret {
+ // This looks like a hack, but concat_idents only accepts idents
+ // (not paths).
+ use libc::*;
+
+ trait AsSyscallArg {
+ type SyscallArgType;
+ fn into_syscall_arg(self) -> Self::SyscallArgType;
+ }
+
+ // Pass pointer types as pointers, to preserve provenance.
+ impl<T> AsSyscallArg for *mut T {
+ type SyscallArgType = *mut T;
+ fn into_syscall_arg(self) -> Self::SyscallArgType { self }
+ }
+ impl<T> AsSyscallArg for *const T {
+ type SyscallArgType = *const T;
+ fn into_syscall_arg(self) -> Self::SyscallArgType { self }
+ }
+
+ // Pass `BorrowedFd` values as the integer value.
+ impl AsSyscallArg for $crate::fd::BorrowedFd<'_> {
+ type SyscallArgType = c::c_long;
+ fn into_syscall_arg(self) -> Self::SyscallArgType {
+ $crate::fd::AsRawFd::as_raw_fd(&self) as _
+ }
+ }
+
+ // Coerce integer values into `c_long`.
+ impl AsSyscallArg for i32 {
+ type SyscallArgType = c::c_long;
+ fn into_syscall_arg(self) -> Self::SyscallArgType { self as _ }
+ }
+ impl AsSyscallArg for u32 {
+ type SyscallArgType = c::c_long;
+ fn into_syscall_arg(self) -> Self::SyscallArgType { self as _ }
+ }
+ impl AsSyscallArg for usize {
+ type SyscallArgType = c::c_long;
+ fn into_syscall_arg(self) -> Self::SyscallArgType { self as _ }
+ }
+
+ // `concat_idents is unstable, so we take an extra `sys_name`
+ // parameter and have our users do the concat for us for now.
+ /*
+ syscall(
+ concat_idents!(SYS_, $name),
+ $($arg_name.into_syscall_arg()),*
+ ) as $ret
+ */
+
+ syscall($sys_name, $($arg_name.into_syscall_arg()),*) as $ret
+ }
+ )
+}
+
+macro_rules! weakcall {
+ ($vis:vis fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
+ $vis unsafe fn $name($($arg_name: $t),*) -> $ret {
+ weak! { fn $name($($t),*) -> $ret }
+
+ // Use a weak symbol from libc when possible, allowing `LD_PRELOAD`
+ // interposition, but if it's not found just fail.
+ if let Some(fun) = $name.get() {
+ fun($($arg_name),*)
+ } else {
+ libc_errno::set_errno(libc_errno::Errno(libc::ENOSYS));
+ -1
+ }
+ }
+ )
+}
+
+/// A combination of `weakcall` and `syscall`. Use the libc function if it's
+/// available, and fall back to `libc::syscall` otherwise.
+macro_rules! weak_or_syscall {
+ ($vis:vis fn $name:ident($($arg_name:ident: $t:ty),*) via $sys_name:ident -> $ret:ty) => (
+ $vis unsafe fn $name($($arg_name: $t),*) -> $ret {
+ weak! { fn $name($($t),*) -> $ret }
+
+ // Use a weak symbol from libc when possible, allowing `LD_PRELOAD`
+ // interposition, but if it's not found just fail.
+ if let Some(fun) = $name.get() {
+ fun($($arg_name),*)
+ } else {
+ syscall! { fn $name($($arg_name: $t),*) via $sys_name -> $ret }
+ $name($($arg_name),*)
+ }
+ }
+ )
+}