mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
Add some additional consistency checks
This commit is contained in:
parent
c59eea1517
commit
1326868143
@ -115,6 +115,43 @@ class metadata_ : public metadata_v2::impl {
|
|||||||
log_.debug() << "link index offset: " << link_index_offset_;
|
log_.debug() << "link index offset: " << link_index_offset_;
|
||||||
log_.debug() << "chunk index offset: " << chunk_index_offset_;
|
log_.debug() << "chunk index offset: " << chunk_index_offset_;
|
||||||
log_.debug() << "device index offset: " << dev_index_offset_;
|
log_.debug() << "device index offset: " << dev_index_offset_;
|
||||||
|
|
||||||
|
if (int(meta_.directories().size() - 1) != link_index_offset_) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
fmt::format("metadata inconsistency: number of directories ({}) does "
|
||||||
|
"not match link index ({})",
|
||||||
|
meta_.directories().size() - 1, link_index_offset_));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (int(meta_.link_index().size()) !=
|
||||||
|
(chunk_index_offset_ - link_index_offset_)) {
|
||||||
|
throw std::runtime_error(fmt::format(
|
||||||
|
"metadata inconsistency: number of links ({}) does not match "
|
||||||
|
"chunk/link index delta ({} - {} = {})",
|
||||||
|
meta_.link_index().size(), chunk_index_offset_, link_index_offset_,
|
||||||
|
chunk_index_offset_ - link_index_offset_));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (int(meta_.chunk_index().size() - 1) !=
|
||||||
|
(dev_index_offset_ - chunk_index_offset_)) {
|
||||||
|
throw std::runtime_error(fmt::format(
|
||||||
|
"metadata inconsistency: number of files ({}) does not match "
|
||||||
|
"device/chunk index delta ({} - {} = {})",
|
||||||
|
meta_.chunk_index().size() - 1, dev_index_offset_,
|
||||||
|
chunk_index_offset_, dev_index_offset_ - chunk_index_offset_));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto devs = meta_.devices()) {
|
||||||
|
auto other_offset = find_index_offset(inode_rank::INO_OTH);
|
||||||
|
|
||||||
|
if (devs->size() != (other_offset - dev_index_offset_)) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
fmt::format("metadata inconsistency: number of devices ({}) does "
|
||||||
|
"not match other/device index delta ({} - {} = {})",
|
||||||
|
devs->size(), other_offset, dev_index_offset_,
|
||||||
|
other_offset - dev_index_offset_));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump(std::ostream& os, int detail_level,
|
void dump(std::ostream& os, int detail_level,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user