Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 3 | #include "config.h" |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 4 | |
| 5 | #include "dump_utils.hpp" |
| 6 | #include "watch.hpp" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 7 | |
| 8 | #include <map> |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace dump |
| 13 | { |
| 14 | namespace core |
| 15 | { |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 16 | using Watch = phosphor::dump::inotify::Watch; |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 17 | using UserMap = phosphor::dump::inotify::UserMap; |
| 18 | |
Jayanth Othayoth | 7f2f802 | 2017-09-22 11:22:25 -0500 | [diff] [blame] | 19 | /** workaround: Watches for IN_CREATE event for the |
| 20 | * ubi filesystem based systemd-coredump core path |
| 21 | * Refer openbmc/issues/#2287 for more details. |
| 22 | */ |
| 23 | #ifdef UBI_CORE_FILE_WORKAROUND |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 24 | static constexpr auto coreFileEvent = IN_CREATE; |
Jayanth Othayoth | 7f2f802 | 2017-09-22 11:22:25 -0500 | [diff] [blame] | 25 | #else |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 26 | static constexpr auto coreFileEvent = IN_CLOSE_WRITE; |
Jayanth Othayoth | 7f2f802 | 2017-09-22 11:22:25 -0500 | [diff] [blame] | 27 | #endif |
| 28 | |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 29 | /** @class Manager |
| 30 | * @brief OpenBMC Core manager implementation. |
Jayanth Othayoth | d3273ea | 2017-07-12 22:55:32 -0500 | [diff] [blame] | 31 | */ |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 32 | class Manager |
| 33 | { |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 34 | public: |
| 35 | Manager() = delete; |
| 36 | Manager(const Manager&) = default; |
| 37 | Manager& operator=(const Manager&) = delete; |
| 38 | Manager(Manager&&) = delete; |
| 39 | Manager& operator=(Manager&&) = delete; |
| 40 | virtual ~Manager() = default; |
Jayanth Othayoth | d3273ea | 2017-07-12 22:55:32 -0500 | [diff] [blame] | 41 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 42 | /** @brief Constructor to create core watch object. |
| 43 | * @param[in] event - Dump manager sd_event loop. |
| 44 | */ |
| 45 | Manager(const EventPtr& event) : |
| 46 | eventLoop(event.get()), |
| 47 | coreWatch(eventLoop, IN_NONBLOCK, coreFileEvent, EPOLLIN, CORE_FILE_DIR, |
| 48 | std::bind(std::mem_fn( |
| 49 | &phosphor::dump::core::Manager::watchCallback), |
| 50 | this, std::placeholders::_1)) |
| 51 | { |
| 52 | } |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 53 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 54 | private: |
| 55 | /** @brief Helper function for initiating dump request using |
| 56 | * D-bus internal create interface. |
| 57 | * @param [in] files - Core files list |
| 58 | */ |
| 59 | void createHelper(const std::vector<std::string>& files); |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 60 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 61 | /** @brief Implementation of core watch call back |
| 62 | * @param [in] fileInfo - map of file info path:event |
| 63 | */ |
| 64 | void watchCallback(const UserMap& fileInfo); |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 65 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 66 | /** @brief sdbusplus Dump event loop */ |
| 67 | EventPtr eventLoop; |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 68 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 69 | /** @brief Core watch object */ |
| 70 | Watch coreWatch; |
Jayanth Othayoth | bf6ec60 | 2017-08-28 01:48:49 -0500 | [diff] [blame] | 71 | }; |
| 72 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 73 | } // namespace core |
Jayanth Othayoth | d02153c | 2017-07-02 22:29:42 -0500 | [diff] [blame] | 74 | } // namespace dump |
| 75 | } // namespace phosphor |