Add mode to open operation

This commit is contained in:
pjht 2024-11-16 11:55:45 -06:00
parent 652d4fc566
commit 76f29415fa
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -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>, u64), Errno> {
fn open(&self, path: &std::path::Path, mode: FileOpenMode, mount_id: u64) -> Result<(Option<u64>, 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