diff --git a/Cargo.toml b/Cargo.toml index b3d0b2c20..4b29c9b0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,6 @@ fuchsia = [ generic = [ "arch", "hostname", - "more", "nproc", "sync", "tail", @@ -108,6 +107,7 @@ redox_generic = [ "ls", "mkdir", "mktemp", + "more", "mv", "nl", "od", diff --git a/src/more/Cargo.toml b/src/more/Cargo.toml index 85d5e7943..ab1aab184 100644 --- a/src/more/Cargo.toml +++ b/src/more/Cargo.toml @@ -12,6 +12,10 @@ path = "more.rs" getopts = "0.2.14" uucore = { path="../uucore" } +[target.'cfg(target_os = "redox")'.dependencies] +redox_termios = "0.1" +redox_syscall = "0.1" + [target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] nix = "0.8.1" diff --git a/src/more/more.rs b/src/more/more.rs index 587237200..07833928c 100644 --- a/src/more/more.rs +++ b/src/more/more.rs @@ -23,6 +23,11 @@ extern crate nix; #[cfg(all(unix, not(target_os = "fuchsia")))] use nix::sys::termios; +#[cfg(target_os = "redox")] +extern crate redox_termios; +#[cfg(target_os = "redox")] +extern crate syscall; + #[derive(Clone, Eq, PartialEq)] pub enum Mode { More, @@ -96,6 +101,18 @@ fn setup_term() -> usize { 0 } +#[cfg(target_os = "redox")] +fn setup_term() -> redox_termios::Termios { + let mut term = redox_termios::Termios::default(); + let fd = syscall::dup(0, b"termios").unwrap(); + syscall::read(fd, &mut term).unwrap(); + term.c_lflag &= !redox_termios::ICANON; + term.c_lflag &= !redox_termios::ECHO; + syscall::write(fd, &term).unwrap(); + let _ = syscall::close(fd); + term +} + #[cfg(all(unix, not(target_os = "fuchsia")))] fn reset_term(term: &mut termios::Termios) { term.c_lflag.insert(termios::ICANON); @@ -107,6 +124,16 @@ fn reset_term(term: &mut termios::Termios) { #[inline(always)] fn reset_term(_: &mut usize) {} +#[cfg(any(target_os = "redox"))] +fn reset_term(term: &mut redox_termios::Termios) { + let fd = syscall::dup(0, b"termios").unwrap(); + syscall::read(fd, term).unwrap(); + term.c_lflag |= redox_termios::ICANON; + term.c_lflag |= redox_termios::ECHO; + syscall::write(fd, &term).unwrap(); + let _ = syscall::close(fd); +} + fn more(matches: getopts::Matches) { let files = matches.free; let mut f = File::open(files.first().unwrap()).unwrap();