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