diff options
author | Jayanth Othayoth <ojayanth@in.ibm.com> | 2017-07-20 02:17:37 -0500 |
---|---|---|
committer | Jayanth Othayoth <ojayanth@in.ibm.com> | 2017-07-27 21:35:36 -0500 |
commit | 430965989b55b7c39b0e11576e06971153a7540c (patch) | |
tree | c0cea5c7be956b43e35332595ea65485d4727ec3 /dump_manager.cpp | |
parent | 580cb2d4767ebd68c7cc90689dd7f818800dc046 (diff) | |
download | phosphor-debug-collector-430965989b55b7c39b0e11576e06971153a7540c.tar.gz phosphor-debug-collector-430965989b55b7c39b0e11576e06971153a7540c.zip |
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 <ojayanth@in.ibm.com>
Diffstat (limited to 'dump_manager.cpp')
-rw-r--r-- | dump_manager.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
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: <BMC_DUMP_PATH>/<id>/<filename> + 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<uint32_t>(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 |