From 430965989b55b7c39b0e11576e06971153a7540c Mon Sep 17 00:00:00 2001 From: Jayanth Othayoth Date: Thu, 20 Jul 2017 02:17:37 -0500 Subject: Restore dump d-bus objects during daemon starts Use the dump files in the persistant location to rebuild the d-bus objects. Change-Id: Ia7b478649274a4681c802e11be4b2049eeed8e13 Signed-off-by: Jayanth Othayoth --- dump_manager.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'dump_manager.cpp') diff --git a/dump_manager.cpp b/dump_manager.cpp index 7e753c0..3775842 100644 --- a/dump_manager.cpp +++ b/dump_manager.cpp @@ -16,7 +16,6 @@ namespace dump using namespace sdbusplus::xyz::openbmc_project::Common::Error; using namespace phosphor::logging; -using namespace std; namespace internal { @@ -170,5 +169,35 @@ void Manager::removeWatch(const fs::path& path) childWatchMap.erase(path); } +void Manager::restore() +{ + fs::path dir(BMC_DUMP_PATH); + if (!fs::exists(dir) || fs::is_empty(dir)) + { + return; + } + + //Dump file path: // + for (const auto& p : fs::directory_iterator(dir)) + { + auto idStr = p.path().filename().string(); + + //Consider only directory's with dump id as name. + //Note: As per design one file per directory. + if ((fs::is_directory(p.path())) && + std::all_of(idStr.begin(), idStr.end(), ::isdigit)) + { + lastEntryId = std::max(lastEntryId, + static_cast(std::stoul(idStr))); + auto fileIt = fs::directory_iterator(p.path()); + //Create dump entry d-bus object. + if (fileIt != fs::end(fileIt)) + { + createEntry(fileIt->path()); + } + } + } +} + } //namespace dump } //namespace phosphor -- cgit v1.2.1