diff options
author | Chuyan Zhang <me@zcy.moe> | 2023-11-30 12:01:11 -0800 |
---|---|---|
committer | Chuyan Zhang <me@zcy.moe> | 2023-11-30 12:01:11 -0800 |
commit | fd125947c9db0b33761414e65e919f73d9bf1815 (patch) | |
tree | c4c66d95ba85601427928aa7f23659590055d464 /ayafs-core/src/bin | |
parent | 1eac97eea4ec0bcef0be061a2cba93a584355283 (diff) | |
download | myfs-fd125947c9db0b33761414e65e919f73d9bf1815.tar.gz myfs-fd125947c9db0b33761414e65e919f73d9bf1815.zip |
Refactor workspace
Diffstat (limited to 'ayafs-core/src/bin')
-rw-r--r-- | ayafs-core/src/bin/main.rs | 44 |
1 files changed, 44 insertions, 0 deletions
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<String>, + #[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 |