From e92ae10408ae1d432a18181629c71f68dd96cf2f Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 26 May 2020 10:59:13 +0100 Subject: [PATCH] [thin_metadata_pack/unpack] Add version field to header. --- thin-provisioning/thin_metadata_pack.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/thin-provisioning/thin_metadata_pack.cc b/thin-provisioning/thin_metadata_pack.cc index 9ac5097..f933cf3 100644 --- a/thin-provisioning/thin_metadata_pack.cc +++ b/thin-provisioning/thin_metadata_pack.cc @@ -41,6 +41,7 @@ using boost::optional; namespace { using namespace std; constexpr uint64_t MAGIC = 0xa537a0aa6309ef77; + constexpr uint64_t PACK_VERSION = 1; uint32_t const SUPERBLOCK_CSUM_SEED = 160774; uint32_t const BITMAP_CSUM_XOR = 240779; @@ -114,6 +115,7 @@ namespace { std::ofstream out_file(*f.output_file_, ios_base::binary); write_u64(out_file, MAGIC); + write_u64(out_file, PACK_VERSION); boost::iostreams::filtering_ostreambuf out_buf; out_buf.push(zlib_compressor()); @@ -154,6 +156,9 @@ namespace { if (read_u64(in_file) != MAGIC) throw runtime_error("Not a pack file."); + if (read_u64(in_file) != PACK_VERSION) + throw runtime_error("unknown pack file format version"); + filtering_istreambuf in_buf; in_buf.push(zlib_decompressor()); in_buf.push(in_file);