Skip to content

Commit

Permalink
Fix compilation issue on redox
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Varlakov committed Jan 4, 2024
1 parent 243c6f9 commit df913e8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/sys/redox/attr.rs
Original file line number Diff line number Diff line change
@@ -1,3 1,4 @@
use std::convert::TryInto;
use std::io;
use std::os::fd::{AsRawFd, BorrowedFd};

Expand All @@ -6,7 7,11 @@ use super::{cvt, Termios};
pub fn get_terminal_attr(fd: BorrowedFd) -> io::Result<Termios> {
let mut termios = Termios::default();

let fd = cvt(libredox::call::dup(fd.as_raw_fd(), b"termios"))?;
let fd: usize = fd
.as_raw_fd()
.try_into()
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
let fd = cvt(libredox::call::dup(fd, b"termios"))?;
let res = cvt(libredox::call::read(fd, &mut termios));
let _ = libredox::call::close(fd);

Expand All @@ -21,7 26,11 @@ pub fn get_terminal_attr(fd: BorrowedFd) -> io::Result<Termios> {
}

pub fn set_terminal_attr(fd: BorrowedFd, termios: &Termios) -> io::Result<()> {
let fd = cvt(libredox::call::dup(fd.as_raw_fd(), b"termios"))?;
let fd: usize = fd
.as_raw_fd()
.try_into()
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
let fd = cvt(libredox::call::dup(fd, b"termios"))?;
let res = cvt(libredox::call::write(fd, termios));
let _ = libredox::call::close(fd);

Expand Down

0 comments on commit df913e8

Please sign in to comment.