mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-03 17:56:12 -04:00
feat(dwarfck): add schema_raw_dump
to --detail
This commit is contained in:
parent
5b095bbf69
commit
293ed10eff
@ -19,8 +19,9 @@ with a non-zero exit code.
|
||||
|
||||
- `-d`, `--detail=`*value*:
|
||||
Level of filesystem information detail. This can be a numeric level
|
||||
between 0 and 6, or a comma-separated list of feature names. The
|
||||
default corresponds to a level of 2.
|
||||
between 0 and 7, or a comma-separated list of feature names. The
|
||||
default corresponds to a level of 2. The feature names are shown
|
||||
in the command help.
|
||||
|
||||
- `-q`, `--quiet`:
|
||||
Don't produce any output unless there is an error.
|
||||
|
@ -47,6 +47,7 @@ enum class fsinfo_feature {
|
||||
metadata_full_dump,
|
||||
frozen_analysis,
|
||||
frozen_layout,
|
||||
schema_raw_dump,
|
||||
directory_tree,
|
||||
section_details,
|
||||
chunk_details,
|
||||
|
@ -55,6 +55,7 @@ constexpr std::array level_features{
|
||||
{fsinfo_feature::directory_tree, fsinfo_feature::frozen_layout}),
|
||||
/* 5 */ fsinfo_features({fsinfo_feature::chunk_details}),
|
||||
/* 6 */ fsinfo_features({fsinfo_feature::metadata_full_dump}),
|
||||
/* 7 */ fsinfo_features({fsinfo_feature::schema_raw_dump}),
|
||||
};
|
||||
|
||||
constexpr std::array<std::pair<fsinfo_feature, std::string_view>,
|
||||
@ -68,6 +69,7 @@ constexpr std::array<std::pair<fsinfo_feature, std::string_view>,
|
||||
FSINFO_FEATURE_PAIR_(metadata_full_dump),
|
||||
FSINFO_FEATURE_PAIR_(frozen_analysis),
|
||||
FSINFO_FEATURE_PAIR_(frozen_layout),
|
||||
FSINFO_FEATURE_PAIR_(schema_raw_dump),
|
||||
FSINFO_FEATURE_PAIR_(directory_tree),
|
||||
FSINFO_FEATURE_PAIR_(section_details),
|
||||
FSINFO_FEATURE_PAIR_(chunk_details),
|
||||
|
@ -91,14 +91,19 @@ namespace {
|
||||
|
||||
using ::apache::thrift::frozen::MappedFrozen;
|
||||
|
||||
void check_schema(std::span<uint8_t const> data) {
|
||||
using namespace ::apache::thrift;
|
||||
frozen::schema::Schema schema;
|
||||
size_t schemaSize = CompactSerializer::deserialize(data, schema);
|
||||
// std::cerr << debugString(schema) << '\n';
|
||||
if (schemaSize != data.size()) {
|
||||
::apache::thrift::frozen::schema::Schema
|
||||
deserialize_schema(std::span<uint8_t const> data) {
|
||||
::apache::thrift::frozen::schema::Schema schema;
|
||||
size_t schema_size =
|
||||
::apache::thrift::CompactSerializer::deserialize(data, schema);
|
||||
if (schema_size != data.size()) {
|
||||
DWARFS_THROW(runtime_error, "invalid schema size");
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
void check_schema(std::span<uint8_t const> data) {
|
||||
auto schema = deserialize_schema(data);
|
||||
if (!schema.layouts()->contains(*schema.rootLayout())) {
|
||||
DWARFS_THROW(runtime_error, "invalid rootLayout in schema");
|
||||
}
|
||||
@ -818,6 +823,7 @@ class metadata_v2_data {
|
||||
: 0);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> schema_;
|
||||
std::span<uint8_t const> data_;
|
||||
MappedFrozen<thrift::metadata::metadata> meta_;
|
||||
global_metadata const global_;
|
||||
@ -850,7 +856,8 @@ metadata_v2_data::metadata_v2_data(
|
||||
std::span<uint8_t const> data, metadata_options const& options,
|
||||
int inode_offset, bool force_consistency_check,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon [[maybe_unused]])
|
||||
: data_{data}
|
||||
: schema_{schema.begin(), schema.end()}
|
||||
, data_{data}
|
||||
, meta_{check_frozen(map_frozen<thrift::metadata::metadata>(schema, data_))}
|
||||
, global_{lgr, check_metadata_consistency(lgr, meta_,
|
||||
options.check_consistency ||
|
||||
@ -1664,6 +1671,10 @@ void metadata_v2_data::dump(
|
||||
os << '\n';
|
||||
}
|
||||
|
||||
if (opts.features.has(fsinfo_feature::schema_raw_dump)) {
|
||||
os << ::apache::thrift::debugString(deserialize_schema(schema_)) << '\n';
|
||||
}
|
||||
|
||||
if (opts.features.has(fsinfo_feature::metadata_details)) {
|
||||
os << "symlink_inode_offset: " << symlink_inode_offset_ << "\n";
|
||||
os << "file_inode_offset: " << file_inode_offset_ << "\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user