ramoops: Check files in pstore
The code was wrong that it passes the pstore dir and create a dump.
Actually it should get the files in pstore dir, and do not create a dump
if it's an empty dir or the dir does not exist.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Id9e2452c93c5e2897441d22d00aeec8b04aca3ee
diff --git a/ramoops_manager.cpp b/ramoops_manager.cpp
index c645d3b..7cc7bba 100644
--- a/ramoops_manager.cpp
+++ b/ramoops_manager.cpp
@@ -6,6 +6,8 @@
#include <sdbusplus/exception.hpp>
+#include <filesystem>
+
namespace phosphor
{
namespace dump
@@ -15,6 +17,14 @@
Manager::Manager(const std::string& filePath)
{
+ namespace fs = std::filesystem;
+
+ fs::path dir(filePath);
+ if (!fs::exists(dir) || fs::is_empty(dir))
+ {
+ return;
+ }
+
std::vector<std::string> files;
files.push_back(filePath);
@@ -23,11 +33,6 @@
void Manager::createHelper(const std::vector<std::string>& files)
{
- if (files.empty())
- {
- return;
- }
-
constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";