Skip to content

Commit

Permalink
feat(forward-compat): add support for metadata feature set (gh #158)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Dec 5, 2023
1 parent 829c7b1 commit 576e15c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/dwarfs/metadata_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ map_frozen(std::span<uint8_t const> schema, std::span<uint8_t const> data) {
return ret;
}

MappedFrozen<thrift::metadata::metadata>
check_frozen(MappedFrozen<thrift::metadata::metadata> meta) {
if (meta.features()) {
auto unsupported = meta.features()->thaw();
if (!unsupported.empty()) {
DWARFS_THROW(runtime_error,
fmt::format("file system uses the following features "
"unsupported by this build: {}",
boost::join(unsupported, ", ")));
}
}
return meta;
}

void analyze_frozen(std::ostream& os,
MappedFrozen<thrift::metadata::metadata> const& meta,
size_t total_size, int detail) {
Expand Down Expand Up @@ -302,7 +316,8 @@ class metadata_ final : public metadata_v2::impl {
std::span<uint8_t const> data, metadata_options const& options,
int inode_offset, bool force_consistency_check)
: data_(data)
, meta_(map_frozen<thrift::metadata::metadata>(schema, data_))
, meta_(
check_frozen(map_frozen<thrift::metadata::metadata>(schema, data_)))
, global_(lgr, &meta_,
options.check_consistency || force_consistency_check)
, root_(dir_entry_view::from_dir_entry_index(0, &global_))
Expand Down
15 changes: 14 additions & 1 deletion thrift/metadata.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,19 @@ struct metadata {

25: optional string_table compact_symlinks,

//=========================================================//
// fields added with dwarfs-0.7.0, file system version 2.5 //
//=========================================================//

// preferred path separator of original file system
26: optional UInt32 preferred_path_separator,
26: optional UInt32 preferred_path_separator

//=========================================================//
// fields added with dwarfs-0.7.3, file system version 2.5 //
//=========================================================//

// The set of features used in this file system image. As long
// as an older binary supports all features, it will be able
// to use images created with newer versions.
27: optional set<string> features,
}

0 comments on commit 576e15c

Please sign in to comment.