From 04ae0158c9b008f3e32b88aaf8ab0f80a0d7904d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:50:45 +0100 Subject: [PATCH] Update most crates to redox-scheme 0.6 A couple of crates need to stay on redox-scheme 0.4 as they need cancellation for async schemes. --- Cargo.lock | 24 +++++++--------------- acpid/Cargo.toml | 2 +- acpid/src/main.rs | 2 +- acpid/src/scheme.rs | 29 ++++++++++++++++++++------- graphics/bgad/Cargo.toml | 2 +- graphics/bgad/src/main.rs | 4 ++-- graphics/bgad/src/scheme.rs | 33 +++++++++++++++++++++---------- graphics/fbbootlogd/Cargo.toml | 2 +- graphics/fbbootlogd/src/main.rs | 4 ++-- graphics/fbbootlogd/src/scheme.rs | 29 +++++++++++++++++++-------- inputd/Cargo.toml | 2 +- inputd/src/main.rs | 30 ++++++++++++++++++++-------- pcid/Cargo.toml | 2 +- pcid/src/main.rs | 4 ++-- pcid/src/scheme.rs | 21 ++++++++++++++------ storage/driver-block/Cargo.toml | 2 +- xhcid/Cargo.toml | 2 +- xhcid/src/main.rs | 2 +- xhcid/src/xhci/scheme.rs | 31 +++++++++++++++++++++-------- 19 files changed, 148 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce7c05e14d..0d927e43bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ dependencies = [ "parking_lot 0.12.3", "plain", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_event", "redox_syscall", "ron", @@ -187,7 +187,7 @@ dependencies = [ "orbclient", "pcid", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_syscall", ] @@ -391,7 +391,7 @@ dependencies = [ "log", "partitionlib", "redox-daemon", - "redox-scheme 0.5.0", + "redox-scheme 0.6.2", "redox_syscall", ] @@ -457,7 +457,7 @@ dependencies = [ "orbclient", "ransid", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_event", "redox_syscall", ] @@ -729,7 +729,7 @@ dependencies = [ "log", "orbclient", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_syscall", ] @@ -977,7 +977,7 @@ dependencies = [ "pico-args", "plain", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_syscall", "serde", ] @@ -1143,16 +1143,6 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "redox-scheme" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a96b9cfb034251dfb0aaa66a67059a7f0ea344039904d1d70cd36266af9c8a2f" -dependencies = [ - "libredox", - "redox_syscall", -] - [[package]] name = "redox-scheme" version = "0.6.2" @@ -2041,7 +2031,7 @@ dependencies = [ "pcid", "plain", "redox-daemon", - "redox-scheme 0.4.0", + "redox-scheme 0.6.2", "redox_event", "redox_syscall", "regex", diff --git a/acpid/Cargo.toml b/acpid/Cargo.toml index a7ee63043c..b704be076c 100644 --- a/acpid/Cargo.toml +++ b/acpid/Cargo.toml @@ -23,5 +23,5 @@ ron = "0.8.1" amlserde = { path = "../amlserde" } common = { path = "../common" } libredox = "0.1.3" -redox-scheme = "0.4" +redox-scheme = "0.6.2" arrayvec = "0.7.6" diff --git a/acpid/src/main.rs b/acpid/src/main.rs index d53ef51e76..aef18c2cb6 100644 --- a/acpid/src/main.rs +++ b/acpid/src/main.rs @@ -114,7 +114,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { match req.kind() { RequestKind::Call(call) => { - let response = call.handle_scheme(&mut scheme); + let response = call.handle_sync(&mut scheme); socket .write_response(response, SignalBehavior::Restart) .expect("acpid: failed to write response"); diff --git a/acpid/src/scheme.rs b/acpid/src/scheme.rs index a380a33dca..e744b5b257 100644 --- a/acpid/src/scheme.rs +++ b/acpid/src/scheme.rs @@ -1,6 +1,7 @@ use core::str; use parking_lot::RwLockReadGuard; -use redox_scheme::{CallerCtx, OpenResult, Scheme}; +use redox_scheme::scheme::SchemeSync; +use redox_scheme::{CallerCtx, OpenResult}; use std::collections::BTreeMap; use std::convert::{TryFrom, TryInto}; use syscall::dirent::{DirEntry, DirentBuf, DirentKind}; @@ -141,8 +142,8 @@ fn parse_table(table: &[u8]) -> Option { }) } -impl Scheme for AcpiScheme<'_> { - fn xopen(&mut self, path: &str, flags: usize, _ctx: &CallerCtx) -> Result { +impl SchemeSync for AcpiScheme<'_> { + fn open(&mut self, path: &str, flags: usize, _ctx: &CallerCtx) -> Result { let path = path.trim_start_matches('/'); let flag_stat = flags & O_STAT == O_STAT; @@ -218,7 +219,7 @@ impl Scheme for AcpiScheme<'_> { }) } - fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { + fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> { let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?; stat.st_size = handle @@ -233,10 +234,17 @@ impl Scheme for AcpiScheme<'_> { stat.st_mode = MODE_FILE; } - Ok(0) + Ok(()) } - fn read(&mut self, id: usize, buf: &mut [u8], offset: u64, _fcntl: u32) -> Result { + fn read( + &mut self, + id: usize, + buf: &mut [u8], + offset: u64, + _fcntl: u32, + _ctx: &CallerCtx, + ) -> Result { let offset: usize = offset.try_into().map_err(|_| Error::new(EINVAL))?; let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?; @@ -340,7 +348,14 @@ impl Scheme for AcpiScheme<'_> { Ok(buf) } - fn write(&mut self, _id: usize, _buf: &[u8], _offset: u64, _fcntl: u32) -> Result { + fn write( + &mut self, + _id: usize, + _buf: &[u8], + _offset: u64, + _fcntl: u32, + _ctx: &CallerCtx, + ) -> Result { Err(Error::new(EBADF)) } } diff --git a/graphics/bgad/Cargo.toml b/graphics/bgad/Cargo.toml index 894f414377..eb62538387 100644 --- a/graphics/bgad/Cargo.toml +++ b/graphics/bgad/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] orbclient = "0.3.47" redox-daemon = "0.1" -redox-scheme = "0.4" +redox-scheme = "0.6.2" redox_syscall = "0.5" common = { path = "../../common" } diff --git a/graphics/bgad/src/main.rs b/graphics/bgad/src/main.rs index c8d4e55c56..2d30ac4e1b 100644 --- a/graphics/bgad/src/main.rs +++ b/graphics/bgad/src/main.rs @@ -47,10 +47,10 @@ fn main() { }; match request.kind() { RequestKind::Call(call) => { - let response = call.handle_scheme(&mut scheme); + let response = call.handle_sync(&mut scheme); socket - .write_responses(&[response], SignalBehavior::Restart) + .write_response(response, SignalBehavior::Restart) .expect("bgad: failed to write next scheme response"); } RequestKind::OnClose { id } => { diff --git a/graphics/bgad/src/scheme.rs b/graphics/bgad/src/scheme.rs index 14ad5a6cb9..5cd214e91e 100644 --- a/graphics/bgad/src/scheme.rs +++ b/graphics/bgad/src/scheme.rs @@ -1,7 +1,9 @@ use inputd::ProducerHandle; -use redox_scheme::Scheme; +use redox_scheme::scheme::SchemeSync; +use redox_scheme::{CallerCtx, OpenResult}; use std::str; use syscall::data::Stat; +use syscall::schemev2::NewFdFlags; use syscall::{Error, Result, EACCES, EINVAL, MODE_CHR}; use crate::bga::Bga; @@ -25,10 +27,13 @@ impl BgaScheme { } } -impl Scheme for BgaScheme { - fn open(&mut self, _path: &str, _flags: usize, uid: u32, _gid: u32) -> Result { - if uid == 0 { - Ok(0) +impl SchemeSync for BgaScheme { + fn open(&mut self, _path: &str, _flags: usize, ctx: &CallerCtx) -> Result { + if ctx.uid == 0 { + Ok(OpenResult::ThisScheme { + number: 0, + flags: NewFdFlags::empty(), + }) } else { Err(Error::new(EACCES)) } @@ -40,6 +45,7 @@ impl Scheme for BgaScheme { buf: &mut [u8], _offset: u64, _fcntl_flags: u32, + _ctx: &CallerCtx, ) -> Result { let mut i = 0; let data = format!("{},{}\n", self.bga.width(), self.bga.height()).into_bytes(); @@ -50,7 +56,14 @@ impl Scheme for BgaScheme { Ok(i) } - fn write(&mut self, _id: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result { + fn write( + &mut self, + _id: usize, + buf: &[u8], + _offset: u64, + _fcntl_flags: u32, + _ctx: &CallerCtx, + ) -> Result { let string = str::from_utf8(buf).or(Err(Error::new(EINVAL)))?; let string = string.trim(); @@ -75,7 +88,7 @@ impl Scheme for BgaScheme { Ok(buf.len()) } - fn fpath(&mut self, _file: usize, buf: &mut [u8]) -> Result { + fn fpath(&mut self, _file: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result { let mut i = 0; let scheme_path = b"bga"; while i < buf.len() && i < scheme_path.len() { @@ -85,16 +98,16 @@ impl Scheme for BgaScheme { Ok(i) } - fn fstat(&mut self, _id: usize, stat: &mut Stat) -> Result { + fn fstat(&mut self, _id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> { *stat = Stat { st_mode: MODE_CHR | 0o666, ..Default::default() }; - Ok(0) + Ok(()) } - fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { + fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize, _ctx: &CallerCtx) -> Result { Ok(0) } } diff --git a/graphics/fbbootlogd/Cargo.toml b/graphics/fbbootlogd/Cargo.toml index a4707c8640..4652dce682 100644 --- a/graphics/fbbootlogd/Cargo.toml +++ b/graphics/fbbootlogd/Cargo.toml @@ -9,7 +9,7 @@ ransid = "0.4" redox_event = "0.4" redox_syscall = "0.5" redox-daemon = "0.1" -redox-scheme = "0.4" +redox-scheme = "0.6.2" console-draw = { path = "../console-draw" } graphics-ipc = { path = "../graphics-ipc" } diff --git a/graphics/fbbootlogd/src/main.rs b/graphics/fbbootlogd/src/main.rs index cfd0ce59b1..b2f723ba3f 100644 --- a/graphics/fbbootlogd/src/main.rs +++ b/graphics/fbbootlogd/src/main.rs @@ -85,10 +85,10 @@ fn inner(daemon: redox_daemon::Daemon) -> ! { match request.kind() { RequestKind::Call(call) => { - let response = call.handle_scheme(&mut scheme); + let response = call.handle_sync(&mut scheme); socket - .write_responses(&[response], SignalBehavior::Restart) + .write_response(response, SignalBehavior::Restart) .expect("pcid: failed to write next scheme response"); } RequestKind::OnClose { id } => { diff --git a/graphics/fbbootlogd/src/scheme.rs b/graphics/fbbootlogd/src/scheme.rs index 647999fb3b..1cf2f21cf2 100644 --- a/graphics/fbbootlogd/src/scheme.rs +++ b/graphics/fbbootlogd/src/scheme.rs @@ -4,7 +4,9 @@ use std::ptr; use console_draw::TextScreen; use graphics_ipc::v2::V2GraphicsHandle; use inputd::ConsumerHandle; -use redox_scheme::Scheme; +use redox_scheme::scheme::SchemeSync; +use redox_scheme::{CallerCtx, OpenResult}; +use syscall::schemev2::NewFdFlags; use syscall::{Error, Result, EINVAL, ENOENT}; pub struct DisplayMap { @@ -110,16 +112,19 @@ impl FbbootlogScheme { } } -impl Scheme for FbbootlogScheme { - fn open(&mut self, path_str: &str, _flags: usize, _uid: u32, _gid: u32) -> Result { +impl SchemeSync for FbbootlogScheme { + fn open(&mut self, path_str: &str, _flags: usize, _ctx: &CallerCtx) -> Result { if !path_str.is_empty() { return Err(Error::new(ENOENT)); } - Ok(0) + Ok(OpenResult::ThisScheme { + number: 0, + flags: NewFdFlags::empty(), + }) } - fn fpath(&mut self, _id: usize, buf: &mut [u8]) -> Result { + fn fpath(&mut self, _id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result { let path = b"fbbootlog:"; let mut i = 0; @@ -131,8 +136,8 @@ impl Scheme for FbbootlogScheme { Ok(i) } - fn fsync(&mut self, _id: usize) -> Result { - Ok(0) + fn fsync(&mut self, _id: usize, _ctx: &CallerCtx) -> Result<()> { + Ok(()) } fn read( @@ -141,11 +146,19 @@ impl Scheme for FbbootlogScheme { _buf: &mut [u8], _offset: u64, _fcntl_flags: u32, + _ctx: &CallerCtx, ) -> Result { Err(Error::new(EINVAL)) } - fn write(&mut self, _id: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result { + fn write( + &mut self, + _id: usize, + buf: &[u8], + _offset: u64, + _fcntl_flags: u32, + _ctx: &CallerCtx, + ) -> Result { if let Some(map) = &mut self.display_map { Self::handle_resize(map, &mut self.text_screen); diff --git a/inputd/Cargo.toml b/inputd/Cargo.toml index cf1de6546e..20ccff318a 100644 --- a/inputd/Cargo.toml +++ b/inputd/Cargo.toml @@ -13,4 +13,4 @@ orbclient = "0.3.27" libredox = "0.1.3" common = { path = "../common" } -redox-scheme = "0.4" +redox-scheme = "0.6.2" diff --git a/inputd/src/main.rs b/inputd/src/main.rs index d69aa81ef5..4b8646f4c5 100644 --- a/inputd/src/main.rs +++ b/inputd/src/main.rs @@ -19,9 +19,11 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use inputd::{VtActivate, VtEvent, VtEventKind}; use libredox::errno::ESTALE; -use redox_scheme::{RequestKind, Scheme, SignalBehavior, Socket}; +use redox_scheme::scheme::SchemeSync; +use redox_scheme::{CallerCtx, OpenResult, RequestKind, Response, SignalBehavior, Socket}; use orbclient::{Event, EventOption}; +use syscall::schemev2::NewFdFlags; use syscall::{Error as SysError, EventFlags, EINVAL}; enum Handle { @@ -121,8 +123,8 @@ impl InputScheme { } } -impl Scheme for InputScheme { - fn open(&mut self, path: &str, _flags: usize, _uid: u32, _gid: u32) -> syscall::Result { +impl SchemeSync for InputScheme { + fn open(&mut self, path: &str, _flags: usize, _ctx: &CallerCtx) -> syscall::Result { let mut path_parts = path.split('/'); let command = path_parts.next().ok_or(SysError::new(EINVAL))?; @@ -211,10 +213,13 @@ impl Scheme for InputScheme { log::info!("inputd: {path} channel has been opened"); self.handles.insert(fd, handle_ty); - Ok(fd) + Ok(OpenResult::ThisScheme { + number: fd, + flags: NewFdFlags::empty(), + }) } - fn fpath(&mut self, id: usize, buf: &mut [u8]) -> syscall::Result { + fn fpath(&mut self, id: usize, buf: &mut [u8], _ctx: &CallerCtx) -> syscall::Result { let handle = self.handles.get(&id).ok_or(SysError::new(EINVAL))?; if let Handle::Consumer { vt, .. } = handle { @@ -236,6 +241,7 @@ impl Scheme for InputScheme { buf: &mut [u8], _offset: u64, _fcntl_flags: u32, + _ctx: &CallerCtx, ) -> syscall::Result { let handle = self.handles.get_mut(&id).ok_or(SysError::new(EINVAL))?; @@ -294,6 +300,7 @@ impl Scheme for InputScheme { buf: &[u8], _offset: u64, _fcntl_flags: u32, + _ctx: &CallerCtx, ) -> syscall::Result { self.has_new_events = true; @@ -429,6 +436,7 @@ impl Scheme for InputScheme { &mut self, id: usize, flags: syscall::EventFlags, + _ctx: &CallerCtx, ) -> syscall::Result { let handle = self.handles.get_mut(&id).ok_or(SysError::new(EINVAL))?; @@ -496,7 +504,7 @@ fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> { match request.kind() { RequestKind::Call(call_request) => { socket_file.write_response( - call_request.handle_scheme(&mut scheme), + call_request.handle_sync(&mut scheme), SignalBehavior::Restart, )?; } @@ -527,7 +535,10 @@ fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> { } // Notify the consumer that we have some events to read. Yum yum. - socket_file.post_fevent(*id, EventFlags::EVENT_READ.bits())?; + socket_file.write_response( + Response::post_fevent(*id, EventFlags::EVENT_READ.bits()), + SignalBehavior::Restart, + )?; *notified = true; } @@ -542,7 +553,10 @@ fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> { } // Notify the consumer that we have some events to read. Yum yum. - socket_file.post_fevent(*id, EventFlags::EVENT_READ.bits())?; + socket_file.write_response( + Response::post_fevent(*id, EventFlags::EVENT_READ.bits()), + SignalBehavior::Restart, + )?; *notified = true; } diff --git a/pcid/Cargo.toml b/pcid/Cargo.toml index 78f0192346..45261f838b 100644 --- a/pcid/Cargo.toml +++ b/pcid/Cargo.toml @@ -20,7 +20,7 @@ pci_types = "0.10" pico-args = { version = "0.5", features = ["combined-flags"] } plain = "0.2" redox-daemon = "0.1" -redox-scheme = "0.4" +redox-scheme = "0.6.2" redox_syscall = "0.5.9" serde = { version = "1", features = ["derive"] } diff --git a/pcid/src/main.rs b/pcid/src/main.rs index 3545c800f9..2035ac497b 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -223,10 +223,10 @@ fn main_inner(daemon: redox_daemon::Daemon) -> ! { }; match request.kind() { RequestKind::Call(call) => { - let response = call.handle_scheme(&mut scheme); + let response = call.handle_sync(&mut scheme); socket - .write_responses(&[response], SignalBehavior::Restart) + .write_response(response, SignalBehavior::Restart) .expect("pcid: failed to write next scheme response"); } RequestKind::OnClose { id } => { diff --git a/pcid/src/scheme.rs b/pcid/src/scheme.rs index cee1fc7a11..135a067b73 100644 --- a/pcid/src/scheme.rs +++ b/pcid/src/scheme.rs @@ -1,7 +1,8 @@ use std::collections::{BTreeMap, VecDeque}; use pci_types::PciAddress; -use redox_scheme::{CallerCtx, OpenResult, Scheme}; +use redox_scheme::scheme::SchemeSync; +use redox_scheme::{CallerCtx, OpenResult}; use syscall::dirent::{DirEntry, DirentBuf, DirentKind}; use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, EIO, EISDIR, ENOENT, ENOTDIR}; use syscall::flag::{MODE_CHR, MODE_DIR, O_DIRECTORY, O_STAT}; @@ -45,8 +46,8 @@ enum ChannelState { const DEVICE_CONTENTS: &[&str] = &["channel"]; -impl Scheme for PciScheme { - fn xopen(&mut self, path: &str, flags: usize, ctx: &CallerCtx) -> Result { +impl SchemeSync for PciScheme { + fn open(&mut self, path: &str, flags: usize, ctx: &CallerCtx) -> Result { log::trace!("OPEN `{}` flags {}", path, flags); // TODO: Check flags are correct @@ -97,7 +98,7 @@ impl Scheme for PciScheme { flags: NewFdFlags::POSITIONED, }) } - fn fstat(&mut self, id: usize, stat: &mut syscall::Stat) -> Result { + fn fstat(&mut self, id: usize, stat: &mut syscall::Stat, _ctx: &CallerCtx) -> Result<()> { let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?; let (len, mode) = match handle.inner { @@ -107,7 +108,7 @@ impl Scheme for PciScheme { }; stat.st_size = len as u64; stat.st_mode = mode; - Ok(0) + Ok(()) } fn read( &mut self, @@ -115,6 +116,7 @@ impl Scheme for PciScheme { buf: &mut [u8], _offset: u64, _fcntl_flags: u32, + _ctx: &CallerCtx, ) -> Result { let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?; @@ -174,7 +176,14 @@ impl Scheme for PciScheme { Ok(buf) } - fn write(&mut self, id: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result { + fn write( + &mut self, + id: usize, + buf: &[u8], + _offset: u64, + _fcntl_flags: u32, + _ctx: &CallerCtx, + ) -> Result { let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?; if handle.stat { diff --git a/storage/driver-block/Cargo.toml b/storage/driver-block/Cargo.toml index 8f465cd535..7a0b2a4029 100644 --- a/storage/driver-block/Cargo.toml +++ b/storage/driver-block/Cargo.toml @@ -15,4 +15,4 @@ futures = { version = "0.3.28", features = ["executor"] } redox-daemon = "0.1" redox_syscall = { version = "0.5", features = ["std"] } -redox-scheme = "0.5" +redox-scheme = "0.6.2" diff --git a/xhcid/Cargo.toml b/xhcid/Cargo.toml index 95eb88ddee..7f566ce208 100644 --- a/xhcid/Cargo.toml +++ b/xhcid/Cargo.toml @@ -21,7 +21,7 @@ lazy_static = "1.4" log = "0.4" redox-daemon = "0.1" redox_event = "0.4.1" -redox-scheme = "0.4" +redox-scheme = "0.6.2" redox_syscall = "0.5" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/xhcid/src/main.rs b/xhcid/src/main.rs index a7a2d86e9a..800614e2e0 100644 --- a/xhcid/src/main.rs +++ b/xhcid/src/main.rs @@ -210,7 +210,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { match request.kind() { RequestKind::Call(call_request) => { - let resp = call_request.handle_scheme(&mut &*hci); + let resp = call_request.handle_sync(&mut &*hci); socket .write_response(resp, SignalBehavior::Restart) .expect("xhcid: failed to write scheme"); diff --git a/xhcid/src/xhci/scheme.rs b/xhcid/src/xhci/scheme.rs index 29c5b58e08..12d77d39e3 100644 --- a/xhcid/src/xhci/scheme.rs +++ b/xhcid/src/xhci/scheme.rs @@ -25,10 +25,11 @@ use std::{cmp, fmt, io, mem, str}; use common::dma::Dma; use futures::executor::block_on; use log::{debug, error, info, trace, warn}; +use redox_scheme::scheme::SchemeSync; use smallvec::SmallVec; use common::io::Io; -use redox_scheme::{CallerCtx, OpenResult, Scheme}; +use redox_scheme::{CallerCtx, OpenResult}; use syscall::schemev2::NewFdFlags; use syscall::{ Error, Result, Stat, EACCES, EBADF, EBADFD, EBADMSG, EINVAL, EIO, EISDIR, ENOENT, ENOSYS, @@ -2098,8 +2099,8 @@ impl Xhci { } } -impl Scheme for &Xhci { - fn xopen(&mut self, path_str: &str, flags: usize, ctx: &CallerCtx) -> Result { +impl SchemeSync for &Xhci { + fn open(&mut self, path_str: &str, flags: usize, ctx: &CallerCtx) -> Result { if ctx.uid != 0 { return Err(Error::new(EACCES)); } @@ -2152,7 +2153,7 @@ impl Scheme for &Xhci { }) } - fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { + fn fstat(&mut self, id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> { let guard = self.handles.get(&id).ok_or(Error::new(EBADF))?; stat.st_mode = match (&*guard).get_handle_type() { @@ -2174,10 +2175,10 @@ impl Scheme for &Xhci { _ => {} } - Ok(0) + Ok(()) } - fn fpath(&mut self, fd: usize, buffer: &mut [u8]) -> Result { + fn fpath(&mut self, fd: usize, buffer: &mut [u8], _ctx: &CallerCtx) -> Result { let mut cursor = io::Cursor::new(buffer); let guard = self.handles.get(&fd).ok_or(Error::new(EBADF))?; @@ -2195,7 +2196,14 @@ impl Scheme for &Xhci { Ok(src_len) } - fn read(&mut self, fd: usize, buf: &mut [u8], offset: u64, _fcntl_flags: u32) -> Result { + fn read( + &mut self, + fd: usize, + buf: &mut [u8], + offset: u64, + _fcntl_flags: u32, + _ctx: &CallerCtx, + ) -> Result { let offset = offset as usize; let mut guard = self.handles.get_mut(&fd).ok_or(Error::new(EBADF))?; trace!( @@ -2258,7 +2266,14 @@ impl Scheme for &Xhci { } } } - fn write(&mut self, fd: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result { + fn write( + &mut self, + fd: usize, + buf: &[u8], + _offset: u64, + _fcntl_flags: u32, + _ctx: &CallerCtx, + ) -> Result { let mut guard = self.handles.get_mut(&fd).ok_or(Error::new(EBADF))?; trace!( "WRITE fd={}, handle={:?}, buf=(addr {:p}, length {})",