[thin-check] print out some info fields.

These are consumed by lvm.
This commit is contained in:
Joe Thornber 2018-11-09 12:43:21 +00:00
parent 5a309dd3bd
commit d1a41d01cc
2 changed files with 17 additions and 0 deletions

View File

@ -126,6 +126,13 @@
(run-fail-rcv (_ stderr) (thin-check xml)
(assert-matches ".*This looks like XML. thin_check only checks the binary metadata format." stderr))))
(define-scenario (thin-check info-fields)
"Outputs info fields"
(with-valid-metadata (md)
(run-ok-rcv (stdout stderr) (thin-check md)
(assert-matches ".*TRANSACTION_ID=[0-9]+.*" stdout)
(assert-matches ".*METADATA_FREE_BLOCKS=[0-9]+.*" stdout))))
;;;-----------------------------------------------------------
;;; thin_restore scenarios
;;;-----------------------------------------------------------

View File

@ -195,6 +195,13 @@ namespace {
return fs.override_mapping_root ? *fs.override_mapping_root : sb.data_mapping_root_;
}
void print_info(superblock_detail::superblock const &sb,
transaction_manager::ptr tm)
{
cout << "TRANSACTION_ID=" << sb.trans_id_ << "\n";
cout << "METADATA_FREE_BLOCKS=" << tm->get_sm()->get_nr_free() << "\n";
}
error_state metadata_check(string const &path, flags fs) {
nested_output out(cerr, 2);
if (fs.quiet)
@ -228,6 +235,9 @@ namespace {
transaction_manager::ptr tm =
open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION);
if (!fs.quiet)
print_info(sb, tm);
if (fs.check_device_tree) {
out << "examining devices tree" << end_message();
{