[cache_check (rust)] Add more checks

- Report errors
- Support reading partially broken bitset
  - The output is a bitmap of 2-bit entries, indicating availability of bits
This commit is contained in:
Ming-Hung Tsai
2021-04-20 16:07:25 +08:00
parent 3279d8381b
commit 239ff7dfa1
4 changed files with 129 additions and 33 deletions

View File

@@ -1,8 +1,12 @@
extern crate clap;
extern crate thinp;
use atty::Stream;
use clap::{App, Arg};
use std::path::Path;
use std::sync::Arc;
use thinp::report::*;
use thinp::cache::check::{check, CacheCheckOptions};
//------------------------------------------
@@ -39,11 +43,26 @@ fn main() {
.help("Don't check the discard bitset")
.long("skip-discards")
.value_name("SKIP_DISCARDS"),
)
.arg(
Arg::with_name("QUIET")
.help("Suppress output messages, return only exit code.")
.short("q")
.long("quiet"),
);
let matches = parser.get_matches();
let input_file = Path::new(matches.value_of("INPUT").unwrap());
let report;
if matches.is_present("QUIET") {
report = std::sync::Arc::new(mk_quiet_report());
} else if atty::is(Stream::Stdout) {
report = std::sync::Arc::new(mk_progress_bar_report());
} else {
report = Arc::new(mk_simple_report());
}
let opts = CacheCheckOptions {
dev: &input_file,
async_io: false,
@@ -51,6 +70,7 @@ fn main() {
skip_mappings: matches.is_present("SKIP_MAPPINGS"),
skip_hints: matches.is_present("SKIP_HINTS"),
skip_discards: matches.is_present("SKIP_DISCARDS"),
report,
};
if let Err(reason) = check(opts) {