1 #pragma once 2 3 #include "item_updater.hpp" 4 5 namespace openpower 6 { 7 namespace software 8 { 9 namespace updater 10 { 11 12 /** @class ItemUpdaterUbi 13 * @brief Manages the activation of the host version items for ubi layout 14 */ 15 class 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 /** @brief Determine the software version id 45 * from the symlink target (e.g. /media/ro-2a1022fe). 46 * 47 * @param[in] symlinkPath - The path of the symlink. 48 * @param[out] id - The version id as a string. 49 */ 50 static std::string determineId(const std::string& symlinkPath); 51 52 private: 53 /** @brief Callback function for Software.Version match. 54 * @details Creates an Activation D-Bus object. 55 * 56 * @param[in] msg - Data associated with subscribed signal 57 */ 58 void createActivation(sdbusplus::message::message& msg) override; 59 60 /** @brief Host factory reset - clears PNOR partitions for each 61 * Activation D-Bus object */ 62 void reset() override; 63 64 /** 65 * @brief Validates the presence of SquashFS image in the image dir. 66 * 67 * @param[in] filePath - The path to the SquashFS image. 68 * @param[out] result - 0 --> if validation was successful 69 * - -1--> Otherwise 70 */ 71 static int validateSquashFSImage(const std::string& filePath); 72 73 /** @brief Clears read only PNOR partition for 74 * given Activation D-Bus object 75 * 76 * @param[in] versionId - The id of the ro partition to remove. 77 */ 78 void removeReadOnlyPartition(std::string versionId); 79 80 /** @brief Clears read write PNOR partition for 81 * given Activation D-Bus object 82 * 83 * @param[in] versionId - The id of the rw partition to remove. 84 */ 85 void removeReadWritePartition(std::string versionId); 86 87 /** @brief Clears preserved PNOR partition */ 88 void removePreservedPartition(); 89 }; 90 91 } // namespace updater 92 } // namespace software 93 } // namespace openpower 94