Add mode to open operation

This commit is contained in:
pjht 2024-11-16 11:55:49 -06:00
parent 581bb3524a
commit b6af654b1a
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -3,7 +3,7 @@ mod ext2;
use std::{
borrow::Cow,
fs::File,
os::mikros::{ipc, syscalls, Errno},
os::mikros::{ipc, syscalls, Errno, FileOpenMode},
sync::Arc, usize,
};
@ -34,7 +34,11 @@ impl fs_rpc::Server for Serv {
res
}
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 = mount.open(path)?;