Delete the pnor version that doesn't have a valid pnor.toc
- When a pnor ro volume is corrupted, it no longer has a valid
pnor.toc. This had caused the Host.Updater service to core-dump.
We need to delete corrupted volumes in order to prevent such
versions from filling up the space on chip.
Resolves openbmc/openbmc#2359
Change-Id: I173409b03f9f7a38fb30e4c8b2eac19064cece70
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index e9a283d..7692293 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -164,12 +164,16 @@
if (0 == iter.path().native().compare(0, PNOR_RO_PREFIX_LEN,
PNOR_RO_PREFIX))
{
+ // The versionId is extracted from the path
+ // for example /media/pnor-ro-2a1022fe.
+ auto id = iter.path().native().substr(PNOR_RO_PREFIX_LEN);
auto pnorTOC = iter.path() / PNOR_TOC_FILE;
if (!fs::is_regular_file(pnorTOC))
{
- log<level::ERR>("Failed to read pnorTOC\n",
+ log<level::ERR>("Failed to read pnorTOC.\n",
entry("FileName=%s", pnorTOC.string()));
- activationState = server::Activation::Activations::Invalid;
+ ItemUpdater::erase(id);
+ continue;
}
auto keyValues =
Version::getValue(pnorTOC,
@@ -191,9 +195,6 @@
activationState = server::Activation::Activations::Invalid;
}
- // The versionId is extracted from the path
- // for example /media/pnor-ro-2a1022fe
- auto id = iter.path().native().substr(PNOR_RO_PREFIX_LEN);
auto purpose = server::Version::VersionPurpose::Host;
auto path = fs::path(SOFTWARE_OBJPATH) / id;
AssociationList associations = {};