use std::{path::PathBuf, process::Stdio};
use clap::Parser;
use wasmer_wasix::fs::WasiFdSeed;
use super::fs::JournalFileSystemBuilder;
use crate::commands::CliCommand;
#[derive(Debug, Parser)]
pub struct CmdJournalMount {
#[clap(index = 1)]
journal_path: PathBuf,
#[clap(index = 2)]
mount_path: PathBuf,
}
impl CliCommand for CmdJournalMount {
type Output = ();
fn run(self) -> Result<(), anyhow::Error> {
std::process::Command::new("/bin/umount")
.arg(self.mount_path.to_string_lossy().as_ref())
.stderr(Stdio::null())
.stdout(Stdio::null())
.spawn()?
.wait()
.ok();
let fs = JournalFileSystemBuilder::new(&self.journal_path)
.with_fd_seed(WasiFdSeed::default())
.with_progress_bar(false)
.build()?;
fuser::mount(fs, &self.mount_path, &[])?;
Ok(())
}
}