4 // convert existing log statements to tracing events
5 // tracing_log::LogTracer::init().expect("logtracer init failed!");
6 // format tracing log data to env_logger like stdout
7 tracing_subscriber::fmt::init();
9 if let Err(e) = crate::main_inner() {
10 tracing::error!(fatal_error = ?e);
14 #[tracing_attributes::instrument("main")]
15 pub fn main_inner() -> anyhow::Result<()> {
16 use bcachefs_mount::{filesystem, key, Cli};
18 libc::setvbuf(filesystem::stdout, std::ptr::null_mut(), libc::_IONBF, 0);
19 // libc::fflush(filesystem::stdout);
22 let opt = Cli::parse();
24 tracing::trace!(?opt);
26 let fss = filesystem::probe_filesystems()?;
29 .ok_or_else(|| anyhow::anyhow!("filesystem was not found"))?;
31 tracing::info!(msg="found filesystem", %fs);
36 .ok_or_else(|| anyhow::anyhow!("no keyoption specified for locked filesystem"))?;
38 key::prepare_key(&fs, key)?;
43 .ok_or_else(|| anyhow::anyhow!("mountpoint option was not specified"))?;
45 fs.mount(&mountpoint, &opt.options)?;
52 // use insta::assert_debug_snapshot;
54 // fn snapshot_testing() {
55 // insta::assert_debug_snapshot!();