(fd: BorrowedFd<'_>)
| 32 | |
| 33 | #[inline] |
| 34 | pub(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")))] |
nothing calls this directly
no test coverage detected