use clap::{Parser, Subcommand}; use std::path::PathBuf; use anyhow::Result; #[derive(Parser)] #[command(name = "markbase-fuse-rust", about = "MarkBase FUSE (Rust libfuse3)")] struct Cli { #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Mount FUSE filesystem Mount { /// User ID #[arg(short, long)] user: String, /// Mount path #[arg(short, long)] dir: PathBuf, /// Database path #[arg(long)] db: Option, }, } fn main() -> Result<()> { let cli = Cli::parse(); match cli.command { Commands::Mount { user, dir, db } => { mount_user(user, dir, db)?; } } Ok(()) } fn mount_user(user: String, dir: PathBuf, db_path: Option) -> Result<()> { use markbase_fuse::fuse_rust::MarkBaseFs; use std::env::current_dir; let db_path = match db_path { Some(p) => p, None => { let mut path = current_dir()?; path.push("data/users"); path.push(format!("{}.sqlite", user)); path } }; if !db_path.exists() { return Err(anyhow::anyhow!("Database not found: {}", db_path.display())); } if !dir.exists() { std::fs::create_dir_all(&dir)?; } println!("=== MarkBase FUSE (Rust v15 equivalent) ==="); println!("User: {}", user); println!("Database: {}", db_path.display()); println!("Mount: {}", dir.display()); println!("Features:"); println!(" - 512KB read chunks"); println!(" - Hash-based cache (1000 entries)"); println!(" - Path cache (2000 entries)"); println!(" - Pre-cache 1000 files"); println!(" - Thread-safe Mutex"); println!(""); let fs = MarkBaseFs::new(&db_path.to_string_lossy())?; // Mount using fuse crate fuse::mount(fs, &dir, &[]); Ok(()) }