blob: 96782f21afb8ab5200e719c5bb89114e8045c222 [file] [log] [blame]
Gunnar Millsb0ce9962018-09-07 13:39:10 -05001#include "config.h"
2
3#include "item_updater.hpp"
4
5#include "images.hpp"
6#include "serialize.hpp"
7#include "version.hpp"
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +07008#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
Gunnar Millsb0ce9962018-09-07 13:39:10 -05009#include "xyz/openbmc_project/Software/Version/server.hpp"
10
Adriana Kobylakd5b8f752019-05-01 11:52:35 -050011#include <phosphor-logging/elog-errors.hpp>
Gunnar Millsb0ce9962018-09-07 13:39:10 -050012#include <phosphor-logging/elog.hpp>
Patrick Williamsc9bb6422021-08-27 06:18:35 -050013#include <phosphor-logging/lg2.hpp>
Adriana Kobylak58aa7502020-06-08 11:12:11 -050014#include <xyz/openbmc_project/Common/error.hpp>
15#include <xyz/openbmc_project/Software/Image/error.hpp>
16
17#include <filesystem>
18#include <fstream>
Adriana Kobylak204e1e72018-01-24 16:00:05 -060019#include <queue>
Adriana Kobylakb77551c2017-10-27 12:46:23 -050020#include <set>
Gunnar Millsec1b41c2017-05-02 12:20:36 -050021#include <string>
Gunnar Millsec1b41c2017-05-02 12:20:36 -050022
23namespace phosphor
24{
25namespace software
26{
27namespace updater
28{
29
Gunnar Mills2ce7da22017-05-04 15:37:56 -050030// When you see server:: you know we're referencing our base class
31namespace server = sdbusplus::xyz::openbmc_project::Software::server;
Michael Tritz0129d922017-08-10 19:33:46 -050032namespace control = sdbusplus::xyz::openbmc_project::Control::server;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050033
Patrick Williamsc9bb6422021-08-27 06:18:35 -050034PHOSPHOR_LOG2_USING;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050035using namespace phosphor::logging;
Adriana Kobylak43699ca2018-10-17 14:56:29 -050036using namespace sdbusplus::xyz::openbmc_project::Software::Image::Error;
Jayanth Othayoth2ab9b102018-02-21 05:27:47 -060037using namespace phosphor::software::image;
Adriana Kobylakc98d9122020-05-05 10:36:01 -050038namespace fs = std::filesystem;
Adriana Kobylakd5b8f752019-05-01 11:52:35 -050039using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
Saqib Khan35e83f32017-05-22 11:37:32 -050040
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050041void ItemUpdater::createActivation(sdbusplus::message_t& msg)
Gunnar Millsec1b41c2017-05-02 12:20:36 -050042{
Saqib Khan84a0e692017-06-28 17:27:01 -050043
44 using SVersion = server::Version;
45 using VersionPurpose = SVersion::VersionPurpose;
Gunnar Mills9a782242017-08-22 16:23:15 -050046 using VersionClass = phosphor::software::manager::Version;
Saqib Khan84a0e692017-06-28 17:27:01 -050047
Patrick Williamsbc1facd2020-06-03 05:58:27 -050048 sdbusplus::message::object_path objPath;
Saqib Khan84a0e692017-06-28 17:27:01 -050049 auto purpose = VersionPurpose::Unknown;
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +070050 std::string extendedVersion;
Saqib Khan705f1bf2017-06-09 23:58:38 -050051 std::string version;
Justin Ledford054bb0b2022-03-15 15:46:58 -070052 std::map<std::string,
53 std::map<std::string,
54 std::variant<std::string, std::vector<std::string>>>>
Adriana Kobylak2285fe02018-02-27 15:36:59 -060055 interfaces;
Patrick Williamse75d10f2017-05-30 16:56:32 -050056 msg.read(objPath, interfaces);
Gunnar Mills2ce7da22017-05-04 15:37:56 -050057 std::string path(std::move(objPath));
Saqib Khan19177d32017-06-20 08:11:49 -050058 std::string filePath;
Justin Ledford054bb0b2022-03-15 15:46:58 -070059 std::vector<std::string> compatibleNames;
Gunnar Mills2ce7da22017-05-04 15:37:56 -050060
61 for (const auto& intf : interfaces)
62 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050063 if (intf.first == VERSION_IFACE)
Gunnar Mills2ce7da22017-05-04 15:37:56 -050064 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050065 for (const auto& property : intf.second)
Gunnar Mills2ce7da22017-05-04 15:37:56 -050066 {
Saqib Khan705f1bf2017-06-09 23:58:38 -050067 if (property.first == "Purpose")
Gunnar Mills2ce7da22017-05-04 15:37:56 -050068 {
Saqib Khan84a0e692017-06-28 17:27:01 -050069 auto value = SVersion::convertVersionPurposeFromString(
Patrick Williamse883fb82020-05-13 11:38:55 -050070 std::get<std::string>(property.second));
Saqib Khan84a0e692017-06-28 17:27:01 -050071 if (value == VersionPurpose::BMC ||
Vijay Khemkae9f6c842020-01-14 14:32:39 -080072#ifdef HOST_BIOS_UPGRADE
73 value == VersionPurpose::Host ||
74#endif
Saqib Khan84a0e692017-06-28 17:27:01 -050075 value == VersionPurpose::System)
76 {
77 purpose = value;
78 }
Saqib Khan705f1bf2017-06-09 23:58:38 -050079 }
80 else if (property.first == "Version")
81 {
Patrick Williamse883fb82020-05-13 11:38:55 -050082 version = std::get<std::string>(property.second);
Gunnar Mills2ce7da22017-05-04 15:37:56 -050083 }
84 }
85 }
Saqib Khan19177d32017-06-20 08:11:49 -050086 else if (intf.first == FILEPATH_IFACE)
87 {
88 for (const auto& property : intf.second)
89 {
90 if (property.first == "Path")
91 {
Patrick Williamse883fb82020-05-13 11:38:55 -050092 filePath = std::get<std::string>(property.second);
Saqib Khan19177d32017-06-20 08:11:49 -050093 }
94 }
95 }
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +070096 else if (intf.first == EXTENDED_VERSION_IFACE)
97 {
98 for (const auto& property : intf.second)
99 {
100 if (property.first == "ExtendedVersion")
101 {
102 extendedVersion = std::get<std::string>(property.second);
103 }
104 }
105 }
Justin Ledford054bb0b2022-03-15 15:46:58 -0700106 else if (intf.first == COMPATIBLE_IFACE)
107 {
108 for (const auto& property : intf.second)
109 {
110 if (property.first == "Names")
111 {
112 compatibleNames =
113 std::get<std::vector<std::string>>(property.second);
114 }
115 }
116 }
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500117 }
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600118 if (version.empty() || filePath.empty() ||
Saqib Khan84a0e692017-06-28 17:27:01 -0500119 purpose == VersionPurpose::Unknown)
Saqib Khan705f1bf2017-06-09 23:58:38 -0500120 {
121 return;
122 }
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500123
124 // Version id is the last item in the path
125 auto pos = path.rfind("/");
126 if (pos == std::string::npos)
127 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500128 error("No version id found in object path: {PATH}", "PATH", path);
Patrick Williamse75d10f2017-05-30 16:56:32 -0500129 return;
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500130 }
131
132 auto versionId = path.substr(pos + 1);
133
Patrick Williamse75d10f2017-05-30 16:56:32 -0500134 if (activations.find(versionId) == activations.end())
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500135 {
Saqib Khan35e83f32017-05-22 11:37:32 -0500136 // Determine the Activation state by processing the given image dir.
137 auto activationState = server::Activation::Activations::Invalid;
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800138 ItemUpdater::ActivationStatus result;
139 if (purpose == VersionPurpose::BMC || purpose == VersionPurpose::System)
140 result = ItemUpdater::validateSquashFSImage(filePath);
141 else
142 result = ItemUpdater::ActivationStatus::ready;
143
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500144 AssociationList associations = {};
145
Saqib Khan35e83f32017-05-22 11:37:32 -0500146 if (result == ItemUpdater::ActivationStatus::ready)
147 {
148 activationState = server::Activation::Activations::Ready;
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500149 // Create an association to the BMC inventory item
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600150 associations.emplace_back(
151 std::make_tuple(ACTIVATION_FWD_ASSOCIATION,
152 ACTIVATION_REV_ASSOCIATION, bmcInventoryPath));
Saqib Khan35e83f32017-05-22 11:37:32 -0500153 }
Gunnar Millsb60add12017-08-24 16:41:42 -0500154
Saqib Khanee13e832017-10-23 12:53:11 -0500155 auto versionPtr = std::make_unique<VersionClass>(
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +0700156 bus, path, version, purpose, extendedVersion, filePath,
Justin Ledford054bb0b2022-03-15 15:46:58 -0700157 compatibleNames,
Adriana Kobylak59b640b2022-01-21 19:45:22 +0000158 std::bind(&ItemUpdater::erase, this, std::placeholders::_1),
159 versionId);
Saqib Khanee13e832017-10-23 12:53:11 -0500160 versionPtr->deleteObject =
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600161 std::make_unique<phosphor::software::manager::Delete>(bus, path,
162 *versionPtr);
Saqib Khanee13e832017-10-23 12:53:11 -0500163 versions.insert(std::make_pair(versionId, std::move(versionPtr)));
Adriana Kobylak88ba1f92022-03-09 21:14:15 +0000164
165 activations.insert(std::make_pair(
166 versionId,
167 std::make_unique<Activation>(bus, path, *this, versionId,
168 activationState, associations)));
Gunnar Mills2ce7da22017-05-04 15:37:56 -0500169 }
Patrick Williamse75d10f2017-05-30 16:56:32 -0500170 return;
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500171}
172
Saqib Khanba239882017-05-26 08:41:54 -0500173void ItemUpdater::processBMCImage()
174{
Gunnar Mills88e8a322017-09-13 11:09:28 -0500175 using VersionClass = phosphor::software::manager::Version;
Lei YU269bff32018-08-21 15:21:40 +0800176
177 // Check MEDIA_DIR and create if it does not exist
178 try
179 {
180 if (!fs::is_directory(MEDIA_DIR))
181 {
182 fs::create_directory(MEDIA_DIR);
183 }
184 }
185 catch (const fs::filesystem_error& e)
186 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500187 error("Failed to prepare dir: {ERROR}", "ERROR", e);
Lei YU269bff32018-08-21 15:21:40 +0800188 return;
189 }
190
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000191 // Functional images are mounted as rofs-<location>-functional
192 constexpr auto functionalSuffix = "-functional";
Lei YUd474d9c2021-12-10 16:21:21 +0800193 bool functionalFound = false;
Gunnar Mills88e8a322017-09-13 11:09:28 -0500194
Saqib Khan1eef62d2017-08-10 15:29:34 -0500195 // Read os-release from folders under /media/ to get
196 // BMC Software Versions.
Gunnar Millsd16bcbd2017-10-08 16:50:42 -0500197 for (const auto& iter : fs::directory_iterator(MEDIA_DIR))
Saqib Khan1eef62d2017-08-10 15:29:34 -0500198 {
199 auto activationState = server::Activation::Activations::Active;
Saqib Khan6fab70d2017-09-07 00:13:50 -0500200 static const auto BMC_RO_PREFIX_LEN = strlen(BMC_ROFS_PREFIX);
Saqib Khan1eef62d2017-08-10 15:29:34 -0500201
202 // Check if the BMC_RO_PREFIXis the prefix of the iter.path
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600203 if (0 ==
204 iter.path().native().compare(0, BMC_RO_PREFIX_LEN, BMC_ROFS_PREFIX))
Saqib Khan1eef62d2017-08-10 15:29:34 -0500205 {
Adriana Kobylak716cd782020-06-08 13:27:43 -0500206 // Get the version to calculate the id
Adriana Kobylak24a8d832020-06-10 08:29:36 -0500207 fs::path releaseFile(OS_RELEASE_FILE);
208 auto osRelease = iter.path() / releaseFile.relative_path();
Saqib Khan1eef62d2017-08-10 15:29:34 -0500209 if (!fs::is_regular_file(osRelease))
210 {
Lei YUe56bf872022-02-22 18:40:37 +0800211#ifdef BMC_STATIC_DUAL_IMAGE
212 // For dual image, it is possible that the secondary image is
213 // empty or contains invalid data, ignore such case.
214 info("Unable to find osRelease: {PATH}", "PATH", osRelease);
215#else
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500216 error("Failed to read osRelease: {PATH}", "PATH", osRelease);
Adriana Kobylak716cd782020-06-08 13:27:43 -0500217
218 // Try to get the version id from the mount directory name and
219 // call to delete it as this version may be corrupted. Dynamic
220 // volumes created by the UBI layout for example have the id in
221 // the mount directory name. The worst that can happen is that
222 // erase() is called with an non-existent id and returns.
223 auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN);
Saqib Khan021c3652017-09-26 12:11:02 -0500224 ItemUpdater::erase(id);
Lei YUe56bf872022-02-22 18:40:37 +0800225#endif
Adriana Kobylak716cd782020-06-08 13:27:43 -0500226
Saqib Khan021c3652017-09-26 12:11:02 -0500227 continue;
Saqib Khan1eef62d2017-08-10 15:29:34 -0500228 }
Gunnar Mills88e8a322017-09-13 11:09:28 -0500229 auto version = VersionClass::getBMCVersion(osRelease);
Saqib Khan1eef62d2017-08-10 15:29:34 -0500230 if (version.empty())
231 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500232 error("Failed to read version from osRelease: {PATH}", "PATH",
233 osRelease);
Adriana Kobylak716cd782020-06-08 13:27:43 -0500234
235 // Try to delete the version, same as above if the
236 // OS_RELEASE_FILE does not exist.
237 auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN);
238 ItemUpdater::erase(id);
239
240 continue;
Saqib Khan1eef62d2017-08-10 15:29:34 -0500241 }
Saqib Khan021c3652017-09-26 12:11:02 -0500242
Adriana Kobylak59b640b2022-01-21 19:45:22 +0000243 // The flash location is part of the mount name: rofs-<location>
244 auto flashId = iter.path().native().substr(BMC_RO_PREFIX_LEN);
245
246 auto id = VersionClass::getId(version + flashId);
Adriana Kobylak716cd782020-06-08 13:27:43 -0500247
Adriana Kobylakf383d272020-06-16 15:17:22 -0500248 // Check if the id has already been added. This can happen if the
249 // BMC partitions / devices were manually flashed with the same
250 // image.
251 if (versions.find(id) != versions.end())
252 {
253 continue;
254 }
255
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000256 auto functional = false;
257 if (iter.path().native().find(functionalSuffix) !=
258 std::string::npos)
259 {
260 // Set functional to true and remove the functional suffix
261 functional = true;
262 flashId.erase(flashId.length() - strlen(functionalSuffix));
Lei YUd474d9c2021-12-10 16:21:21 +0800263 functionalFound = true;
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000264 }
Adriana Kobylak780220f2022-01-18 20:01:53 +0000265
Saqib Khan1eef62d2017-08-10 15:29:34 -0500266 auto purpose = server::Version::VersionPurpose::BMC;
Adriana Kobylak780220f2022-01-18 20:01:53 +0000267 restorePurpose(flashId, purpose);
Adriana Kobylakec4eec32019-11-13 14:28:35 -0600268
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +0700269 // Read os-release from /etc/ to get the BMC extended version
270 std::string extendedVersion =
271 VersionClass::getBMCExtendedVersion(osRelease);
272
Saqib Khan1eef62d2017-08-10 15:29:34 -0500273 auto path = fs::path(SOFTWARE_OBJPATH) / id;
274
Lei YU269bff32018-08-21 15:21:40 +0800275 // Create functional association if this is the functional
276 // version
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000277 if (functional)
Gunnar Mills88e8a322017-09-13 11:09:28 -0500278 {
279 createFunctionalAssociation(path);
280 }
281
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500282 AssociationList associations = {};
283
284 if (activationState == server::Activation::Activations::Active)
285 {
286 // Create an association to the BMC inventory item
287 associations.emplace_back(std::make_tuple(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600288 ACTIVATION_FWD_ASSOCIATION, ACTIVATION_REV_ASSOCIATION,
289 bmcInventoryPath));
Gunnar Mills43b25cd2017-09-07 13:19:34 -0500290
291 // Create an active association since this image is active
292 createActiveAssociation(path);
293 }
294
AppaRao Pulibbebec72020-01-28 23:57:41 +0530295 // All updateable firmware components must expose the updateable
296 // association.
297 createUpdateableAssociation(path);
298
Adriana Kobylakee590c72017-09-26 15:16:06 -0500299 // Create Version instance for this version.
300 auto versionPtr = std::make_unique<VersionClass>(
Adriana Kobylaka84f06d2022-01-18 15:41:57 +0000301 bus, path, version, purpose, extendedVersion, flashId,
Justin Ledford054bb0b2022-03-15 15:46:58 -0700302 std::vector<std::string>(),
Adriana Kobylak59b640b2022-01-21 19:45:22 +0000303 std::bind(&ItemUpdater::erase, this, std::placeholders::_1),
304 id);
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000305 if (functional)
306 {
307 versionPtr->setFunctional(true);
308 }
309 else
Michael Tritz4254bec2017-10-03 17:18:22 -0500310 {
Saqib Khanee13e832017-10-23 12:53:11 -0500311 versionPtr->deleteObject =
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600312 std::make_unique<phosphor::software::manager::Delete>(
313 bus, path, *versionPtr);
Michael Tritz4254bec2017-10-03 17:18:22 -0500314 }
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600315 versions.insert(std::make_pair(id, std::move(versionPtr)));
Michael Tritz4254bec2017-10-03 17:18:22 -0500316
Saqib Khanee13e832017-10-23 12:53:11 -0500317 // Create Activation instance for this version.
318 activations.insert(std::make_pair(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600319 id, std::make_unique<Activation>(
320 bus, path, *this, id, activationState, associations)));
Saqib Khan1eef62d2017-08-10 15:29:34 -0500321
Lei YUbdf2d6c2021-12-15 14:05:01 +0800322#ifdef BMC_STATIC_DUAL_IMAGE
323 uint8_t priority;
324 if ((functional && (runningImageSlot == 0)) ||
325 (!functional && (runningImageSlot == 1)))
326 {
327 priority = 0;
328 }
329 else
330 {
331 priority = 1;
332 }
333 activations.find(id)->second->redundancyPriority =
334 std::make_unique<RedundancyPriority>(
335 bus, path, *(activations.find(id)->second), priority,
336 false);
337#else
Lei YU269bff32018-08-21 15:21:40 +0800338 // If Active, create RedundancyPriority instance for this
339 // version.
Saqib Khan1eef62d2017-08-10 15:29:34 -0500340 if (activationState == server::Activation::Activations::Active)
341 {
342 uint8_t priority = std::numeric_limits<uint8_t>::max();
Adriana Kobylak780220f2022-01-18 20:01:53 +0000343 if (!restorePriority(flashId, priority))
Saqib Khan1eef62d2017-08-10 15:29:34 -0500344 {
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000345 if (functional)
Adriana Kobylakee590c72017-09-26 15:16:06 -0500346 {
347 priority = 0;
348 }
349 else
350 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500351 error(
352 "Unable to restore priority from file for {VERSIONID}",
353 "VERSIONID", id);
Adriana Kobylakee590c72017-09-26 15:16:06 -0500354 }
Saqib Khan1eef62d2017-08-10 15:29:34 -0500355 }
356 activations.find(id)->second->redundancyPriority =
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600357 std::make_unique<RedundancyPriority>(
358 bus, path, *(activations.find(id)->second), priority,
359 false);
Saqib Khan1eef62d2017-08-10 15:29:34 -0500360 }
Lei YUbdf2d6c2021-12-15 14:05:01 +0800361#endif
Saqib Khan1eef62d2017-08-10 15:29:34 -0500362 }
363 }
Saqib Khandcbfa042017-09-18 13:08:39 -0500364
Lei YUd474d9c2021-12-10 16:21:21 +0800365 if (!functionalFound)
Saqib Khandcbfa042017-09-18 13:08:39 -0500366 {
Lei YUd474d9c2021-12-10 16:21:21 +0800367 // If there is no functional version found, read the /etc/os-release and
368 // create rofs-<versionId>-functional under MEDIA_DIR, then call again
369 // processBMCImage() to create the D-Bus interface for it.
Gunnar Millsd16bcbd2017-10-08 16:50:42 -0500370 auto version = VersionClass::getBMCVersion(OS_RELEASE_FILE);
Adriana Kobylak59b640b2022-01-21 19:45:22 +0000371 auto id = phosphor::software::manager::Version::getId(version +
372 functionalSuffix);
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000373 auto versionFileDir = BMC_ROFS_PREFIX + id + functionalSuffix + "/etc/";
Saqib Khandcbfa042017-09-18 13:08:39 -0500374 try
375 {
Gunnar Millsd16bcbd2017-10-08 16:50:42 -0500376 if (!fs::is_directory(versionFileDir))
Saqib Khandcbfa042017-09-18 13:08:39 -0500377 {
378 fs::create_directories(versionFileDir);
379 }
Adriana Kobylak1e81f232022-01-18 22:28:47 +0000380 auto versionFilePath =
381 BMC_ROFS_PREFIX + id + functionalSuffix + OS_RELEASE_FILE;
Saqib Khandcbfa042017-09-18 13:08:39 -0500382 fs::create_directory_symlink(OS_RELEASE_FILE, versionFilePath);
383 ItemUpdater::processBMCImage();
384 }
385 catch (const std::exception& e)
386 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500387 error("Exception during processing: {ERROR}", "ERROR", e);
Saqib Khandcbfa042017-09-18 13:08:39 -0500388 }
389 }
Eddie Jameseaa1ee02018-03-01 10:09:10 -0600390
391 mirrorUbootToAlt();
Saqib Khanba239882017-05-26 08:41:54 -0500392 return;
393}
394
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500395void ItemUpdater::erase(std::string entryId)
396{
Eddie James6d873712017-09-01 11:29:07 -0500397 // Find entry in versions map
398 auto it = versions.find(entryId);
399 if (it != versions.end())
400 {
Lei YU0f88b5a2018-08-21 15:28:53 +0800401 if (it->second->isFunctional() && ACTIVE_BMC_MAX_ALLOWED > 1)
Eddie James6d873712017-09-01 11:29:07 -0500402 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500403 error(
404 "Version ({VERSIONID}) is currently running on the BMC; unable to remove.",
405 "VERSIONID", entryId);
Gunnar Millsd16bcbd2017-10-08 16:50:42 -0500406 return;
Eddie James6d873712017-09-01 11:29:07 -0500407 }
Adriana Kobylakd1a55ad2020-06-11 14:01:28 -0500408 }
Eddie James6d873712017-09-01 11:29:07 -0500409
Adriana Kobylakd1a55ad2020-06-11 14:01:28 -0500410 // First call resetUbootEnvVars() so that the BMC points to a valid image to
411 // boot from. If resetUbootEnvVars() is called after the image is actually
412 // deleted from the BMC flash, there'd be a time window where the BMC would
413 // be pointing to a non-existent image to boot from.
414 // Need to remove the entries from the activations map before that call so
415 // that resetUbootEnvVars() doesn't use the version to be deleted.
416 auto iteratorActivations = activations.find(entryId);
417 if (iteratorActivations == activations.end())
418 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500419 error(
420 "Failed to find version ({VERSIONID}) in item updater activations map; unable to remove.",
421 "VERSIONID", entryId);
Adriana Kobylakd1a55ad2020-06-11 14:01:28 -0500422 }
423 else
424 {
425 removeAssociations(iteratorActivations->second->path);
Zami Seckae06d762021-08-13 20:11:15 -0500426 iteratorActivations->second->deleteImageManagerObject();
Adriana Kobylakd1a55ad2020-06-11 14:01:28 -0500427 this->activations.erase(entryId);
428 }
429 ItemUpdater::resetUbootEnvVars();
430
431 if (it != versions.end())
432 {
Adriana Kobylak780220f2022-01-18 20:01:53 +0000433 auto flashId = it->second->path();
434
Adriana Kobylak25773a72022-01-21 15:24:48 +0000435 // Delete version data if it has been installed on flash (path is not
436 // the upload directory)
437 if (flashId.find(IMG_UPLOAD_DIR) == std::string::npos)
438 {
439 removeReadOnlyPartition(entryId);
440 removePersistDataDirectory(flashId);
441 helper.clearEntry(flashId);
442 }
Saqib Khanee13e832017-10-23 12:53:11 -0500443
444 // Removing entry in versions map
445 this->versions.erase(entryId);
Eddie James6d873712017-09-01 11:29:07 -0500446 }
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500447
Saqib Khanee13e832017-10-23 12:53:11 -0500448 return;
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500449}
450
Michael Tritzbc1bf3a2017-09-18 16:38:23 -0500451void ItemUpdater::deleteAll()
452{
Adriana Kobylak83cd21f2018-02-28 15:48:48 -0600453 std::vector<std::string> deletableVersions;
454
Michael Tritzbc1bf3a2017-09-18 16:38:23 -0500455 for (const auto& versionIt : versions)
456 {
457 if (!versionIt.second->isFunctional())
458 {
Adriana Kobylak83cd21f2018-02-28 15:48:48 -0600459 deletableVersions.push_back(versionIt.first);
Michael Tritzbc1bf3a2017-09-18 16:38:23 -0500460 }
461 }
462
Adriana Kobylak83cd21f2018-02-28 15:48:48 -0600463 for (const auto& deletableIt : deletableVersions)
464 {
465 ItemUpdater::erase(deletableIt);
466 }
467
Lei YU56aaf452018-06-21 16:09:44 +0800468 helper.cleanup();
Michael Tritzbc1bf3a2017-09-18 16:38:23 -0500469}
470
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600471ItemUpdater::ActivationStatus
472 ItemUpdater::validateSquashFSImage(const std::string& filePath)
Saqib Khan35e83f32017-05-22 11:37:32 -0500473{
Bright Cheng8e9ccfe2019-11-18 16:18:44 +0800474 bool valid = true;
Saqib Khan35e83f32017-05-22 11:37:32 -0500475
Bright Cheng8e9ccfe2019-11-18 16:18:44 +0800476 // Record the images which are being updated
477 // First check for the fullimage, then check for images with partitions
478 imageUpdateList.push_back(bmcFullImages);
479 valid = checkImage(filePath, imageUpdateList);
480 if (!valid)
Saqib Khan35e83f32017-05-22 11:37:32 -0500481 {
Bright Cheng8e9ccfe2019-11-18 16:18:44 +0800482 imageUpdateList.clear();
483 imageUpdateList.assign(bmcImages.begin(), bmcImages.end());
484 valid = checkImage(filePath, imageUpdateList);
485 if (!valid)
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500486 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500487 error("Failed to find the needed BMC images.");
Bright Cheng8e9ccfe2019-11-18 16:18:44 +0800488 return ItemUpdater::ActivationStatus::invalid;
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500489 }
Saqib Khan35e83f32017-05-22 11:37:32 -0500490 }
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500491
Michael Tritzb1cfdf92017-08-14 14:33:30 -0500492 return ItemUpdater::ActivationStatus::ready;
Saqib Khan35e83f32017-05-22 11:37:32 -0500493}
494
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500495void ItemUpdater::savePriority(const std::string& versionId, uint8_t value)
496{
Adriana Kobylak780220f2022-01-18 20:01:53 +0000497 auto flashId = versions.find(versionId)->second->path();
498 storePriority(flashId, value);
Adriana Kobylak25773a72022-01-21 15:24:48 +0000499 helper.setEntry(flashId, value);
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500500}
501
Saqib Khanb9da6632017-09-13 09:48:37 -0500502void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
Saqib Khan4c1aec02017-07-06 11:46:13 -0500503{
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500504 std::map<std::string, uint8_t> priorityMap;
505
506 // Insert the requested version and priority, it may not exist yet.
507 priorityMap.insert(std::make_pair(versionId, value));
508
Saqib Khan4c1aec02017-07-06 11:46:13 -0500509 for (const auto& intf : activations)
510 {
Gunnar Mills9a782242017-08-22 16:23:15 -0500511 if (intf.second->redundancyPriority)
Saqib Khan4c1aec02017-07-06 11:46:13 -0500512 {
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500513 priorityMap.insert(std::make_pair(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600514 intf.first, intf.second->redundancyPriority.get()->priority()));
Saqib Khan4c1aec02017-07-06 11:46:13 -0500515 }
516 }
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500517
518 // Lambda function to compare 2 priority values, use <= to allow duplicates
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600519 typedef std::function<bool(std::pair<std::string, uint8_t>,
520 std::pair<std::string, uint8_t>)>
521 cmpPriority;
522 cmpPriority cmpPriorityFunc =
523 [](std::pair<std::string, uint8_t> priority1,
524 std::pair<std::string, uint8_t> priority2) {
525 return priority1.second <= priority2.second;
526 };
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500527
528 // Sort versions by ascending priority
529 std::set<std::pair<std::string, uint8_t>, cmpPriority> prioritySet(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600530 priorityMap.begin(), priorityMap.end(), cmpPriorityFunc);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500531
532 auto freePriorityValue = value;
533 for (auto& element : prioritySet)
534 {
535 if (element.first == versionId)
536 {
537 continue;
538 }
539 if (element.second == freePriorityValue)
540 {
541 ++freePriorityValue;
542 auto it = activations.find(element.first);
543 it->second->redundancyPriority.get()->sdbusPriority(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600544 freePriorityValue);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500545 }
546 }
547
548 auto lowestVersion = prioritySet.begin()->first;
549 if (value == prioritySet.begin()->second)
550 {
551 lowestVersion = versionId;
552 }
553 updateUbootEnvVars(lowestVersion);
Saqib Khan4c1aec02017-07-06 11:46:13 -0500554}
555
Michael Tritz37a59042017-07-12 13:44:53 -0500556void ItemUpdater::reset()
557{
Lei YU56aaf452018-06-21 16:09:44 +0800558 helper.factoryReset();
Michael Tritz37a59042017-07-12 13:44:53 -0500559
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500560 info("BMC factory reset will take effect upon reboot.");
Michael Tritz37a59042017-07-12 13:44:53 -0500561}
562
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500563void ItemUpdater::removeReadOnlyPartition(std::string versionId)
564{
Adriana Kobylak25773a72022-01-21 15:24:48 +0000565 auto flashId = versions.find(versionId)->second->path();
566 helper.removeVersion(flashId);
Leonel Gonzalez3526ef72017-07-07 14:38:25 -0500567}
568
Michael Tritz0129d922017-08-10 19:33:46 -0500569bool ItemUpdater::fieldModeEnabled(bool value)
570{
571 // enabling field mode is intended to be one way: false -> true
572 if (value && !control::FieldMode::fieldModeEnabled())
573 {
574 control::FieldMode::fieldModeEnabled(value);
575
Adriana Kobylak22848ec2019-10-28 10:08:39 -0500576 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
577 SYSTEMD_INTERFACE, "StartUnit");
578 method.append("obmc-flash-bmc-setenv@fieldmode\\x3dtrue.service",
579 "replace");
580 bus.call_noreply(method);
581
582 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
583 SYSTEMD_INTERFACE, "StopUnit");
584 method.append("usr-local.mount", "replace");
585 bus.call_noreply(method);
586
587 std::vector<std::string> usrLocal = {"usr-local.mount"};
588
589 method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
590 SYSTEMD_INTERFACE, "MaskUnitFiles");
591 method.append(usrLocal, false, true);
592 bus.call_noreply(method);
Michael Tritz0129d922017-08-10 19:33:46 -0500593 }
Adriana Kobylakd5b8f752019-05-01 11:52:35 -0500594 else if (!value && control::FieldMode::fieldModeEnabled())
595 {
596 elog<NotAllowed>(xyz::openbmc_project::Common::NotAllowed::REASON(
597 "FieldMode is not allowed to be cleared"));
598 }
Michael Tritz0129d922017-08-10 19:33:46 -0500599
600 return control::FieldMode::fieldModeEnabled();
601}
602
603void ItemUpdater::restoreFieldModeStatus()
604{
Michael Tritzff0b4212017-10-24 17:38:09 -0500605 std::ifstream input("/dev/mtd/u-boot-env");
Michael Tritz0129d922017-08-10 19:33:46 -0500606 std::string envVar;
607 std::getline(input, envVar);
608
Gunnar Mills9a782242017-08-22 16:23:15 -0500609 if (envVar.find("fieldmode=true") != std::string::npos)
Michael Tritz0129d922017-08-10 19:33:46 -0500610 {
611 ItemUpdater::fieldModeEnabled(true);
612 }
613}
614
Gunnar Millsb60add12017-08-24 16:41:42 -0500615void ItemUpdater::setBMCInventoryPath()
616{
Gunnar Millsb60add12017-08-24 16:41:42 -0500617 auto depth = 0;
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600618 auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
619 MAPPER_INTERFACE, "GetSubTreePaths");
Gunnar Millsb60add12017-08-24 16:41:42 -0500620
Adriana Kobylak1254c622017-12-07 12:24:56 -0600621 mapperCall.append(INVENTORY_PATH);
Gunnar Millsb60add12017-08-24 16:41:42 -0500622 mapperCall.append(depth);
Adriana Kobylak1254c622017-12-07 12:24:56 -0600623 std::vector<std::string> filter = {BMC_INVENTORY_INTERFACE};
Gunnar Millsb60add12017-08-24 16:41:42 -0500624 mapperCall.append(filter);
625
Ed Tanous87c78172018-08-10 12:51:53 -0700626 try
627 {
628 auto response = bus.call(mapperCall);
629
630 using ObjectPaths = std::vector<std::string>;
631 ObjectPaths result;
632 response.read(result);
633
634 if (!result.empty())
635 {
636 bmcInventoryPath = result.front();
637 }
638 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500639 catch (const sdbusplus::exception_t& e)
Gunnar Millsb60add12017-08-24 16:41:42 -0500640 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500641 error("Error in mapper GetSubTreePath: {ERROR}", "ERROR", e);
Gunnar Millsb60add12017-08-24 16:41:42 -0500642 return;
643 }
644
Adriana Kobylak1254c622017-12-07 12:24:56 -0600645 return;
Gunnar Millsb60add12017-08-24 16:41:42 -0500646}
647
Gunnar Millsf10b2322017-09-21 15:31:55 -0500648void ItemUpdater::createActiveAssociation(const std::string& path)
Gunnar Millsded875d2017-08-28 16:44:52 -0500649{
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600650 assocs.emplace_back(
651 std::make_tuple(ACTIVE_FWD_ASSOCIATION, ACTIVE_REV_ASSOCIATION, path));
Gunnar Millsded875d2017-08-28 16:44:52 -0500652 associations(assocs);
653}
654
Gunnar Mills88e8a322017-09-13 11:09:28 -0500655void ItemUpdater::createFunctionalAssociation(const std::string& path)
656{
657 assocs.emplace_back(std::make_tuple(FUNCTIONAL_FWD_ASSOCIATION,
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600658 FUNCTIONAL_REV_ASSOCIATION, path));
Gunnar Mills88e8a322017-09-13 11:09:28 -0500659 associations(assocs);
660}
661
AppaRao Pulibbebec72020-01-28 23:57:41 +0530662void ItemUpdater::createUpdateableAssociation(const std::string& path)
663{
664 assocs.emplace_back(std::make_tuple(UPDATEABLE_FWD_ASSOCIATION,
665 UPDATEABLE_REV_ASSOCIATION, path));
666 associations(assocs);
667}
668
Adriana Kobylak991af7e2018-12-10 13:08:38 -0600669void ItemUpdater::removeAssociations(const std::string& path)
Gunnar Millsded875d2017-08-28 16:44:52 -0500670{
671 for (auto iter = assocs.begin(); iter != assocs.end();)
672 {
Adriana Kobylak991af7e2018-12-10 13:08:38 -0600673 if ((std::get<2>(*iter)).compare(path) == 0)
Gunnar Millsded875d2017-08-28 16:44:52 -0500674 {
675 iter = assocs.erase(iter);
676 associations(assocs);
677 }
678 else
679 {
680 ++iter;
681 }
682 }
683}
684
Saqib Khanb9da6632017-09-13 09:48:37 -0500685bool ItemUpdater::isLowestPriority(uint8_t value)
686{
687 for (const auto& intf : activations)
688 {
Gunnar Millsd16bcbd2017-10-08 16:50:42 -0500689 if (intf.second->redundancyPriority)
Saqib Khanb9da6632017-09-13 09:48:37 -0500690 {
691 if (intf.second->redundancyPriority.get()->priority() < value)
692 {
693 return false;
694 }
695 }
696 }
697 return true;
698}
699
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500700void ItemUpdater::updateUbootEnvVars(const std::string& versionId)
701{
Lei YU9c76a0a2022-03-14 11:37:15 +0800702 auto it = versions.find(versionId);
703 if (it == versions.end())
704 {
705 return;
706 }
707 auto flashId = it->second->path();
Adriana Kobylak25773a72022-01-21 15:24:48 +0000708 helper.updateUbootVersionId(flashId);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500709}
710
Saqib Khan49446ae2017-10-02 10:54:20 -0500711void ItemUpdater::resetUbootEnvVars()
712{
713 decltype(activations.begin()->second->redundancyPriority.get()->priority())
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600714 lowestPriority = std::numeric_limits<uint8_t>::max();
Saqib Khan49446ae2017-10-02 10:54:20 -0500715 decltype(activations.begin()->second->versionId) lowestPriorityVersion;
716 for (const auto& intf : activations)
717 {
718 if (!intf.second->redundancyPriority.get())
719 {
720 // Skip this version if the redundancyPriority is not initialized.
721 continue;
722 }
723
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600724 if (intf.second->redundancyPriority.get()->priority() <= lowestPriority)
Saqib Khan49446ae2017-10-02 10:54:20 -0500725 {
726 lowestPriority = intf.second->redundancyPriority.get()->priority();
727 lowestPriorityVersion = intf.second->versionId;
728 }
729 }
730
Saqib Khanf0382c32017-10-24 13:36:22 -0500731 // Update the U-boot environment variable to point to the lowest priority
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500732 updateUbootEnvVars(lowestPriorityVersion);
Saqib Khan49446ae2017-10-02 10:54:20 -0500733}
734
Lei YUd8c9eea2021-12-16 16:08:30 +0800735void ItemUpdater::freeSpace([[maybe_unused]] const Activation& caller)
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600736{
Lei YUd8c9eea2021-12-16 16:08:30 +0800737#ifdef BMC_STATIC_DUAL_IMAGE
738 // For the golden image case, always remove the version on the primary side
739 std::string versionIDtoErase;
740 for (const auto& iter : activations)
741 {
742 if (iter.second->redundancyPriority &&
743 iter.second->redundancyPriority.get()->priority() == 0)
744 {
745 versionIDtoErase = iter.second->versionId;
746 break;
747 }
748 }
749 if (!versionIDtoErase.empty())
750 {
751 erase(versionIDtoErase);
752 }
753 else
754 {
755 warning("Failed to find version to erase");
756 }
757#else
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600758 // Versions with the highest priority in front
759 std::priority_queue<std::pair<int, std::string>,
760 std::vector<std::pair<int, std::string>>,
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600761 std::less<std::pair<int, std::string>>>
762 versionsPQ;
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600763
764 std::size_t count = 0;
765 for (const auto& iter : activations)
766 {
767 if ((iter.second.get()->activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600768 server::Activation::Activations::Active) ||
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600769 (iter.second.get()->activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600770 server::Activation::Activations::Failed))
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600771 {
772 count++;
773 // Don't put the functional version on the queue since we can't
774 // remove the "running" BMC version.
Lei YU0f88b5a2018-08-21 15:28:53 +0800775 // If ACTIVE_BMC_MAX_ALLOWED <= 1, there is only one active BMC,
776 // so remove functional version as well.
Adriana Kobylaka6963592018-09-07 14:13:29 -0500777 // Don't delete the the Activation object that called this function.
778 if ((versions.find(iter.second->versionId)
779 ->second->isFunctional() &&
780 ACTIVE_BMC_MAX_ALLOWED > 1) ||
781 (iter.second->versionId == caller.versionId))
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600782 {
783 continue;
784 }
Adriana Kobylaka6963592018-09-07 14:13:29 -0500785
786 // Failed activations don't have priority, assign them a large value
787 // for sorting purposes.
788 auto priority = 999;
789 if (iter.second.get()->activation() ==
Lei YUcfb4b202021-05-06 17:47:28 +0800790 server::Activation::Activations::Active &&
791 iter.second->redundancyPriority)
Adriana Kobylaka6963592018-09-07 14:13:29 -0500792 {
793 priority = iter.second->redundancyPriority.get()->priority();
794 }
795
796 versionsPQ.push(std::make_pair(priority, iter.second->versionId));
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600797 }
798 }
799
800 // If the number of BMC versions is over ACTIVE_BMC_MAX_ALLOWED -1,
801 // remove the highest priority one(s).
802 while ((count >= ACTIVE_BMC_MAX_ALLOWED) && (!versionsPQ.empty()))
803 {
804 erase(versionsPQ.top().second);
805 versionsPQ.pop();
806 count--;
807 }
Lei YUd8c9eea2021-12-16 16:08:30 +0800808#endif
Adriana Kobylak204e1e72018-01-24 16:00:05 -0600809}
810
Eddie Jameseaa1ee02018-03-01 10:09:10 -0600811void ItemUpdater::mirrorUbootToAlt()
812{
Lei YU56aaf452018-06-21 16:09:44 +0800813 helper.mirrorAlt();
Eddie Jameseaa1ee02018-03-01 10:09:10 -0600814}
815
Bright Cheng8e9ccfe2019-11-18 16:18:44 +0800816bool ItemUpdater::checkImage(const std::string& filePath,
817 const std::vector<std::string>& imageList)
818{
819 bool valid = true;
820
821 for (auto& bmcImage : imageList)
822 {
823 fs::path file(filePath);
824 file /= bmcImage;
825 std::ifstream efile(file.c_str());
826 if (efile.good() != 1)
827 {
828 valid = false;
829 break;
830 }
831 }
832
833 return valid;
834}
835
Lei YU6e9fb1d2021-02-19 18:01:40 +0800836#ifdef HOST_BIOS_UPGRADE
837void ItemUpdater::createBIOSObject()
838{
839 std::string path = BIOS_OBJPATH;
840 // Get version id from last item in the path
841 auto pos = path.rfind("/");
842 if (pos == std::string::npos)
843 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500844 error("No version id found in object path {PATH}", "PATH", path);
Lei YU6e9fb1d2021-02-19 18:01:40 +0800845 return;
846 }
847
848 createActiveAssociation(path);
849 createFunctionalAssociation(path);
850
851 auto versionId = path.substr(pos + 1);
852 auto version = "null";
853 AssociationList assocs = {};
854 biosActivation = std::make_unique<Activation>(
855 bus, path, *this, versionId, server::Activation::Activations::Active,
856 assocs);
857 auto dummyErase = [](std::string /*entryId*/) {
858 // Do nothing;
859 };
860 biosVersion = std::make_unique<VersionClass>(
861 bus, path, version, VersionPurpose::Host, "", "",
Justin Ledford054bb0b2022-03-15 15:46:58 -0700862 std::vector<std::string>(),
Adriana Kobylak59b640b2022-01-21 19:45:22 +0000863 std::bind(dummyErase, std::placeholders::_1), "");
Lei YU6e9fb1d2021-02-19 18:01:40 +0800864 biosVersion->deleteObject =
865 std::make_unique<phosphor::software::manager::Delete>(bus, path,
866 *biosVersion);
867}
868#endif
869
Lei YU531fbc22021-12-10 20:03:18 +0800870void ItemUpdater::getRunningSlot()
871{
872 // Check /run/media/slot to get the slot number
873 constexpr auto slotFile = "/run/media/slot";
874 std::fstream f(slotFile, std::ios_base::in);
875 f >> runningImageSlot;
876}
877
Gunnar Millsec1b41c2017-05-02 12:20:36 -0500878} // namespace updater
879} // namespace software
880} // namespace phosphor