diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/rustix/src/process/ioctl.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/rustix/src/process/ioctl.rs')
-rw-r--r-- | vendor/rustix/src/process/ioctl.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/rustix/src/process/ioctl.rs b/vendor/rustix/src/process/ioctl.rs new file mode 100644 index 0000000..5afc766 --- /dev/null +++ b/vendor/rustix/src/process/ioctl.rs @@ -0,0 +1,52 @@ +//! Process-oriented `ioctl`s. +//! +//! # Safety +//! +//! This module invokes `ioctl`s. + +#![allow(unsafe_code)] + +use crate::{backend, io, ioctl}; +use backend::c; +use backend::fd::AsFd; + +/// `ioctl(fd, TIOCSCTTY, 0)`—Sets the controlling terminal for the process. +/// +/// # References +/// - [Linux] +/// - [FreeBSD] +/// - [NetBSD] +/// - [OpenBSD] +/// +/// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 +/// [NetBSD]: https://man.netbsd.org/tty.4 +/// [OpenBSD]: https://man.openbsd.org/tty.4 +#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] +#[inline] +#[doc(alias = "TIOCSCTTY")] +pub fn ioctl_tiocsctty<Fd: AsFd>(fd: Fd) -> io::Result<()> { + unsafe { ioctl::ioctl(fd, Tiocsctty) } +} + +#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] +struct Tiocsctty; + +#[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] +unsafe impl ioctl::Ioctl for Tiocsctty { + type Output = (); + + const IS_MUTATING: bool = false; + const OPCODE: ioctl::Opcode = ioctl::Opcode::old(c::TIOCSCTTY as ioctl::RawOpcode); + + fn as_ptr(&mut self) -> *mut c::c_void { + (&0u32) as *const u32 as *mut c::c_void + } + + unsafe fn output_from_ptr( + _: ioctl::IoctlOutput, + _: *mut c::c_void, + ) -> io::Result<Self::Output> { + Ok(()) + } +} |