feat(storage): full file protocol over per-client shared region (badged clients, owned handles, clamped lengths, ReadOnly on unwritable disk); init loads via libkos::fs; drop boot shared buffer
This commit is contained in:
@@ -24,6 +24,7 @@ impl FileEntry {
|
||||
pub struct MockFileSystem {
|
||||
files: [Option<FileEntry>; MAX_FILES],
|
||||
count: usize,
|
||||
read_only: bool,
|
||||
}
|
||||
|
||||
impl MockFileSystem {
|
||||
@@ -31,9 +32,16 @@ impl MockFileSystem {
|
||||
Self {
|
||||
files: [const { None }; MAX_FILES],
|
||||
count: 0,
|
||||
read_only: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// The same file system, refusing all writes.
|
||||
pub fn read_only(mut self) -> Self {
|
||||
self.read_only = true;
|
||||
self
|
||||
}
|
||||
|
||||
fn find_by_name(&self, path: &[u8]) -> Option<usize> {
|
||||
for i in 0..MAX_FILES {
|
||||
if let Some(entry) = &self.files[i] {
|
||||
@@ -47,6 +55,10 @@ impl MockFileSystem {
|
||||
}
|
||||
|
||||
impl FileSystem for MockFileSystem {
|
||||
fn writable(&self) -> bool {
|
||||
!self.read_only
|
||||
}
|
||||
|
||||
fn open(&mut self, path: &[u8]) -> Option<FileHandle> {
|
||||
let idx = self.find_by_name(path)?;
|
||||
if let Some(entry) = &mut self.files[idx] {
|
||||
|
||||
Reference in New Issue
Block a user