Fix nullfs driver init

next
Sayan Nandan 7 months ago
parent e8e62cf924
commit b119a7053f
No known key found for this signature in database
GPG Key ID: 0EBD769024B24F0A

@ -32,6 +32,7 @@ use {
crate::engine::{
core::GlobalNS,
data::uuid::Uuid,
error::ErrorKind,
storage::{
safe_interfaces::{paths_v1, FSInterface, NullFS, VirtualFS},
GNSDriver, ModelDriver,
@ -68,7 +69,19 @@ impl<Fs: FSInterface> TestGlobal<Fs> {
impl<Fs: FSInterface> TestGlobal<Fs> {
pub fn new_with_driver_id(log_name: &str) -> Self {
let gns = GlobalNS::empty();
let driver = GNSDriver::open_gns_with_name(log_name, &gns).unwrap();
let driver = match GNSDriver::create_gns_with_name(log_name) {
Ok(drv) => Ok(drv),
Err(e) => match e.kind() {
ErrorKind::IoError(e_) => match e_.kind() {
std::io::ErrorKind::AlreadyExists => {
GNSDriver::open_gns_with_name(log_name, &gns)
}
_ => Err(e),
},
_ => Err(e),
},
}
.unwrap();
Self::new(gns, 0, driver)
}
}

@ -67,9 +67,12 @@ impl<Fs: FSInterface> GNSDriver<Fs> {
pub fn open_gns(gs: &GlobalNS) -> RuntimeResult<Self> {
Self::open_gns_with_name(Self::FILE_PATH, gs)
}
pub fn create_gns_with_name(name: &str) -> RuntimeResult<Self> {
journal::create_journal::<_, Fs>(name)
}
/// Create a new event log
pub fn create_gns() -> RuntimeResult<Self> {
journal::create_journal::<_, Fs>(Self::FILE_PATH)
Self::create_gns_with_name(Self::FILE_PATH)
}
}

@ -51,6 +51,9 @@ impl SysIOError {
pub fn into_inner(self) -> std::io::Error {
self.0
}
pub fn kind(&self) -> std::io::ErrorKind {
self.0.kind()
}
}
impl From<std::io::Error> for SysIOError {

Loading…
Cancel
Save