diff --git a/src/main.rs b/src/main.rs index 68ded3b..dff3001 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::{ - borrow::Cow, fs::File, io::{Read, Seek}, os::mikros::{ipc, syscalls, Errno}, path::PathBuf, sync::Arc + borrow::Cow, fs::File, io::{Read, Seek}, os::mikros::{ipc, syscalls, Errno, FileOpenMode}, path::PathBuf, sync::Arc }; use parking_lot::RwLock; @@ -37,7 +37,11 @@ impl fs_rpc::Server for Serv { Ok((self.mounts.read().len() - 1) as u64) } - fn open(&self, path: &std::path::Path, mount_id: u64) -> Result<(Option, u64), Errno> { + fn open(&self, path: &std::path::Path, mode: FileOpenMode, mount_id: u64) -> Result<(Option, u64), Errno> { + if !mode.readable() || mode.writable() { + // WRiting isn't supported yet, so the only sensible mode is readonly. + return Err(Errno::EACCES) + } let mounts = self.mounts.read(); let mount = &mounts[mount_id as usize]; let (&file_offset, &file_size) = mount