1 #pragma once 2 3 #include "config.h" 4 5 #include "dump_utils.hpp" 6 #include "watch.hpp" 7 8 #include <map> 9 10 namespace phosphor 11 { 12 namespace dump 13 { 14 namespace core 15 { 16 using Watch = phosphor::dump::inotify::Watch; 17 using UserMap = phosphor::dump::inotify::UserMap; 18 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 24 static constexpr auto coreFileEvent = IN_CREATE; 25 #else 26 static constexpr auto coreFileEvent = IN_CLOSE_WRITE; 27 #endif 28 29 /** @class Manager 30 * @brief OpenBMC Core manager implementation. 31 */ 32 class Manager 33 { 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; 41 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 } 53 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); 60 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); 65 66 /** @brief sdbusplus Dump event loop */ 67 EventPtr eventLoop; 68 69 /** @brief Core watch object */ 70 Watch coreWatch; 71 }; 72 73 } // namespace core 74 } // namespace dump 75 } // namespace phosphor 76