From 76f29415fa8e3b9c59674c749b41986011d0c9c2 Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 16 Nov 2024 11:55:45 -0600 Subject: [PATCH] Add mode to open operation --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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