fixed and update fat-mount

This commit is contained in:
Moritz Gmeiner 2025-07-31 01:07:48 +02:00
commit df20ae6f0c
3 changed files with 39 additions and 4 deletions

25
Cargo.lock generated
View file

@ -168,6 +168,16 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "ctrlc"
version = "3.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f93780a459b7d656ef7f071fe699c4d3d2cb201c4b24d085b6ddc505276e73"
dependencies = [
"nix 0.30.1",
"windows-sys",
]
[[package]] [[package]]
name = "enum_dispatch" name = "enum_dispatch"
version = "0.3.13" version = "0.3.13"
@ -243,6 +253,7 @@ name = "fat-mount"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ctrlc",
"env_logger", "env_logger",
"fat-fuse", "fat-fuse",
"fuser", "fuser",
@ -257,7 +268,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"memchr", "memchr",
"nix", "nix 0.29.0",
"page_size", "page_size",
"pkg-config", "pkg-config",
"smallvec", "smallvec",
@ -376,6 +387,18 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "nix"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.19" version = "0.2.19"

View file

@ -5,6 +5,7 @@ edition = "2024"
[dependencies] [dependencies]
anyhow = "1.0.98" anyhow = "1.0.98"
ctrlc = "3.4.7"
env_logger = "0.11.8" env_logger = "0.11.8"
fat-fuse = { version = "0.1.0", path = "../fat-fuse" } fat-fuse = { version = "0.1.0", path = "../fat-fuse" }
fuser = "0.15.1" fuser = "0.15.1"

View file

@ -1,6 +1,5 @@
use std::cell::RefCell;
use std::fs::File; use std::fs::File;
use std::rc::Rc; use std::sync::mpsc::channel;
use fat_fuse::FatFuse; use fat_fuse::FatFuse;
use fuser::MountOption; use fuser::MountOption;
@ -10,6 +9,7 @@ fn main() -> anyhow::Result<()> {
let mut args = std::env::args(); let mut args = std::env::args();
let _prog_name = args.next().unwrap();
let path = args.next().ok_or(anyhow::anyhow!("missing fs path"))?; let path = args.next().ok_or(anyhow::anyhow!("missing fs path"))?;
let mountpoint = args.next().ok_or(anyhow::anyhow!("missing mount point"))?; let mountpoint = args.next().ok_or(anyhow::anyhow!("missing mount point"))?;
@ -23,7 +23,18 @@ fn main() -> anyhow::Result<()> {
MountOption::AutoUnmount, MountOption::AutoUnmount,
]; ];
fuser::mount2(fat_fuse, mountpoint, &options).unwrap(); let (tx, rx) = channel();
ctrlc::set_handler(move || {
tx.send(()).unwrap();
})
.unwrap();
let handle = fuser::spawn_mount2(fat_fuse, mountpoint, &options)?;
rx.recv().unwrap();
println!("done");
Ok(()) Ok(())
} }