summaryrefslogtreecommitdiffstats
path: root/ubi/item_updater_ubi.hpp
blob: ce1b5b87d0f582fee9c8eafab7ead9045d03f8fe (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once

#include "item_updater.hpp"

namespace openpower
{
namespace software
{
namespace updater
{

/** @class ItemUpdaterUbi
 *  @brief Manages the activation of the host version items for ubi layout
 */
class ItemUpdaterUbi : public ItemUpdater
{
  public:
    ItemUpdaterUbi(sdbusplus::bus::bus& bus, const std::string& path) :
        ItemUpdater(bus, path)
    {
        processPNORImage();
        gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
        volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);

        // Emit deferred signal.
        emit_object_added();
    }
    virtual ~ItemUpdaterUbi() = default;

    void freePriority(uint8_t value, const std::string& versionId) override;

    void processPNORImage() override;

    bool erase(std::string entryId) override;

    void deleteAll() override;

    bool freeSpace() override;

    bool isVersionFunctional(const std::string& versionId) override;

    /** @brief Determine the software version id
     *         from the symlink target (e.g. /media/ro-2a1022fe).
     *
     * @param[in] symlinkPath - The path of the symlink.
     * @param[out] id - The version id as a string.
     */
    static std::string determineId(const std::string& symlinkPath);

  private:
    std::unique_ptr<Activation> createActivationObject(
        const std::string& path, const std::string& versionId,
        const std::string& extVersion,
        sdbusplus::xyz::openbmc_project::Software::server::Activation::
            Activations activationStatus,
        AssociationList& assocs) override;

    std::unique_ptr<Version>
        createVersionObject(const std::string& objPath,
                            const std::string& versionId,
                            const std::string& versionString,
                            sdbusplus::xyz::openbmc_project::Software::server::
                                Version::VersionPurpose versionPurpose,
                            const std::string& filePath) override;

    bool validateImage(const std::string& path) override;

    /** @brief Host factory reset - clears PNOR partitions for each
     * Activation D-Bus object */
    void reset() override;

    /**
     * @brief Validates the presence of SquashFS image in the image dir.
     *
     * @param[in]  filePath - The path to the SquashFS image.
     * @param[out] result    - 0 --> if validation was successful
     *                       - -1--> Otherwise
     */
    static int validateSquashFSImage(const std::string& filePath);

    /** @brief Clears read only PNOR partition for
     *  given Activation D-Bus object
     *
     * @param[in]  versionId - The id of the ro partition to remove.
     */
    void removeReadOnlyPartition(std::string versionId);

    /** @brief Clears read write PNOR partition for
     *  given Activation D-Bus object
     *
     *  @param[in]  versionId - The id of the rw partition to remove.
     */
    void removeReadWritePartition(std::string versionId);

    /** @brief Clears preserved PNOR partition */
    void removePreservedPartition();
};

} // namespace updater
} // namespace software
} // namespace openpower
OpenPOWER on IntegriCloud