diff --git a/Cargo.lock b/Cargo.lock index 6b9e91ac94..e5b1d35b0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,26 +1,35 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ptyd" version = "0.1.0" dependencies = [ - "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "redox_termios" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +"checksum redox_termios 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" diff --git a/Cargo.toml b/Cargo.toml index 1e9a58f6ce..753ed1bbb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,5 @@ name = "ptyd" version = "0.1.0" [dependencies] -redox_syscall = "0.1.40" -redox_termios = "0.1" +redox_syscall = "0.2.4" +redox_termios = "0.1.2" diff --git a/src/main.rs b/src/main.rs index 2fbdf74038..d49976c680 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ use std::os::unix::fs::OpenOptionsExt; use std::os::unix::io::AsRawFd; use syscall::data::{Event, Packet, TimeSpec}; +use syscall::flag::{CloneFlags, EventFlags}; use syscall::scheme::SchemeBlockMut; mod master; @@ -22,7 +23,7 @@ use scheme::PtyScheme; fn main(){ // Daemonize - if unsafe { syscall::clone(0).unwrap() } == 0 { + if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 { let mut event_file = OpenOptions::new() .read(true) .write(true) @@ -109,7 +110,7 @@ fn main(){ for (id, handle) in scheme.handles.iter_mut() { let events = handle.events(); - if events > 0 { + if events != EventFlags::empty() { post_fevent(&mut socket, *id, events, 1); } } @@ -130,7 +131,7 @@ fn timeout(time_file: &mut File) -> io::Result<()> { time_file.write_all(&time) } -fn post_fevent(socket: &mut File, id: usize, flags: usize, count: usize) { +fn post_fevent(socket: &mut File, id: usize, flags: EventFlags, count: usize) { socket.write(&Packet { id: 0, pid: 0, @@ -138,7 +139,7 @@ fn post_fevent(socket: &mut File, id: usize, flags: usize, count: usize) { gid: 0, a: syscall::number::SYS_FEVENT, b: id, - c: flags, + c: flags.bits(), d: count }).expect("pty: failed to write event"); } diff --git a/src/master.rs b/src/master.rs index f465ecffe6..7ceee9addf 100644 --- a/src/master.rs +++ b/src/master.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use std::rc::{Rc, Weak}; use syscall::error::{Error, Result, EINVAL, EAGAIN}; -use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; +use syscall::flag::{EventFlags, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use pty::Pty; use resource::Resource; @@ -98,14 +98,14 @@ impl Resource for PtyMaster { } } - fn fevent(&mut self) -> Result { + fn fevent(&mut self) -> Result { self.notified_read = false; // resend self.notified_write = false; Ok(self.events()) } - fn events(&mut self) -> usize { - let mut events = 0; + fn events(&mut self) -> EventFlags { + let mut events = EventFlags::empty(); let pty = self.pty.borrow(); if pty.miso.front().is_some() { diff --git a/src/pgrp.rs b/src/pgrp.rs index f79c256cf5..336f94c9da 100644 --- a/src/pgrp.rs +++ b/src/pgrp.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use std::rc::Weak; use syscall::error::{Error, Result, EBADF, EINVAL, EPIPE}; -use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE}; +use syscall::flag::{EventFlags, F_GETFL, F_SETFL, O_ACCMODE}; use pty::Pty; use resource::Resource; @@ -102,11 +102,11 @@ impl Resource for PtyPgrp { } } - fn fevent(&mut self) -> Result { + fn fevent(&mut self) -> Result { Err(Error::new(EBADF)) } - fn events(&mut self) -> usize { - 0 + fn events(&mut self) -> EventFlags { + EventFlags::empty() } } diff --git a/src/resource.rs b/src/resource.rs index 9abac98f77..82c037251b 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -2,6 +2,7 @@ use std::cell::RefCell; use std::rc::Weak; use syscall::error::Result; +use syscall::flag::EventFlags; use pty::Pty; @@ -15,8 +16,8 @@ pub trait Resource { fn write(&self, buf: &[u8]) -> Result>; fn sync(&self) -> Result; fn fcntl(&mut self, cmd: usize, arg: usize) -> Result; - fn fevent(&mut self) -> Result; - fn events(&mut self) -> usize; + fn fevent(&mut self) -> Result; + fn events(&mut self) -> EventFlags; fn timeout(&self, _count: u64) { // Handled only by PTY master } diff --git a/src/scheme.rs b/src/scheme.rs index 3e5c929f41..582cd3e081 100644 --- a/src/scheme.rs +++ b/src/scheme.rs @@ -5,7 +5,7 @@ use std::str; use syscall::data::Stat; use syscall::error::{Error, Result, EBADF, EINVAL, ENOENT}; -use syscall::flag::MODE_CHR; +use syscall::flag::{EventFlags, MODE_CHR}; use syscall::scheme::SchemeBlockMut; use master::PtyMaster; @@ -97,7 +97,7 @@ impl SchemeBlockMut for PtyScheme { handle.fcntl(cmd, arg).map(Some) } - fn fevent(&mut self, id: usize, _flags: usize) -> Result> { + fn fevent(&mut self, id: usize, _flags: EventFlags) -> Result> { let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?; handle.fevent().map(Some) } diff --git a/src/slave.rs b/src/slave.rs index 6b55db3054..3698e74462 100644 --- a/src/slave.rs +++ b/src/slave.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use std::rc::Weak; use syscall::error::{Error, Result, EINVAL, EPIPE, EAGAIN}; -use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; +use syscall::flag::{EventFlags, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use pty::Pty; use resource::Resource; @@ -116,14 +116,14 @@ impl Resource for PtySlave { } } - fn fevent(&mut self) -> Result { + fn fevent(&mut self) -> Result { self.notified_read = false; // resend self.notified_write = false; Ok(self.events()) } - fn events(&mut self) -> usize { - let mut events = 0; + fn events(&mut self) -> EventFlags { + let mut events = EventFlags::empty(); if let Some(pty_lock) = self.pty.upgrade() { let pty = pty_lock.borrow(); diff --git a/src/termios.rs b/src/termios.rs index c6ea14b4a9..0672e9b007 100644 --- a/src/termios.rs +++ b/src/termios.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use std::rc::Weak; use syscall::error::{Error, Result, EBADF, EINVAL, EPIPE}; -use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE}; +use syscall::flag::{EventFlags, F_GETFL, F_SETFL, O_ACCMODE}; use pty::Pty; use resource::Resource; @@ -92,11 +92,11 @@ impl Resource for PtyTermios { } } - fn fevent(&mut self) -> Result { + fn fevent(&mut self) -> Result { Err(Error::new(EBADF)) } - fn events(&mut self) -> usize { - 0 + fn events(&mut self) -> EventFlags { + EventFlags::empty() } } diff --git a/src/winsize.rs b/src/winsize.rs index c0480a57f6..9c255d8eff 100644 --- a/src/winsize.rs +++ b/src/winsize.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use std::rc::Weak; use syscall::error::{Error, Result, EBADF, EINVAL, EPIPE}; -use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE}; +use syscall::flag::{EventFlags, F_GETFL, F_SETFL, O_ACCMODE}; use pty::Pty; use resource::Resource; @@ -92,11 +92,11 @@ impl Resource for PtyWinsize { } } - fn fevent(&mut self) -> Result { + fn fevent(&mut self) -> Result { Err(Error::new(EBADF)) } - fn events(&mut self) -> usize { - 0 + fn events(&mut self) -> EventFlags { + EventFlags::empty() } }