diff --git a/services/ptable_parse/composite_ptable.cpp b/services/ptable_parse/composite_ptable.cpp index f76a1fa96b294a85431991f1cf90e1227d1b5ca0..9f2fd373125e86ada7266256e82b202ea8b4fbe2 100644 --- a/services/ptable_parse/composite_ptable.cpp +++ b/services/ptable_parse/composite_ptable.cpp @@ -125,4 +125,16 @@ void CompositePtable::AppendChildPtnInfo(const std::vector &ptnInfo) { partitionInfo_.insert(partitionInfo_.end(), ptnInfo.begin(), ptnInfo.end()); } + +void CompositePtable::ClearPartitionInfo() +{ + std::vector().swap(partitionInfo_); + for (const auto &iter : childs_) { + if (iter == nullptr) { + LOG(ERROR) << "invalid iter ptable"; + return; + } + iter->ClearPartitionInfo(); + } +} } diff --git a/services/ptable_parse/composite_ptable.h b/services/ptable_parse/composite_ptable.h index 3e1d420c16a9121d71a0c22a606aecc7c35c8f52..b29970dd3fc541191366a4c43902c52f833ef0ab 100644 --- a/services/ptable_parse/composite_ptable.h +++ b/services/ptable_parse/composite_ptable.h @@ -31,6 +31,7 @@ public: bool EditPartitionBuf(uint8_t *imageBuf, uint64_t imgBufSize, std::vector &modifyList) override; bool GetPtableImageBuffer(uint8_t *imageBuf, const uint32_t imgBufSize) override; void AddChildPtable(std::unique_ptr child) override; + void ClearPartitionInfo() override; private: bool CheckBuff(const uint8_t *buf, const uint64_t size) diff --git a/services/ptable_parse/ptable.cpp b/services/ptable_parse/ptable.cpp index d2a062f474927cb50386291a4877d6b293428292..53c4920f88b66a4ef87d8d45d9d345f90b37840e 100644 --- a/services/ptable_parse/ptable.cpp +++ b/services/ptable_parse/ptable.cpp @@ -88,6 +88,11 @@ std::vector& Ptable::GetPtablePartitionInfoInstance() return partitionInfo_; } +void Ptable::ClearPartitionInfo() +{ + partitionInfo_.clear(); +} + bool Ptable::InitPtable() { if (!partitionInfo_.empty()) { diff --git a/services/ptable_parse/ptable.h b/services/ptable_parse/ptable.h index f88c5e8601f4421228d62a5b3054de86bda85207..12530a4f8c8d98d012ab2c670a4523c54cdad0cf 100644 --- a/services/ptable_parse/ptable.h +++ b/services/ptable_parse/ptable.h @@ -96,6 +96,7 @@ public: virtual bool SyncABLunPtableDevice(const int sourceSlot); virtual bool GetABLunPartitionInfo(const int sourceSlot, std::string &srcNode, std::string &tgtNode, uint32_t &offset); + virtual void ClearPartitionInfo(); int GetEndPtnIndex() {