Update redox_syscall and redox_termios

This commit is contained in:
Jeremy Soller
2021-01-19 11:34:05 -07:00
parent ccd65a0c88
commit 18c14b1d8f
10 changed files with 48 additions and 37 deletions
Generated
+16 -7
View File
@@ -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"
+2 -2
View File
@@ -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"
+5 -4
View File
@@ -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");
}
+4 -4
View File
@@ -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<usize> {
fn fevent(&mut self) -> Result<EventFlags> {
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() {
+4 -4
View File
@@ -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<usize> {
fn fevent(&mut self) -> Result<EventFlags> {
Err(Error::new(EBADF))
}
fn events(&mut self) -> usize {
0
fn events(&mut self) -> EventFlags {
EventFlags::empty()
}
}
+3 -2
View File
@@ -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<Option<usize>>;
fn sync(&self) -> Result<usize>;
fn fcntl(&mut self, cmd: usize, arg: usize) -> Result<usize>;
fn fevent(&mut self) -> Result<usize>;
fn events(&mut self) -> usize;
fn fevent(&mut self) -> Result<EventFlags>;
fn events(&mut self) -> EventFlags;
fn timeout(&self, _count: u64) {
// Handled only by PTY master
}
+2 -2
View File
@@ -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<Option<usize>> {
fn fevent(&mut self, id: usize, _flags: EventFlags) -> Result<Option<EventFlags>> {
let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?;
handle.fevent().map(Some)
}
+4 -4
View File
@@ -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<usize> {
fn fevent(&mut self) -> Result<EventFlags> {
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();
+4 -4
View File
@@ -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<usize> {
fn fevent(&mut self) -> Result<EventFlags> {
Err(Error::new(EBADF))
}
fn events(&mut self) -> usize {
0
fn events(&mut self) -> EventFlags {
EventFlags::empty()
}
}
+4 -4
View File
@@ -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<usize> {
fn fevent(&mut self) -> Result<EventFlags> {
Err(Error::new(EBADF))
}
fn events(&mut self) -> usize {
0
fn events(&mut self) -> EventFlags {
EventFlags::empty()
}
}