diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-02 18:36:06 -0600 |
| commit | 8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch) | |
| tree | 22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/rustix/src/termios/ioctl.rs | |
| parent | 4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff) | |
chore: add vendor directory
Diffstat (limited to 'vendor/rustix/src/termios/ioctl.rs')
| -rw-r--r-- | vendor/rustix/src/termios/ioctl.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/rustix/src/termios/ioctl.rs b/vendor/rustix/src/termios/ioctl.rs new file mode 100644 index 00000000..22945566 --- /dev/null +++ b/vendor/rustix/src/termios/ioctl.rs @@ -0,0 +1,66 @@ +//! Terminal-related `ioctl` functions. + +#![allow(unsafe_code)] + +use crate::fd::AsFd; +use crate::{backend, io, ioctl}; +use backend::c; + +/// `ioctl(fd, TIOCEXCL)`—Enables exclusive mode on a terminal. +/// +/// In exclusive mode, subsequent unprivileged `open` calls on the terminal +/// device fail with [`io::Errno::BUSY`]. +/// +/// # 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 = "horizon", + target_os = "redox", + target_os = "wasi" +)))] +#[inline] +#[doc(alias = "TIOCEXCL")] +pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { + // SAFETY: `TIOCEXCL` is a no-argument setter opcode. + unsafe { + let ctl = ioctl::NoArg::<{ c::TIOCEXCL as _ }>::new(); + ioctl::ioctl(fd, ctl) + } +} + +/// `ioctl(fd, TIOCNXCL)`—Disables exclusive mode on a terminal. +/// +/// # 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 = "horizon", + target_os = "redox", + target_os = "wasi" +)))] +#[inline] +#[doc(alias = "TIOCNXCL")] +pub fn ioctl_tiocnxcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { + // SAFETY: `TIOCNXCL` is a no-argument setter opcode. + unsafe { + let ctl = ioctl::NoArg::<{ c::TIOCNXCL as _ }>::new(); + ioctl::ioctl(fd, ctl) + } +} |
