2 // convert existing log statements to tracing events
3 // tracing_log::LogTracer::init().expect("logtracer init failed!");
4 // format tracing log data to env_logger like stdout
5 tracing_subscriber::fmt::init();
7 if let Err(e) = crate::main_inner() {
8 tracing::error!(fatal_error = ?e);
14 #[tracing_attributes::instrument("main")]
15 pub fn main_inner() -> anyhow::Result<()> {
16 use structopt::StructOpt;
17 use bcachefs_mount::{Options, filesystem, key};
25 // libc::fflush(filesystem::stdout);
27 let opt = Options::from_args();
30 tracing::trace!(?opt);
32 let fss = filesystem::probe_filesystems()?;
35 .ok_or_else(|| anyhow::anyhow!("filesystem was not found"))?;
37 tracing::info!(msg="found filesystem", %fs);
42 .ok_or_else(|| anyhow::anyhow!("no keyoption specified for locked filesystem"))?;
44 key::prepare_key(&fs, key)?;
49 .ok_or_else(|| anyhow::anyhow!("mountpoint option was not specified"))?;
51 fs.mount(&mountpoint, &opt.options)?;
58 // use insta::assert_debug_snapshot;
60 // fn snapshot_testing() {
61 // insta::assert_debug_snapshot!();