2020-08-05 13:39:18 +05:30
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
mod common;
|
2021-07-01 19:57:37 +05:30
|
|
|
|
|
|
|
use common::common_args::*;
|
|
|
|
use common::input_arg::*;
|
|
|
|
use common::output_option::*;
|
2021-07-20 15:07:55 +05:30
|
|
|
use common::program::*;
|
|
|
|
use common::target::*;
|
2021-07-06 07:21:27 +05:30
|
|
|
use common::test_dir::*;
|
2021-07-20 15:07:55 +05:30
|
|
|
use common::thin::*;
|
2020-08-05 13:39:18 +05:30
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
const USAGE: &str = concat!(
|
|
|
|
"thin_metadata_pack ",
|
|
|
|
include_str!("../VERSION"),
|
|
|
|
"Produces a compressed file of thin metadata. Only packs metadata blocks that are actually used.\n\
|
|
|
|
\n\
|
|
|
|
USAGE:\n \
|
|
|
|
thin_metadata_pack -i <DEV> -o <FILE>\n\
|
|
|
|
\n\
|
|
|
|
FLAGS:\n \
|
|
|
|
-h, --help Prints help information\n \
|
|
|
|
-V, --version Prints version information\n\
|
|
|
|
\n\
|
|
|
|
OPTIONS:\n \
|
|
|
|
-i <DEV> Specify thinp metadata binary device/file\n \
|
|
|
|
-o <FILE> Specify packed output file"
|
|
|
|
);
|
2020-08-05 13:39:18 +05:30
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
//------------------------------------------
|
2020-08-05 13:39:18 +05:30
|
|
|
|
2021-07-06 07:21:27 +05:30
|
|
|
struct ThinMetadataPack;
|
2020-08-05 13:39:18 +05:30
|
|
|
|
2021-07-06 07:21:27 +05:30
|
|
|
impl<'a> Program<'a> for ThinMetadataPack {
|
|
|
|
fn name() -> &'a str {
|
|
|
|
"thin_metadata_pack"
|
|
|
|
}
|
|
|
|
|
2021-07-20 12:37:12 +05:30
|
|
|
fn path() -> &'a std::ffi::OsStr {
|
|
|
|
THIN_METADATA_PACK.as_ref()
|
2021-07-06 07:21:27 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
fn usage() -> &'a str {
|
|
|
|
USAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
fn arg_type() -> ArgType {
|
|
|
|
ArgType::IoOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_option_hint(option: &str) -> String {
|
|
|
|
rust_msg::bad_option_hint(option)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> InputProgram<'a> for ThinMetadataPack {
|
|
|
|
fn mk_valid_input(td: &mut TestDir) -> Result<std::path::PathBuf> {
|
|
|
|
mk_valid_md(td)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn file_not_found() -> &'a str {
|
|
|
|
rust_msg::FILE_NOT_FOUND
|
|
|
|
}
|
|
|
|
|
|
|
|
fn missing_input_arg() -> &'a str {
|
|
|
|
rust_msg::MISSING_INPUT_ARG
|
|
|
|
}
|
|
|
|
|
|
|
|
fn corrupted_input() -> &'a str {
|
|
|
|
rust_msg::BAD_SUPERBLOCK
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> OutputProgram<'a> for ThinMetadataPack {
|
|
|
|
fn file_not_found() -> &'a str {
|
|
|
|
rust_msg::FILE_NOT_FOUND
|
|
|
|
}
|
|
|
|
|
|
|
|
fn missing_output_arg() -> &'a str {
|
|
|
|
rust_msg::MISSING_OUTPUT_ARG
|
|
|
|
}
|
|
|
|
}
|
2020-08-05 13:39:18 +05:30
|
|
|
|
|
|
|
//------------------------------------------
|
2021-07-06 07:21:27 +05:30
|
|
|
|
|
|
|
test_accepts_help!(ThinMetadataPack);
|
|
|
|
test_accepts_version!(ThinMetadataPack);
|
|
|
|
test_rejects_bad_option!(ThinMetadataPack);
|
|
|
|
|
|
|
|
test_missing_input_option!(ThinMetadataPack);
|
|
|
|
test_missing_output_option!(ThinMetadataPack);
|
|
|
|
test_input_file_not_found!(ThinMetadataPack);
|
|
|
|
|
|
|
|
//-----------------------------------------
|