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 void processPNORImage() override; 33 34 bool erase(std::string entryId) override; 35 36 void deleteAll() override; 37 38 void freeSpace() override; 39 40 bool isVersionFunctional(const std::string& versionId) override; 41 42 /** @brief Determine the software version id 43 * from the symlink target (e.g. /media/ro-2a1022fe). 44 * 45 * @param[in] symlinkPath - The path of the symlink. 46 * @param[out] id - The version id as a string. 47 */ 48 static std::string determineId(const std::string& symlinkPath); 49 50 private: 51 /** @brief Callback function for Software.Version match. 52 * @details Creates an Activation D-Bus object. 53 * 54 * @param[in] msg - Data associated with subscribed signal 55 */ 56 void createActivation(sdbusplus::message::message& msg) override; 57 58 /** @brief Host factory reset - clears PNOR partitions for each 59 * Activation D-Bus object */ 60 void reset() override; 61 62 /** 63 * @brief Validates the presence of SquashFS image in the image dir. 64 * 65 * @param[in] filePath - The path to the SquashFS image. 66 * @param[out] result - 0 --> if validation was successful 67 * - -1--> Otherwise 68 */ 69 static int validateSquashFSImage(const std::string& filePath); 70 71 /** @brief Clears read only PNOR partition for 72 * given Activation D-Bus object 73 * 74 * @param[in] versionId - The id of the ro partition to remove. 75 */ 76 void removeReadOnlyPartition(std::string versionId); 77 78 /** @brief Clears read write PNOR partition for 79 * given Activation D-Bus object 80 * 81 * @param[in] versionId - The id of the rw partition to remove. 82 */ 83 void removeReadWritePartition(std::string versionId); 84 85 /** @brief Clears preserved PNOR partition */ 86 void removePreservedPartition(); 87 }; 88 89 } // namespace updater 90 } // namespace software 91 } // namespace openpower 92