forked from ibm-openbmc/phosphor-debug-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_manager.hpp
77 lines (65 loc) · 2.01 KB
/
core_manager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include "config.h"
#include "dump_utils.hpp"
#include "watch.hpp"
#include <map>
namespace phosphor
{
namespace dump
{
namespace core
{
using Watch = phosphor::dump::inotify::Watch;
using UserMap = phosphor::dump::inotify::UserMap;
/** workaround: Watches for IN_CLOSE_WRITE event for the
* jffs filesystem based systemd-coredump core path
* Refer openbmc/issues/#2287 for more details.
*
* JFFS_CORE_FILE_WORKAROUND will be enabled for jffs and
* for other file system it will be disabled.
*/
#ifdef JFFS_CORE_FILE_WORKAROUND
static constexpr auto coreFileEvent = IN_CLOSE_WRITE;
#else
static constexpr auto coreFileEvent = IN_CREATE;
#endif
/** @class Manager
* @brief OpenBMC Core manager implementation.
*/
class Manager
{
public:
Manager() = delete;
Manager(const Manager&) = default;
Manager& operator=(const Manager&) = delete;
Manager(Manager&&) = delete;
Manager& operator=(Manager&&) = delete;
virtual ~Manager() = default;
/** @brief Constructor to create core watch object.
* @param[in] event - Dump manager sd_event loop.
*/
Manager(const EventPtr& event) :
eventLoop(event.get()),
coreWatch(eventLoop, IN_NONBLOCK, coreFileEvent, EPOLLIN, CORE_FILE_DIR,
std::bind(std::mem_fn(
&phosphor::dump::core::Manager::watchCallback),
this, std::placeholders::_1))
{}
private:
/** @brief Helper function for initiating dump request using
* D-bus internal create interface.
* @param [in] files - Core files list
*/
void createHelper(const std::vector<std::string>& files);
/** @brief Implementation of core watch call back
* @param [in] fileInfo - map of file info path:event
*/
void watchCallback(const UserMap& fileInfo);
/** @brief sdbusplus Dump event loop */
EventPtr eventLoop;
/** @brief Core watch object */
Watch coreWatch;
};
} // namespace core
} // namespace dump
} // namespace phosphor