blob: 6f7383f8ad0bd443736eee0164d0505824d305ba [file] [log] [blame]
Jayanth Othayothd02153c2017-07-02 22:29:42 -05001#include <sdbusplus/bus.hpp>
2#include <phosphor-logging/elog-errors.hpp>
3
4#include "xyz/openbmc_project/Common/error.hpp"
5#include "config.h"
6#include "core_manager.hpp"
7#include "watch.hpp"
8
9int main(int argc, char* argv[])
10{
11 using namespace phosphor::logging;
12 using InternalFailure =
13 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
14
15 auto bus = sdbusplus::bus::new_default();
16 sd_event* event = nullptr;
17 auto rc = sd_event_default(&event);
18 if (rc < 0)
19 {
20 log<level::ERR>("Error occurred during the sd_event_default",
21 entry("rc=%d", rc));
22 report<InternalFailure>();
23 return -1;
24 }
25 phosphor::dump::EventPtr eventP{event};
26 event = nullptr;
27
28 try
29 {
30 phosphor::dump::inotify::Watch watch(
31 eventP,
32 IN_NONBLOCK,
33 IN_CLOSE_WRITE,
34 EPOLLIN,
35 CORE_FILE_DIR,
36 std::bind(
37 &phosphor::dump::core::manager::watchCallback,
38 std::placeholders::_1));
39
40 auto rc = sd_event_loop(eventP.get());
41 if (rc < 0)
42 {
43 log<level::ERR>("Error occurred during the sd_event_loop",
44 entry("rc=%d", rc));
45 elog<InternalFailure>();
46 }
47 }
48
49 catch (InternalFailure& e)
50 {
51 commit<InternalFailure>();
52 return -1;
53 }
54
55 return 0;
56}