46 lines
1.0 KiB
Rust
46 lines
1.0 KiB
Rust
#[macro_use]
|
|
extern crate log;
|
|
|
|
use clap::Parser;
|
|
use env_logger::Env;
|
|
use fuser::MountOption;
|
|
|
|
mod fs;
|
|
|
|
#[derive(Parser)]
|
|
#[command(version, about, long_about = None)]
|
|
struct Args {
|
|
/// Pass FUSE options to library
|
|
#[arg(short = 'o', value_name = "OPT")]
|
|
options: Vec<String>,
|
|
|
|
/// Allow opening files with O_DIRECT
|
|
#[arg(long = "allow-direct-io")]
|
|
allow_direct_io: bool,
|
|
|
|
/// Mount point
|
|
#[arg(value_name = "MOUNT_POINT")]
|
|
mount_point: String,
|
|
}
|
|
|
|
fn main() {
|
|
env_logger::init_from_env(Env::new().filter("CORRUPTFS_LOG"));
|
|
|
|
let args = Args::parse();
|
|
debug!("extra options: {:?}", args.options);
|
|
|
|
let mut options = vec![
|
|
MountOption::FSName("corruptfs".to_string()),
|
|
MountOption::NoDev,
|
|
MountOption::NoSuid,
|
|
MountOption::RW,
|
|
];
|
|
options.extend(
|
|
args.options
|
|
.iter()
|
|
.map(|opt| MountOption::CUSTOM(opt.clone())),
|
|
);
|
|
|
|
fuser::mount2(fs::CorruptFs::new(args.allow_direct_io), args.mount_point, &options).unwrap();
|
|
}
|