From fd125947c9db0b33761414e65e919f73d9bf1815 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Thu, 30 Nov 2023 12:01:11 -0800 Subject: Refactor workspace --- ayafs-core/src/bin/main.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ayafs-core/src/bin/main.rs (limited to 'ayafs-core/src/bin') diff --git a/ayafs-core/src/bin/main.rs b/ayafs-core/src/bin/main.rs new file mode 100644 index 0000000..25504b9 --- /dev/null +++ b/ayafs-core/src/bin/main.rs @@ -0,0 +1,44 @@ +use std::path::PathBuf; +use std::sync::Arc; +use clap::Parser; +use fuser::MountOption; +use log::LevelFilter; +use aya::AyaFS; +use aya::block_device::disk::Disk; + +#[derive(Parser, Debug)] +#[command(author, version, about)] +struct Args { + mount_point: Option, + #[arg(short, action = clap::ArgAction::Count)] + verbosity: u8, + #[arg(long)] + auto_unmount: bool, + #[arg(long)] + allow_root: bool, +} + +fn main() { + let args = Args::parse(); + let mount_point = args.mount_point.unwrap(); + let verbosity = args.verbosity; + let log_level = match verbosity { + 0 => LevelFilter::Error, + 1 => LevelFilter::Warn, + 2 => LevelFilter::Info, + 3 => LevelFilter::Debug, + _ => LevelFilter::Trace, + }; + env_logger::builder().filter_level(log_level).init(); + let options = vec![ + // MountOption::RO, + MountOption::FSName("hello".to_string()), + MountOption::AutoUnmount, + MountOption::AllowRoot, + ]; + let disk = Arc::new(Disk::new(PathBuf::from("/dev/nvme0n1p4"))); + // let disk = Arc::new(MemoryDisk::new(16384)); + let filesystem = AyaFS::new(disk, 7864320); + + fuser::mount2(filesystem, mount_point, &options).unwrap(); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2