blob: af330a81bbae3255b938d23ac3d74683e7536c27 [file] [log] [blame]
Lei YUf3ce4332019-02-21 14:09:49 +08001#pragma once
2
3#include "item_updater.hpp"
4
5namespace openpower
6{
7namespace software
8{
9namespace updater
10{
11
12/** @class ItemUpdaterUbi
13 * @brief Manages the activation of the host version items for ubi layout
14 */
15class ItemUpdaterUbi : public ItemUpdater
16{
17 public:
18 ItemUpdaterUbi(sdbusplus::bus::bus& bus, const std::string& path) :
19 ItemUpdater(bus, path)
20 {
21 processPNORImage();
22 gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
23 volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
24
25 // Emit deferred signal.
26 emit_object_added();
27 }
28 virtual ~ItemUpdaterUbi() = default;
29
30 void freePriority(uint8_t value, const std::string& versionId) override;
31
32 bool isLowestPriority(uint8_t value) override;
33
34 void processPNORImage() override;
35
36 bool erase(std::string entryId) override;
37
38 void deleteAll() override;
39
40 void freeSpace() override;
41
42 bool isVersionFunctional(const std::string& versionId) override;
43
44 private:
45 /** @brief Callback function for Software.Version match.
46 * @details Creates an Activation D-Bus object.
47 *
48 * @param[in] msg - Data associated with subscribed signal
49 */
50 void createActivation(sdbusplus::message::message& msg) override;
51
52 /** @brief Host factory reset - clears PNOR partitions for each
53 * Activation D-Bus object */
54 void reset() override;
55
56 /**
57 * @brief Validates the presence of SquashFS image in the image dir.
58 *
59 * @param[in] filePath - The path to the SquashFS image.
60 * @param[out] result - 0 --> if validation was successful
61 * - -1--> Otherwise
62 */
63 static int validateSquashFSImage(const std::string& filePath);
64
65 /** @brief Clears read only PNOR partition for
66 * given Activation D-Bus object
67 *
68 * @param[in] versionId - The id of the ro partition to remove.
69 */
70 void removeReadOnlyPartition(std::string versionId);
71
72 /** @brief Clears read write PNOR partition for
73 * given Activation D-Bus object
74 *
75 * @param[in] versionId - The id of the rw partition to remove.
76 */
77 void removeReadWritePartition(std::string versionId);
78
79 /** @brief Clears preserved PNOR partition */
80 void removePreservedPartition();
81};
82
83} // namespace updater
84} // namespace software
85} // namespace openpower