[cache_dump (rust)] First draft of cache_dump

This commit is contained in:
Ming-Hung Tsai
2021-02-25 18:14:44 +08:00
parent fde0e0e2b8
commit eb3d181f95
3 changed files with 199 additions and 0 deletions

41
src/bin/cache_dump.rs Normal file
View File

@@ -0,0 +1,41 @@
extern crate clap;
extern crate thinp;
use clap::{App, Arg};
use std::path::Path;
use thinp::cache::dump::{dump, CacheDumpOptions};
//------------------------------------------
fn main() {
let parser = App::new("cache_check")
.version(thinp::version::TOOLS_VERSION)
.arg(
Arg::with_name("INPUT")
.help("Specify the input device to check")
.required(true)
.index(1),
)
.arg(
Arg::with_name("REPAIR")
.help("")
.long("repair")
.value_name("REPAIR"),
);
let matches = parser.get_matches();
let input_file = Path::new(matches.value_of("INPUT").unwrap());
let opts = CacheDumpOptions {
dev: &input_file,
async_io: false,
repair: matches.is_present("REPAIR"),
};
if let Err(reason) = dump(opts) {
eprintln!("{}", reason);
std::process::exit(1);
}
}
//------------------------------------------