in clients/filesystem-fuse/src/main.rs [192:276]
fn main() -> Result<(), i32> {
let directives = env::var("RUST_LOG").unwrap_or("".to_string());
let args = command_args::Arguments::parse();
let reload_handle = init_tracing_subscriber(directives.as_str());
match args.command {
Commands::Mount {
mount_point,
fileset_location,
config,
debug: debug_level,
foreground,
} => {
let app_config = AppConfig::from_file(config);
if let Err(e) = &app_config {
error!("Failed to load config: {:?}", e);
return Err(-1);
};
let mut app_config = app_config.unwrap();
let mount_point = {
let path = Path::new(&mount_point).canonicalize();
if let Err(e) = path {
error!("Failed to resolve mount point: {:?}", e);
return Err(-1);
};
let path = path.unwrap();
path.to_string_lossy().to_string()
};
// if debug > 0, it means that we needs fuse_debug.
app_config.fuse.fuse_debug = debug_level > 0 || app_config.fuse.fuse_debug;
match debug_level {
0 => {
// Use the value in RUST_LOG, no need to modify filter
}
1 => {
// debug feature of gvfs_fuse is enabled.
reload_handle
.modify(|filter| {
*filter = filter::EnvFilter::builder()
.parse([directives.as_str(), "gvfs_fuse=debug"].join(",").as_str())
.unwrap();
})
.unwrap();
}
_ => {
error!("Unsupported debug level: {}", debug_level);
return Err(-1);
}
}
let result = init_dirs(&mut app_config, &mount_point);
if let Err(e) = result {
error!("Failed to initialize working directories: {:?}", e);
return Err(-1);
}
let result = if foreground {
mount_fuse(app_config, mount_point, fileset_location)
} else {
let result = make_daemon(&app_config);
info!("Making daemon");
if let Err(e) = result {
error!("Failed to daemonize: {:?}", e);
return Err(-1);
};
mount_fuse(app_config, mount_point, fileset_location)
};
if let Err(e) = result {
error!("Failed to mount gvfs: {:?}", e.to_string());
return Err(-1);
};
Ok(())
}
Commands::Umount { mount_point, force } => {
let result = do_umount(&mount_point, force);
if let Err(e) = result {
error!("Failed to unmount gvfs: {:?}", e.to_string());
return Err(-1);
};
Ok(())
}
}
}