27 lines
636 B
Rust
27 lines
636 B
Rust
use crate::fs::{FsBackend, FsState};
|
|
use crate::os::SystemOS;
|
|
|
|
pub struct FsFacade<'a> {
|
|
pub(in crate::os) os: &'a mut SystemOS,
|
|
}
|
|
|
|
impl<'a> FsFacade<'a> {
|
|
pub fn needs_mount(&self) -> bool {
|
|
matches!(self.os.fs_state, FsState::Unmounted | FsState::Error(_))
|
|
}
|
|
|
|
pub fn mount(&mut self, backend: Box<dyn FsBackend>) {
|
|
self.os.vm_runtime.mount_fs(
|
|
&mut self.os.log_service,
|
|
&mut self.os.fs,
|
|
&mut self.os.fs_state,
|
|
backend,
|
|
);
|
|
}
|
|
|
|
pub fn unmount(&mut self) {
|
|
self.os.fs.unmount();
|
|
self.os.fs_state = FsState::Unmounted;
|
|
}
|
|
}
|