faultlog: Initial framework for Fault Log
Fault Log is a new type of dump. For details please see
https://github.com/openbmc/docs/blob/master/designs/hw-fault-monitor.md
This commit enables creation and deletion of fault log entries.
Tested: Created and deleted fault log entries by calling the
corresponding D-Bus methods via bmcweb (added extra code in bmcweb for
testing this). Also forced a fault log directory creation error by
changing the code to specify a nonexistent directory path "/abc/def/"
instead of FAULTLOG_DUMP_PATH, and forced a fault log file open error
by creating a directory (manually using mkdir) with the same name as
the file that the fault log manager tried to open.
Signed-off-by: Claire Weinan <cweinan@google.com>
Change-Id: I03d4c19a4c131f7224ac895e404c46b1f566617b
diff --git a/faultlog_dump_entry.cpp b/faultlog_dump_entry.cpp
new file mode 100644
index 0000000..897d98b
--- /dev/null
+++ b/faultlog_dump_entry.cpp
@@ -0,0 +1,38 @@
+#include "faultlog_dump_entry.hpp"
+
+#include <fmt/core.h>
+
+#include <phosphor-logging/log.hpp>
+
+namespace phosphor
+{
+namespace dump
+{
+namespace faultlog
+{
+using namespace phosphor::logging;
+
+void Entry::delete_()
+{
+ log<level::INFO>("In faultlog_dump_entry.cpp delete_()");
+
+ // Delete Dump file from Permanent location
+ try
+ {
+ std::filesystem::remove(file);
+ }
+ catch (const std::filesystem::filesystem_error& e)
+ {
+ // Log Error message and continue
+ log<level::ERR>(
+ fmt::format("Failed to delete dump file, errormsg({})", e.what())
+ .c_str());
+ }
+
+ // Remove Dump entry D-bus object
+ phosphor::dump::Entry::delete_();
+}
+
+} // namespace faultlog
+} // namespace dump
+} // namespace phosphor