Use flash id to write image to flash
Update the item updater helper functions to take the flash id instead of
the version id since flash id is the name of the volumes/partitions.
The flash id was being persisted for the mmc layout with the name of
"partlabel". This is not needed anymore since the flash id is now being
passed by the service files.
The write functions/service files still use the version id to know where
the image files are located in /tmp/. They then set the value of flash
id (Path property) which is then used by the other functions such as
Delete and setting the u-boot environment variables.
Tested: Code update and Delete functions work on ubi and mmc.
Change-Id: I87c5b8ae2e24af30256dc3b436859835f14cda05
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index e7de3d0..94de753 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -375,24 +375,18 @@
{
auto flashId = it->second->path();
- // Delete ReadOnly partitions if it's not active
- removeReadOnlyPartition(entryId);
- removePersistDataDirectory(flashId);
+ // Delete version data if it has been installed on flash (path is not
+ // the upload directory)
+ if (flashId.find(IMG_UPLOAD_DIR) == std::string::npos)
+ {
+ removeReadOnlyPartition(entryId);
+ removePersistDataDirectory(flashId);
+ helper.clearEntry(flashId);
+ }
// Removing entry in versions map
this->versions.erase(entryId);
}
- else
- {
- // Delete ReadOnly partitions even if we can't find the version
- removeReadOnlyPartition(entryId);
-
- error(
- "Failed to find version ({VERSIONID}) in item updater versions map; unable to remove.",
- "VERSIONID", entryId);
- }
-
- helper.clearEntry(entryId);
return;
}
@@ -445,7 +439,7 @@
{
auto flashId = versions.find(versionId)->second->path();
storePriority(flashId, value);
- helper.setEntry(versionId, value);
+ helper.setEntry(flashId, value);
}
void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
@@ -511,7 +505,8 @@
void ItemUpdater::removeReadOnlyPartition(std::string versionId)
{
- helper.removeVersion(versionId);
+ auto flashId = versions.find(versionId)->second->path();
+ helper.removeVersion(flashId);
}
bool ItemUpdater::fieldModeEnabled(bool value)
@@ -647,7 +642,8 @@
void ItemUpdater::updateUbootEnvVars(const std::string& versionId)
{
- helper.updateUbootVersionId(versionId);
+ auto flashId = versions.find(versionId)->second->path();
+ helper.updateUbootVersionId(flashId);
}
void ItemUpdater::resetUbootEnvVars()