Add mode to open operation
This commit is contained in:
parent
652d4fc566
commit
76f29415fa
@ -1,5 +1,5 @@
|
|||||||
use std::{
|
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;
|
use parking_lot::RwLock;
|
||||||
@ -37,7 +37,11 @@ impl fs_rpc::Server for Serv {
|
|||||||
Ok((self.mounts.read().len() - 1) as u64)
|
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 mounts = self.mounts.read();
|
||||||
let mount = &mounts[mount_id as usize];
|
let mount = &mounts[mount_id as usize];
|
||||||
let (&file_offset, &file_size) = mount
|
let (&file_offset, &file_size) = mount
|
||||||
|
Loading…
Reference in New Issue
Block a user