From 797b02059faa6dc4eeb80f340269b99af8b22f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=82=AC?= Date: Tue, 15 Jul 2025 15:08:19 +0800 Subject: [PATCH] ptable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄悬 --- services/ptable_parse/composite_ptable.cpp | 12 ++++++++++++ services/ptable_parse/composite_ptable.h | 1 + services/ptable_parse/ptable.cpp | 5 +++++ services/ptable_parse/ptable.h | 1 + 4 files changed, 19 insertions(+) diff --git a/services/ptable_parse/composite_ptable.cpp b/services/ptable_parse/composite_ptable.cpp index f76a1fa9..9f2fd373 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 3e1d420c..b29970dd 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 d2a062f4..53c4920f 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 f88c5e86..12530a4f 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() { -- Gitee