diff --git a/Cargo.lock b/Cargo.lock index 7a86e7e..db9c49a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,10 +150,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "fat-mount" -version = "0.1.0" - [[package]] name = "fuser" version = "0.15.1" diff --git a/fat-mount/Cargo.toml b/fat-mount/Cargo.toml new file mode 100644 index 0000000..e9f82da --- /dev/null +++ b/fat-mount/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "fat-mount" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = "1.0.98" +env_logger = "0.11.8" +fat-fuse = { version = "0.1.0", path = "../fat-fuse" } +fuser = "0.15.1" diff --git a/fat-mount/src/main.rs b/fat-mount/src/main.rs new file mode 100644 index 0000000..f9ea244 --- /dev/null +++ b/fat-mount/src/main.rs @@ -0,0 +1,29 @@ +use std::cell::RefCell; +use std::fs::File; +use std::rc::Rc; + +use fat_fuse::FatFuse; +use fuser::MountOption; + +fn main() -> anyhow::Result<()> { + env_logger::init(); + + let mut args = std::env::args(); + + let path = args.next().ok_or(anyhow::anyhow!("missing fs path"))?; + let mountpoint = args.next().ok_or(anyhow::anyhow!("missing mount point"))?; + + let file = File::open(path)?; + + let fat_fuse = FatFuse::new(Rc::new(RefCell::new(file)))?; + + let options = vec![ + MountOption::RO, + MountOption::FSName("fat-fuse".to_owned()), + MountOption::AutoUnmount, + ]; + + fuser::mount2(fat_fuse, mountpoint, &options).unwrap(); + + Ok(()) +}