summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/rustix/src/backend/libc
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc')
-rw-r--r--vendor/rustix/src/backend/libc/c.rs4
-rw-r--r--vendor/rustix/src/backend/libc/event/epoll.rs4
-rw-r--r--vendor/rustix/src/backend/libc/event/poll_fd.rs2
-rw-r--r--vendor/rustix/src/backend/libc/event/syscalls.rs8
-rw-r--r--vendor/rustix/src/backend/libc/event/types.rs2
-rw-r--r--vendor/rustix/src/backend/libc/fs/dir.rs34
-rw-r--r--vendor/rustix/src/backend/libc/fs/syscalls.rs14
-rw-r--r--vendor/rustix/src/backend/libc/mm/types.rs35
-rw-r--r--vendor/rustix/src/backend/libc/mount/types.rs4
-rw-r--r--vendor/rustix/src/backend/libc/net/syscalls.rs4
-rw-r--r--vendor/rustix/src/backend/libc/pipe/types.rs6
-rw-r--r--vendor/rustix/src/backend/libc/process/mod.rs2
-rw-r--r--vendor/rustix/src/backend/libc/process/syscalls.rs14
-rw-r--r--vendor/rustix/src/backend/libc/process/types.rs10
-rw-r--r--vendor/rustix/src/backend/libc/termios/syscalls.rs9
-rw-r--r--vendor/rustix/src/backend/libc/time/types.rs9
16 files changed, 113 insertions, 48 deletions
diff --git a/vendor/rustix/src/backend/libc/c.rs b/vendor/rustix/src/backend/libc/c.rs
index f788cb120..d3a1e5f4a 100644
--- a/vendor/rustix/src/backend/libc/c.rs
+++ b/vendor/rustix/src/backend/libc/c.rs
@@ -130,8 +130,8 @@ pub(super) use libc::{
blksize64_t as blksize_t, fstat64 as fstat, fstatfs64 as fstatfs, fstatvfs64 as fstatvfs,
ftruncate64 as ftruncate, getrlimit64 as getrlimit, ino_t, lseek64 as lseek, mmap,
off64_t as off_t, openat, posix_fadvise64 as posix_fadvise, preadv, pwritev,
- rlimit64 as rlimit, setrlimit64 as setrlimit, statfs64 as statfs, statvfs64 as statvfs,
- RLIM_INFINITY,
+ rlimit64 as rlimit, setrlimit64 as setrlimit, stat64at as fstatat, statfs64 as statfs,
+ statvfs64 as statvfs, RLIM_INFINITY,
};
#[cfg(any(linux_like, target_os = "hurd"))]
pub(super) use libc::{
diff --git a/vendor/rustix/src/backend/libc/event/epoll.rs b/vendor/rustix/src/backend/libc/event/epoll.rs
index b41b05711..ced3be103 100644
--- a/vendor/rustix/src/backend/libc/event/epoll.rs
+++ b/vendor/rustix/src/backend/libc/event/epoll.rs
@@ -278,8 +278,8 @@ pub fn wait(epoll: impl AsFd, event_list: &mut EventVec, timeout: c::c_int) -> i
/// An iterator over the `Event`s in an `EventVec`.
pub struct Iter<'a> {
/// Use `Copied` to copy the struct, since `Event` is `packed` on some
- /// platforms, and it's common for users to directly destructure it,
- /// which would lead to errors about forming references to packed fields.
+ /// platforms, and it's common for users to directly destructure it, which
+ /// would lead to errors about forming references to packed fields.
iter: core::iter::Copied<slice::Iter<'a, Event>>,
}
diff --git a/vendor/rustix/src/backend/libc/event/poll_fd.rs b/vendor/rustix/src/backend/libc/event/poll_fd.rs
index 42f94f3c7..32fd83dd0 100644
--- a/vendor/rustix/src/backend/libc/event/poll_fd.rs
+++ b/vendor/rustix/src/backend/libc/event/poll_fd.rs
@@ -12,7 +12,7 @@ use {
bitflags! {
/// `POLL*` flags for use with [`poll`].
///
- /// [`poll`]: crate::io::poll
+ /// [`poll`]: crate::event::poll
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct PollFlags: c::c_short {
diff --git a/vendor/rustix/src/backend/libc/event/syscalls.rs b/vendor/rustix/src/backend/libc/event/syscalls.rs
index f2dcdf5ad..725ec8250 100644
--- a/vendor/rustix/src/backend/libc/event/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/event/syscalls.rs
@@ -181,3 +181,11 @@ pub(crate) fn port_send(
) -> io::Result<()> {
unsafe { ret(c::port_send(borrowed_fd(port), events, userdata)) }
}
+
+#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
+pub(crate) fn pause() {
+ let r = unsafe { libc::pause() };
+ let errno = libc_errno::errno().0;
+ debug_assert_eq!(r, -1);
+ debug_assert_eq!(errno, libc::EINTR);
+}
diff --git a/vendor/rustix/src/backend/libc/event/types.rs b/vendor/rustix/src/backend/libc/event/types.rs
index ea4776667..a04d7e6cf 100644
--- a/vendor/rustix/src/backend/libc/event/types.rs
+++ b/vendor/rustix/src/backend/libc/event/types.rs
@@ -17,7 +17,7 @@ use bitflags::bitflags;
bitflags! {
/// `EFD_*` flags for use with [`eventfd`].
///
- /// [`eventfd`]: crate::io::eventfd
+ /// [`eventfd`]: crate::event::eventfd
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct EventfdFlags: u32 {
diff --git a/vendor/rustix/src/backend/libc/fs/dir.rs b/vendor/rustix/src/backend/libc/fs/dir.rs
index 0df1ea1b5..82a0a908f 100644
--- a/vendor/rustix/src/backend/libc/fs/dir.rs
+++ b/vendor/rustix/src/backend/libc/fs/dir.rs
@@ -2,7 +2,7 @@
use super::types::FileType;
use crate::backend::c;
use crate::backend::conv::owned_fd;
-use crate::fd::{AsFd, BorrowedFd};
+use crate::fd::{AsFd, BorrowedFd, OwnedFd};
use crate::ffi::{CStr, CString};
use crate::fs::{fcntl_getfl, openat, Mode, OFlags};
#[cfg(not(target_os = "vita"))]
@@ -48,8 +48,34 @@ pub struct Dir {
}
impl Dir {
- /// Construct a `Dir` that reads entries from the given directory
- /// file descriptor.
+ /// Take ownership of `fd` and construct a `Dir` that reads entries from
+ /// the given directory file descriptor.
+ #[inline]
+ pub fn new<Fd: Into<OwnedFd>>(fd: Fd) -> io::Result<Self> {
+ Self::_new(fd.into())
+ }
+
+ #[inline]
+ fn _new(fd: OwnedFd) -> io::Result<Self> {
+ let raw = owned_fd(fd);
+ unsafe {
+ let libc_dir = c::fdopendir(raw);
+
+ if let Some(libc_dir) = NonNull::new(libc_dir) {
+ Ok(Self {
+ libc_dir,
+ any_errors: false,
+ })
+ } else {
+ let err = io::Errno::last_os_error();
+ let _ = c::close(raw);
+ Err(err)
+ }
+ }
+ }
+
+ /// Borrow `fd` and construct a `Dir` that reads entries from the given
+ /// directory file descriptor.
#[inline]
pub fn read_from<Fd: AsFd>(fd: Fd) -> io::Result<Self> {
Self::_read_from(fd.as_fd())
@@ -393,5 +419,5 @@ fn dir_iterator_handles_io_errors() {
}
assert!(matches!(dir.next(), Some(Err(_))));
- assert!(matches!(dir.next(), None));
+ assert!(dir.next().is_none());
}
diff --git a/vendor/rustix/src/backend/libc/fs/syscalls.rs b/vendor/rustix/src/backend/libc/fs/syscalls.rs
index 5e0b62f8e..fcf069a83 100644
--- a/vendor/rustix/src/backend/libc/fs/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/fs/syscalls.rs
@@ -2,8 +2,7 @@
use crate::backend::c;
#[cfg(any(
- apple,
- linux_kernel,
+ not(target_os = "redox"),
feature = "alloc",
all(linux_kernel, feature = "procfs")
))]
@@ -275,10 +274,7 @@ pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
}
}
-#[cfg(all(
- any(feature = "alloc", all(linux_kernel, feature = "procfs")),
- not(target_os = "redox")
-))]
+#[cfg(not(target_os = "redox"))]
#[inline]
pub(crate) fn readlinkat(
dirfd: BorrowedFd<'_>,
@@ -660,7 +656,7 @@ pub(crate) fn lstat(path: &CStr) -> io::Result<Stat> {
}
}
-#[cfg(not(any(target_os = "aix", target_os = "espidf", target_os = "redox")))]
+#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
pub(crate) fn statat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<Stat> {
// See the comments in `fstat` about using `crate::fs::statx` here.
#[cfg(all(
@@ -1703,7 +1699,7 @@ pub(crate) fn ftruncate(fd: BorrowedFd<'_>, length: u64) -> io::Result<()> {
}
#[cfg(any(linux_kernel, target_os = "freebsd"))]
-pub(crate) fn memfd_create(path: &CStr, flags: MemfdFlags) -> io::Result<OwnedFd> {
+pub(crate) fn memfd_create(name: &CStr, flags: MemfdFlags) -> io::Result<OwnedFd> {
#[cfg(target_os = "freebsd")]
weakcall! {
fn memfd_create(
@@ -1720,7 +1716,7 @@ pub(crate) fn memfd_create(path: &CStr, flags: MemfdFlags) -> io::Result<OwnedFd
) via SYS_memfd_create -> c::c_int
}
- unsafe { ret_owned_fd(memfd_create(c_str(path), bitflags_bits!(flags))) }
+ unsafe { ret_owned_fd(memfd_create(c_str(name), bitflags_bits!(flags))) }
}
#[cfg(linux_kernel)]
diff --git a/vendor/rustix/src/backend/libc/mm/types.rs b/vendor/rustix/src/backend/libc/mm/types.rs
index ef335d27a..a4aa3e232 100644
--- a/vendor/rustix/src/backend/libc/mm/types.rs
+++ b/vendor/rustix/src/backend/libc/mm/types.rs
@@ -6,7 +6,7 @@ bitflags! {
///
/// For `PROT_NONE`, use `ProtFlags::empty()`.
///
- /// [`mmap`]: crate::io::mmap
+ /// [`mmap`]: crate::mm::mmap
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct ProtFlags: u32 {
@@ -27,7 +27,7 @@ bitflags! {
///
/// For `PROT_NONE`, use `MprotectFlags::empty()`.
///
- /// [`mprotect`]: crate::io::mprotect
+ /// [`mprotect`]: crate::mm::mprotect
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MprotectFlags: u32 {
@@ -69,8 +69,8 @@ bitflags! {
///
/// For `MAP_ANONYMOUS` (aka `MAP_ANON`), see [`mmap_anonymous`].
///
- /// [`mmap`]: crate::io::mmap
- /// [`mmap_anonymous`]: crates::io::mmap_anonymous
+ /// [`mmap`]: crate::mm::mmap
+ /// [`mmap_anonymous`]: crates::mm::mmap_anonymous
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MapFlags: u32 {
@@ -242,8 +242,8 @@ bitflags! {
///
/// For `MREMAP_FIXED`, see [`mremap_fixed`].
///
- /// [`mremap`]: crate::io::mremap
- /// [`mremap_fixed`]: crate::io::mremap_fixed
+ /// [`mremap`]: crate::mm::mremap
+ /// [`mremap_fixed`]: crate::mm::mremap_fixed
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MremapFlags: u32 {
@@ -258,7 +258,7 @@ bitflags! {
bitflags! {
/// `MS_*` flags for use with [`msync`].
///
- /// [`msync`]: crate::io::msync
+ /// [`msync`]: crate::mm::msync
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MsyncFlags: u32 {
@@ -281,7 +281,7 @@ bitflags! {
bitflags! {
/// `MLOCK_*` flags for use with [`mlock_with`].
///
- /// [`mlock_with`]: crate::io::mlock_with
+ /// [`mlock_with`]: crate::mm::mlock_with
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MlockFlags: u32 {
@@ -383,10 +383,10 @@ pub enum Advice {
/// `MADV_UNMERGEABLE`
#[cfg(linux_kernel)]
LinuxUnmergeable = bitcast!(c::MADV_UNMERGEABLE),
- /// `MADV_HUGEPAGE` (since Linux 2.6.38)
+ /// `MADV_HUGEPAGE`
#[cfg(linux_kernel)]
LinuxHugepage = bitcast!(c::MADV_HUGEPAGE),
- /// `MADV_NOHUGEPAGE` (since Linux 2.6.38)
+ /// `MADV_NOHUGEPAGE`
#[cfg(linux_kernel)]
LinuxNoHugepage = bitcast!(c::MADV_NOHUGEPAGE),
/// `MADV_DONTDUMP` (since Linux 3.4)
@@ -429,7 +429,7 @@ impl Advice {
bitflags! {
/// `O_*` flags for use with [`userfaultfd`].
///
- /// [`userfaultfd`]: crate::io::userfaultfd
+ /// [`userfaultfd`]: crate::mm::userfaultfd
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct UserfaultfdFlags: u32 {
@@ -451,8 +451,17 @@ bitflags! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MlockAllFlags: u32 {
- // libc doesn't define `MCL_ONFAULT` yet.
- // const ONFAULT = libc::MCL_ONFAULT;
+ /// Used together with `MCL_CURRENT`, `MCL_FUTURE`, or both. Mark all
+ /// current (with `MCL_CURRENT`) or future (with `MCL_FUTURE`) mappings
+ /// to lock pages when they are faulted in. When used with
+ /// `MCL_CURRENT`, all present pages are locked, but `mlockall` will
+ /// not fault in non-present pages. When used with `MCL_FUTURE`, all
+ /// future mappings will be marked to lock pages when they are faulted
+ /// in, but they will not be populated by the lock when the mapping is
+ /// created. `MCL_ONFAULT` must be used with either `MCL_CURRENT` or
+ /// `MCL_FUTURE` or both.
+ #[cfg(linux_kernel)]
+ const ONFAULT = bitcast!(libc::MCL_ONFAULT);
/// Lock all pages which will become mapped into the address space of
/// the process in the future. These could be, for instance, new pages
/// required by a growing heap and stack as well as new memory-mapped
diff --git a/vendor/rustix/src/backend/libc/mount/types.rs b/vendor/rustix/src/backend/libc/mount/types.rs
index d4f9c2da7..238f2128e 100644
--- a/vendor/rustix/src/backend/libc/mount/types.rs
+++ b/vendor/rustix/src/backend/libc/mount/types.rs
@@ -299,9 +299,9 @@ bitflags! {
#[cfg(linux_kernel)]
bitflags! {
- /// `MS_*` constants for use with [`change_mount`].
+ /// `MS_*` constants for use with [`mount_change`].
///
- /// [`change_mount`]: crate::mount::change_mount
+ /// [`mount_change`]: crate::mount::mount_change
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MountPropagationFlags: c::c_ulong {
diff --git a/vendor/rustix/src/backend/libc/net/syscalls.rs b/vendor/rustix/src/backend/libc/net/syscalls.rs
index 97b862033..33411c01a 100644
--- a/vendor/rustix/src/backend/libc/net/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/net/syscalls.rs
@@ -100,7 +100,7 @@ pub(crate) fn sendto_v4(
send_recv_len(buf.len()),
bitflags_bits!(flags),
as_ptr(&encode_sockaddr_v4(addr)).cast::<c::sockaddr>(),
- size_of::<SocketAddrV4>() as _,
+ size_of::<c::sockaddr_in>() as c::socklen_t,
))
}
}
@@ -119,7 +119,7 @@ pub(crate) fn sendto_v6(
send_recv_len(buf.len()),
bitflags_bits!(flags),
as_ptr(&encode_sockaddr_v6(addr)).cast::<c::sockaddr>(),
- size_of::<SocketAddrV6>() as _,
+ size_of::<c::sockaddr_in6>() as c::socklen_t,
))
}
}
diff --git a/vendor/rustix/src/backend/libc/pipe/types.rs b/vendor/rustix/src/backend/libc/pipe/types.rs
index 1004e41f7..d5cc73962 100644
--- a/vendor/rustix/src/backend/libc/pipe/types.rs
+++ b/vendor/rustix/src/backend/libc/pipe/types.rs
@@ -7,7 +7,7 @@ use {crate::backend::c, bitflags::bitflags};
bitflags! {
/// `O_*` constants for use with [`pipe_with`].
///
- /// [`pipe_with`]: crate::io::pipe_with
+ /// [`pipe_with`]: crate::pipe::pipe_with
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct PipeFlags: u32 {
@@ -34,8 +34,8 @@ bitflags! {
#[cfg(linux_kernel)]
bitflags! {
- /// `SPLICE_F_*` constants for use with [`splice`], [`vmsplice`],
- /// and [`tee`].
+ /// `SPLICE_F_*` constants for use with [`splice`], [`vmsplice`], and
+ /// [`tee`].
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct SpliceFlags: c::c_uint {
diff --git a/vendor/rustix/src/backend/libc/process/mod.rs b/vendor/rustix/src/backend/libc/process/mod.rs
index b89096199..39803b521 100644
--- a/vendor/rustix/src/backend/libc/process/mod.rs
+++ b/vendor/rustix/src/backend/libc/process/mod.rs
@@ -1,4 +1,4 @@
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
pub(crate) mod cpu_set;
#[cfg(not(windows))]
pub(crate) mod syscalls;
diff --git a/vendor/rustix/src/backend/libc/process/syscalls.rs b/vendor/rustix/src/backend/libc/process/syscalls.rs
index ec31e0ea7..46fd18211 100644
--- a/vendor/rustix/src/backend/libc/process/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/process/syscalls.rs
@@ -1,6 +1,6 @@
//! libc syscalls supporting `rustix::process`.
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
use super::types::RawCpuSet;
use crate::backend::c;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
@@ -72,6 +72,14 @@ use {
super::super::conv::ret_owned_fd, crate::process::PidfdFlags, crate::process::PidfdGetfdFlags,
};
+#[cfg(any(linux_kernel, target_os = "dragonfly"))]
+#[inline]
+pub(crate) fn sched_getcpu() -> usize {
+ let r = unsafe { libc::sched_getcpu() };
+ debug_assert!(r >= 0);
+ r as usize
+}
+
#[cfg(feature = "fs")]
#[cfg(not(target_os = "wasi"))]
pub(crate) fn chdir(path: &CStr) -> io::Result<()> {
@@ -181,7 +189,7 @@ pub(crate) fn getpgrp() -> Pid {
}
}
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
#[inline]
pub(crate) fn sched_getaffinity(pid: Option<Pid>, cpuset: &mut RawCpuSet) -> io::Result<()> {
unsafe {
@@ -193,7 +201,7 @@ pub(crate) fn sched_getaffinity(pid: Option<Pid>, cpuset: &mut RawCpuSet) -> io:
}
}
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
#[inline]
pub(crate) fn sched_setaffinity(pid: Option<Pid>, cpuset: &RawCpuSet) -> io::Result<()> {
unsafe {
diff --git a/vendor/rustix/src/backend/libc/process/types.rs b/vendor/rustix/src/backend/libc/process/types.rs
index 8689c414a..f914128df 100644
--- a/vendor/rustix/src/backend/libc/process/types.rs
+++ b/vendor/rustix/src/backend/libc/process/types.rs
@@ -155,10 +155,12 @@ pub type RawCpuid = u32;
#[cfg(freebsdlike)]
pub type RawId = c::id_t;
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(linux_kernel, target_os = "fuchsia"))]
pub(crate) type RawCpuSet = c::cpu_set_t;
+#[cfg(freebsdlike)]
+pub(crate) type RawCpuSet = c::cpuset_t;
-#[cfg(any(linux_kernel, target_os = "dragonfly", target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
#[inline]
pub(crate) fn raw_cpu_set_new() -> RawCpuSet {
let mut set = unsafe { core::mem::zeroed() };
@@ -166,7 +168,5 @@ pub(crate) fn raw_cpu_set_new() -> RawCpuSet {
set
}
-#[cfg(any(linux_kernel, target_os = "fuchsia"))]
+#[cfg(any(freebsdlike, linux_kernel, target_os = "fuchsia"))]
pub(crate) const CPU_SETSIZE: usize = c::CPU_SETSIZE as usize;
-#[cfg(target_os = "dragonfly")]
-pub(crate) const CPU_SETSIZE: usize = 256;
diff --git a/vendor/rustix/src/backend/libc/termios/syscalls.rs b/vendor/rustix/src/backend/libc/termios/syscalls.rs
index 35d4e2349..a833aea8d 100644
--- a/vendor/rustix/src/backend/libc/termios/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/termios/syscalls.rs
@@ -115,6 +115,15 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
pub(crate) fn tcgetpgrp(fd: BorrowedFd<'_>) -> io::Result<Pid> {
unsafe {
let pid = ret_pid_t(c::tcgetpgrp(borrowed_fd(fd)))?;
+
+ // This doesn't appear to be documented, but on Linux, it appears
+ // `tcsetpgrp` can succceed and set the pid to 0 if we pass it a
+ // pseudo-terminal device fd. For now, translate it into `OPNOTSUPP`.
+ #[cfg(linux_kernel)]
+ if pid == 0 {
+ return Err(io::Errno::OPNOTSUPP);
+ }
+
Ok(Pid::from_raw_unchecked(pid))
}
}
diff --git a/vendor/rustix/src/backend/libc/time/types.rs b/vendor/rustix/src/backend/libc/time/types.rs
index 1514b02d0..5254c6bc7 100644
--- a/vendor/rustix/src/backend/libc/time/types.rs
+++ b/vendor/rustix/src/backend/libc/time/types.rs
@@ -83,9 +83,11 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct TimerfdFlags: u32 {
/// `TFD_NONBLOCK`
+ #[doc(alias = "TFD_NONBLOCK")]
const NONBLOCK = bitcast!(c::TFD_NONBLOCK);
/// `TFD_CLOEXEC`
+ #[doc(alias = "TFD_CLOEXEC")]
const CLOEXEC = bitcast!(c::TFD_CLOEXEC);
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
@@ -102,10 +104,12 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct TimerfdTimerFlags: u32 {
/// `TFD_TIMER_ABSTIME`
+ #[doc(alias = "TFD_TIMER_ABSTIME")]
const ABSTIME = bitcast!(c::TFD_TIMER_ABSTIME);
/// `TFD_TIMER_CANCEL_ON_SET`
#[cfg(linux_kernel)]
+ #[doc(alias = "TFD_TIMER_CANCEL_ON_SET")]
const CANCEL_ON_SET = bitcast!(c::TFD_TIMER_CANCEL_ON_SET);
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
@@ -127,6 +131,7 @@ pub enum TimerfdClockId {
/// epoch, 1970-01-01T00:00:00Z. The clock is externally settable, so it is
/// not monotonic. Successive reads may see decreasing times, so it isn't
/// reliable for measuring durations.
+ #[doc(alias = "CLOCK_REALTIME")]
Realtime = bitcast!(c::CLOCK_REALTIME),
/// `CLOCK_MONOTONIC`—A clock that tells an abstract time.
@@ -137,12 +142,14 @@ pub enum TimerfdClockId {
///
/// This clock does not advance while the system is suspended; see
/// `Boottime` for a clock that does.
+ #[doc(alias = "CLOCK_MONOTONIC")]
Monotonic = bitcast!(c::CLOCK_MONOTONIC),
/// `CLOCK_BOOTTIME`—Like `Monotonic`, but advances while suspended.
///
/// This clock is similar to `Monotonic`, but does advance while the system
/// is suspended.
+ #[doc(alias = "CLOCK_BOOTTIME")]
Boottime = bitcast!(c::CLOCK_BOOTTIME),
/// `CLOCK_REALTIME_ALARM`—Like `Realtime`, but wakes a suspended system.
@@ -150,6 +157,7 @@ pub enum TimerfdClockId {
/// This clock is like `Realtime`, but can wake up a suspended system.
///
/// Use of this clock requires the `CAP_WAKE_ALARM` Linux capability.
+ #[doc(alias = "CLOCK_REALTIME_ALARM")]
RealtimeAlarm = bitcast!(c::CLOCK_REALTIME_ALARM),
/// `CLOCK_BOOTTIME_ALARM`—Like `Boottime`, but wakes a suspended system.
@@ -157,6 +165,7 @@ pub enum TimerfdClockId {
/// This clock is like `Boottime`, but can wake up a suspended system.
///
/// Use of this clock requires the `CAP_WAKE_ALARM` Linux capability.
+ #[doc(alias = "CLOCK_BOOTTIME_ALARM")]
BoottimeAlarm = bitcast!(c::CLOCK_BOOTTIME_ALARM),
}