diff options
Diffstat (limited to 'ayafs-core/src/bin')
-rw-r--r-- | ayafs-core/src/bin/main.rs | 9 | ||||
-rw-r--r-- | ayafs-core/src/bin/mem_run.rs | 43 |
2 files changed, 48 insertions, 4 deletions
diff --git a/ayafs-core/src/bin/main.rs b/ayafs-core/src/bin/main.rs index 25504b9..a2d838c 100644 --- a/ayafs-core/src/bin/main.rs +++ b/ayafs-core/src/bin/main.rs @@ -9,6 +9,7 @@ use aya::block_device::disk::Disk; #[derive(Parser, Debug)] #[command(author, version, about)] struct Args { + device_path: Option<String>, mount_point: Option<String>, #[arg(short, action = clap::ArgAction::Count)] verbosity: u8, @@ -20,6 +21,7 @@ struct Args { fn main() { let args = Args::parse(); + let device_path = args.device_path.unwrap(); let mount_point = args.mount_point.unwrap(); let verbosity = args.verbosity; let log_level = match verbosity { @@ -36,9 +38,8 @@ fn main() { 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); - + let disk = Arc::new(Disk::new(PathBuf::from(device_path))); + let filesystem = AyaFS::load(disk); + fuser::mount2(filesystem, mount_point, &options).unwrap(); }
\ No newline at end of file diff --git a/ayafs-core/src/bin/mem_run.rs b/ayafs-core/src/bin/mem_run.rs new file mode 100644 index 0000000..7ba6f4e --- /dev/null +++ b/ayafs-core/src/bin/mem_run.rs @@ -0,0 +1,43 @@ +use std::sync::Arc; +use clap::Parser; +use fuser::MountOption; +use log::LevelFilter; +use users::{get_current_gid, get_current_uid}; +use aya::AyaFS; +use aya::block_device::memory_disk::MemoryDisk; + +#[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(MemoryDisk::new(16384)); + let filesystem = AyaFS::new(disk, 16384, get_current_uid(), get_current_gid()); + + fuser::mount2(filesystem, mount_point, &options).unwrap(); +}
\ No newline at end of file |