blob: 1792ad47bfbfb4050a56c6a69a3d0ea035988a39 (
plain)
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
|
#include "config.h"
#ifdef UBIFS_LAYOUT
#include "ubi/item_updater_ubi.hpp"
#include "ubi/watch.hpp"
#else
#include "static/item_updater_static.hpp"
#endif
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
#include <system_error>
int main(int argc, char* argv[])
{
using namespace openpower::software::updater;
using namespace phosphor::logging;
auto bus = sdbusplus::bus::new_default();
sd_event* loop = nullptr;
auto rc = sd_event_default(&loop);
if (rc < 0)
{
log<level::ERR>("Error occurred during the sd_event_default",
entry("RC=%d", rc));
return -1;
}
// Add sdbusplus ObjectManager.
sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
#ifdef UBIFS_LAYOUT
ItemUpdaterUbi updater(bus, SOFTWARE_OBJPATH);
#else
ItemUpdaterStatic updater(bus, SOFTWARE_OBJPATH);
#endif
bus.request_name(BUSNAME_UPDATER);
try
{
#ifdef UBIFS_LAYOUT
openpower::software::updater::Watch watch(
loop,
std::bind(std::mem_fn(&ItemUpdater::updateFunctionalAssociation),
&updater, std::placeholders::_1));
#endif
bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
rc = sd_event_loop(loop);
if (rc < 0)
{
log<level::ERR>("Error occurred during the sd_event_loop",
entry("RC=%d", rc));
return -1;
}
}
catch (const std::system_error& e)
{
log<level::ERR>(e.what());
return -1;
}
sd_event_unref(loop);
return 0;
}
|