mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
Improve dwarfsck output
This commit is contained in:
parent
f3c0f96059
commit
88d684379e
@ -537,7 +537,7 @@ int filesystem_v2::identify(logger& lgr, std::shared_ptr<mmif> mm,
|
|||||||
|
|
||||||
if (errors == 0 and detail_level > 0) {
|
if (errors == 0 and detail_level > 0) {
|
||||||
filesystem_options fsopts;
|
filesystem_options fsopts;
|
||||||
if (detail_level > 1) {
|
if (detail_level > 0) {
|
||||||
fsopts.metadata.enable_nlink = true;
|
fsopts.metadata.enable_nlink = true;
|
||||||
}
|
}
|
||||||
filesystem_v2(lgr, mm, fsopts).dump(os, detail_level);
|
filesystem_v2(lgr, mm, fsopts).dump(os, detail_level);
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <thrift/lib/cpp2/protocol/Serializer.h>
|
#include <thrift/lib/cpp2/protocol/Serializer.h>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/locale.h>
|
||||||
|
|
||||||
#include <folly/container/F14Set.h>
|
#include <folly/container/F14Set.h>
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ void analyze_frozen(std::ostream& os,
|
|||||||
MappedFrozen<thrift::metadata::metadata> const& meta,
|
MappedFrozen<thrift::metadata::metadata> const& meta,
|
||||||
size_t total_size, int detail) {
|
size_t total_size, int detail) {
|
||||||
using namespace ::apache::thrift::frozen;
|
using namespace ::apache::thrift::frozen;
|
||||||
|
std::locale loc("");
|
||||||
|
|
||||||
auto layout = meta.findFirstOfType<
|
auto layout = meta.findFirstOfType<
|
||||||
std::unique_ptr<Layout<thrift::metadata::metadata>>>();
|
std::unique_ptr<Layout<thrift::metadata::metadata>>>();
|
||||||
@ -111,13 +113,14 @@ void analyze_frozen(std::ostream& os,
|
|||||||
|
|
||||||
auto fmt_size = [&](auto const& name, size_t count, size_t size) {
|
auto fmt_size = [&](auto const& name, size_t count, size_t size) {
|
||||||
return fmt::format(
|
return fmt::format(
|
||||||
"{0:>10} {1:.<20}{2:.>13L} bytes {3:5.1f}% {4:5.1f} bytes/item\n",
|
loc, "{0:>14L} {1:.<20}{2:.>16L} bytes {3:5.1f}% {4:5.1f} bytes/item\n",
|
||||||
count, name, size, 100.0 * size / total_size,
|
count, name, size, 100.0 * size / total_size,
|
||||||
count > 0 ? static_cast<double>(size) / count : 0.0);
|
count > 0 ? static_cast<double>(size) / count : 0.0);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto fmt_detail = [&](auto const& name, size_t count, size_t size) {
|
auto fmt_detail = [&](auto const& name, size_t count, size_t size) {
|
||||||
return fmt::format(" {0:<20}{1:>13L} bytes {2:5.1f}% "
|
return fmt::format(loc,
|
||||||
|
" {0:<20}{1:>16L} bytes {2:5.1f}% "
|
||||||
"{3:5.1f} bytes/item\n",
|
"{3:5.1f} bytes/item\n",
|
||||||
name, size, 100.0 * size / total_size,
|
name, size, 100.0 * size / total_size,
|
||||||
count > 0 ? static_cast<double>(size) / count : 0.0);
|
count > 0 ? static_cast<double>(size) / count : 0.0);
|
||||||
@ -216,7 +219,8 @@ void analyze_frozen(std::ostream& os,
|
|||||||
|
|
||||||
os << "metadata memory usage:\n";
|
os << "metadata memory usage:\n";
|
||||||
os << fmt::format(
|
os << fmt::format(
|
||||||
" {0:.<20}{1:.>13L} bytes {2:6.1f} bytes/inode\n",
|
loc,
|
||||||
|
" {0:.<20}{1:.>16L} bytes {2:6.1f} bytes/inode\n",
|
||||||
"total metadata", total_size,
|
"total metadata", total_size,
|
||||||
static_cast<double>(total_size) / meta.inodes().size());
|
static_cast<double>(total_size) / meta.inodes().size());
|
||||||
|
|
||||||
@ -748,9 +752,10 @@ void metadata_<LoggerPolicy>::dump(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (detail_level > 0) {
|
if (detail_level > 0) {
|
||||||
os << "block size: " << stbuf.f_bsize << std::endl;
|
os << "block size: " << size_with_unit(stbuf.f_bsize) << std::endl;
|
||||||
os << "inode count: " << stbuf.f_files << std::endl;
|
os << "inode count: " << stbuf.f_files << std::endl;
|
||||||
os << "original filesystem size: " << stbuf.f_blocks << std::endl;
|
os << "original filesystem size: " << size_with_unit(stbuf.f_blocks)
|
||||||
|
<< std::endl;
|
||||||
if (auto opt = meta_.options()) {
|
if (auto opt = meta_.options()) {
|
||||||
std::vector<std::string> options;
|
std::vector<std::string> options;
|
||||||
auto boolopt = [&](auto const& name, bool value) {
|
auto boolopt = [&](auto const& name, bool value) {
|
||||||
|
@ -56,7 +56,7 @@ int dwarfsck(int argc, char** argv) {
|
|||||||
po::value<std::string>(&input),
|
po::value<std::string>(&input),
|
||||||
"input filesystem")
|
"input filesystem")
|
||||||
("detail,d",
|
("detail,d",
|
||||||
po::value<int>(&detail)->default_value(1),
|
po::value<int>(&detail)->default_value(2),
|
||||||
"detail level")
|
"detail level")
|
||||||
("num-workers,n",
|
("num-workers,n",
|
||||||
po::value<size_t>(&num_workers)->default_value(num_cpu),
|
po::value<size_t>(&num_workers)->default_value(num_cpu),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user