MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / tcgetattr

Function tcgetattr

src/backend/linux_raw/termios/syscalls.rs:34–52  ·  view source on GitHub ↗
(fd: BorrowedFd<'_>)

Source from the content-addressed store, hash-verified

32
33#[inline]
34pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
35 let mut result = MaybeUninit::<Termios>::uninit();
36
37 // SAFETY: This invokes the `TCGETS2` ioctl, which initializes the full
38 // `Termios` structure.
39 unsafe {
40 match ret(syscall!(__NR_ioctl, fd, c_uint(c::TCGETS2), &mut result)) {
41 Ok(()) => Ok(result.assume_init()),
42
43 // A `NOTTY` or `ACCESS` might mean the OS doesn't support
44 // `TCGETS2`, for example a seccomp environment or WSL that only
45 // knows about `TCGETS`. Fall back to the old `TCGETS`.
46 #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
47 Err(io::Errno::NOTTY) | Err(io::Errno::ACCESS) => tcgetattr_fallback(fd),
48
49 Err(err) => Err(err),
50 }
51 }
52}
53
54/// Implement `tcgetattr` using the old `TCGETS` ioctl.
55#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]

Callers

nothing calls this directly

Calls 3

assume_initMethod · 0.80
tcgetattr_fallbackFunction · 0.70
retFunction · 0.50

Tested by

no test coverage detected