Commit 400a5066 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'update_dependencies' into 'master'

Update dependencies.

See merge request !36
parents 47f62378 8f7d7595
This diff is collapsed.
......@@ -17,7 +17,7 @@ path = "src/lib/lib.rs"
[dependencies]
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
byteorder = { version = "1.0", default-features = false }
dns-parser = "0.7.1"
......@@ -42,4 +42,4 @@ lto = true
[patch.crates-io]
mio = { git = "https://gitlab.redox-os.org/redox-os/mio.git", branch = "redox-unix" }
net2 = { git = "https://gitlab.redox-os.org/redox-os/net2-rs.git", branch = "redox-unix" }
net2 = { git = "https://gitlab.redox-os.org/redox-os/net2-rs.git", branch = "master" }
......@@ -17,6 +17,8 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::process;
use std::rc::Rc;
use syscall::{CloneFlags, EventFlags};
mod scheme;
fn run() -> Result<()> {
......@@ -73,14 +75,14 @@ fn run() -> Result<()> {
event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
flags: EventFlags::empty(),
})?;
event_queue.run()
}
fn main() {
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
logger::init_logger();
if let Err(err) = run() {
error!("dnsd: {}", err);
......
......@@ -13,7 +13,7 @@ use std::str::FromStr;
use std::rc::Rc;
use std::net::Ipv4Addr;
use syscall::data::TimeSpec;
use syscall::{Error as SyscallError, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
use syscall::{Error as SyscallError, EventFlags as SyscallEventFlags, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
use syscall;
use dns_parser::{Builder, Packet as DNSPacket, RRData, ResponseCode};
......@@ -417,10 +417,8 @@ impl Dnsd {
}
impl SchemeMut for Dnsd {
fn open(&mut self, url: &[u8], _flags: usize, _uid: u32, _gid: u32) -> SyscallResult<usize> {
let domain = str::from_utf8(url)
.or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?
.to_lowercase();
fn open(&mut self, url: &str, _flags: usize, _uid: u32, _gid: u32) -> SyscallResult<usize> {
let domain = url.to_lowercase();
if domain.is_empty() || !Dnsd::validate_domain(&domain) {
return Err(SyscallError::new(syscall::EINVAL));
}
......@@ -484,8 +482,8 @@ impl SchemeMut for Dnsd {
}
}
fn fevent(&mut self, _fd: usize, _events: usize) -> SyscallResult<usize> {
Ok(0)
fn fevent(&mut self, _fd: usize, _events: SyscallEventFlags) -> SyscallResult<SyscallEventFlags> {
Ok(SyscallEventFlags::empty())
}
fn fsync(&mut self, _fd: usize) -> SyscallResult<usize> {
......
......@@ -15,6 +15,8 @@ use std::os::unix::io::{FromRawFd, RawFd};
use std::process;
use std::rc::Rc;
use syscall::flag::{CloneFlags, EventFlags};
use redox_netstack::error::{Error, Result};
use redox_netstack::logger;
use event::EventQueue;
......@@ -141,14 +143,14 @@ fn run() -> Result<()> {
event_queue.trigger_all(event::Event {
fd: 0,
flags: 0
flags: EventFlags::empty()
})?;
event_queue.run()
}
fn main() {
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
logger::init_logger();
if let Err(err) = run() {
......
......@@ -13,7 +13,7 @@ use std::str::FromStr;
use std::str;
use syscall::data::Stat;
use syscall::flag::{MODE_DIR, MODE_FILE};
use syscall::{Error as SyscallError, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
use syscall::{Error as SyscallError, EventFlags as SyscallEventFlags, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
use syscall;
use self::nodes::*;
......@@ -384,14 +384,13 @@ impl NetCfgScheme {
fn notify_scheduled_fds(&mut self) {
let fds_to_notify = self.notifier.borrow_mut().get_notified_fds();
for fd in fds_to_notify {
let _ = post_fevent(&mut self.scheme_file, fd, syscall::EVENT_READ, 1);
let _ = post_fevent(&mut self.scheme_file, fd, syscall::EVENT_READ.bits(), 1);
}
}
}
impl SchemeMut for NetCfgScheme {
fn open(&mut self, url: &[u8], _flags: usize, uid: u32, _gid: u32) -> SyscallResult<usize> {
let path = str::from_utf8(url).or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?;
fn open(&mut self, path: &str, _flags: usize, uid: u32, _gid: u32) -> SyscallResult<usize> {
let mut current_node = Rc::clone(&self.root_node);
for part in path.split('/') {
if part.is_empty() {
......@@ -505,16 +504,16 @@ impl SchemeMut for NetCfgScheme {
Ok(0)
}
fn fevent(&mut self, fd: usize, events: usize) -> SyscallResult<usize> {
fn fevent(&mut self, fd: usize, events: SyscallEventFlags) -> SyscallResult<SyscallEventFlags> {
let file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
if events & syscall::EVENT_READ == syscall::EVENT_READ {
if events.contains(syscall::EVENT_READ) {
self.notifier.borrow_mut().subscribe(&file.path, fd);
} else {
self.notifier.borrow_mut().unsubscribe(&file.path, fd);
}
Ok(0)
Ok(SyscallEventFlags::empty())
}
fn fsync(&mut self, fd: usize) -> SyscallResult<usize> {
......
use smoltcp::socket::{AnySocket, SocketHandle};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fs::File;
......@@ -9,12 +8,15 @@ use std::ops::Deref;
use std::ops::DerefMut;
use std::rc::Rc;
use std::str;
use syscall;
use syscall::{Error as SyscallError, Packet as SyscallPacket, Result as SyscallResult, SchemeBlockMut};
use syscall::{Error as SyscallError, EventFlags as SyscallEventFlags, Packet as SyscallPacket, Result as SyscallResult, SchemeBlockMut};
use syscall::data::TimeSpec;
use syscall::flag::{EVENT_READ, EVENT_WRITE};
use redox_netstack::error::{Error, Result};
use smoltcp::socket::{AnySocket, SocketHandle};
use super::{post_fevent, SocketSet};
pub struct NullFile {
......@@ -108,19 +110,19 @@ where
{
let socket = socket_set.get::<SocketT>(socket_handle);
if events & syscall::EVENT_READ == syscall::EVENT_READ && (socket.can_recv() || !socket.may_recv()) {
if events & syscall::EVENT_READ.bits() == syscall::EVENT_READ.bits() && (socket.can_recv() || !socket.may_recv()) {
if !*read_notified {
*read_notified = true;
revents |= EVENT_READ;
revents |= EVENT_READ.bits();
}
} else {
*read_notified = false;
}
if events & syscall::EVENT_WRITE == syscall::EVENT_WRITE && socket.can_send() {
if events & syscall::EVENT_WRITE.bits() == syscall::EVENT_WRITE.bits() && socket.can_send() {
if !*write_notified {
*write_notified = true;
revents |= EVENT_WRITE;
revents |= EVENT_WRITE.bits();
}
} else {
*write_notified = false;
......@@ -437,9 +439,7 @@ impl<SocketT> syscall::SchemeBlockMut for SocketScheme<SocketT>
where
SocketT: SchemeSocket + AnySocket<'static, 'static>,
{
fn open(&mut self, url: &[u8], flags: usize, uid: u32, _gid: u32) -> SyscallResult<Option<usize>> {
let path = str::from_utf8(url).or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?;
fn open(&mut self, path: &str, flags: usize, uid: u32, _gid: u32) -> SyscallResult<Option<usize>> {
if path.is_empty() {
let null = NullFile {
flags: flags,
......@@ -552,15 +552,15 @@ where
}
fn dup(&mut self, fd: usize, buf: &[u8]) -> SyscallResult<Option<usize>> {
let path = str::from_utf8(buf).or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?;
if let Some((flags, uid, gid)) = self.nulls
.get(&fd)
.map(|null| (null.flags, null.uid, null.gid))
{
return self.open(buf, flags, uid, gid);
return self.open(path, flags, uid, gid);
}
let path = str::from_utf8(buf).or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?;
let new_file = {
let file = self.files
.get_mut(&fd)
......@@ -624,20 +624,20 @@ where
Ok(Some(id))
}
fn fevent(&mut self, fd: usize, events: usize) -> SyscallResult<Option<usize>> {
fn fevent(&mut self, fd: usize, events: SyscallEventFlags) -> SyscallResult<Option<SyscallEventFlags>> {
let file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
match *file {
SchemeFile::Setting(_) => return Err(SyscallError::new(syscall::EBADF)),
SchemeFile::Socket(ref mut file) => {
file.events = events;
file.events = events.bits();
file.read_notified = false; // resend missed events
file.write_notified = false;
}
}
let mut socket_set = self.socket_set.borrow_mut();
let revents = file.events(&mut socket_set);
let revents = SyscallEventFlags::from_bits_truncate(file.events(&mut socket_set));
Ok(Some(revents))
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment