diff options
| author | Adriana Kobylak <anoo@us.ibm.com> | 2018-04-24 11:37:21 -0500 |
|---|---|---|
| committer | Adriana Kobylak <anoo@us.ibm.com> | 2018-05-08 11:51:36 -0500 |
| commit | b072d1bec4f8c5ee2de13722a4af63ba4350d7c7 (patch) | |
| tree | 86d93a28745daacd5518c1888e82f9879cfcdf96 /sync_manager_main.cpp | |
| parent | 7e8d76b3de932520789a8fb2920cd4b6fde9d388 (diff) | |
| download | phosphor-bmc-code-mgmt-b072d1bec4f8c5ee2de13722a4af63ba4350d7c7.tar.gz phosphor-bmc-code-mgmt-b072d1bec4f8c5ee2de13722a4af63ba4350d7c7.zip | |
sync_manager: Create sync watch class
Create a watch class to monitor the files and directories
specified in the synclist file.
Store the file descriptors and file names in a map to be
able to know the full path of the file that triggered the
event. The watch descriptor number does not change so it
can be a single variable.
Change-Id: I211225ddc012af85d9be39ae5d40b8258d73435d
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'sync_manager_main.cpp')
| -rw-r--r-- | sync_manager_main.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sync_manager_main.cpp b/sync_manager_main.cpp index 09aea5c..46a2d95 100644 --- a/sync_manager_main.cpp +++ b/sync_manager_main.cpp @@ -1,15 +1,41 @@ +#include <exception> +#include <phosphor-logging/log.hpp> #include <sdbusplus/bus.hpp> #include <sdbusplus/server/manager.hpp> +#include <systemd/sd-event.h> #include "config.h" #include "sync_manager.hpp" +#include "sync_watch.hpp" int main(int argc, char* argv[]) { auto bus = sdbusplus::bus::new_default(); + sd_event* loop = nullptr; + sd_event_default(&loop); + sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH); - phosphor::software::manager::Sync syncManager(); - bus.request_name(SYNC_BUSNAME); + + try + { + phosphor::software::manager::Sync syncManager; + bus.request_name(SYNC_BUSNAME); + + using namespace phosphor::software::manager; + phosphor::software::manager::SyncWatch watch( + *loop, std::bind(std::mem_fn(&Sync::processEntry), &syncManager)); + bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); + sd_event_loop(loop); + } + catch (std::exception& e) + { + using namespace phosphor::logging; + log<level::ERR>(e.what()); + sd_event_unref(loop); + return -1; + } + + sd_event_unref(loop); return 0; } |

