summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-09-20 12:51:28 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-09-29 14:49:11 +0000
commit2badd7a655605734bda5199f1631ff11f18e58e2 (patch)
treed21e7b33301ad4e981a9a160577903bcc3622599
parent139cf1a1d85ac459b9adad1bccfc45c0cec5e2bf (diff)
downloadopenpower-pnor-code-mgmt-2badd7a655605734bda5199f1631ff11f18e58e2.tar.gz
openpower-pnor-code-mgmt-2badd7a655605734bda5199f1631ff11f18e58e2.zip
Create functional association on startup
Look at /var/lib/phosphor-software-manager/pnor/ro to determine if there is a funcitonal image, if so create a functional association. Resolves openbmc/openbmc#2279 Change-Id: I6e576e2e21a592a98d843eb45cdab8bba8f55192 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--item_updater.cpp27
-rwxr-xr-xitem_updater.hpp8
-rw-r--r--watch.cpp8
3 files changed, 37 insertions, 6 deletions
diff --git a/item_updater.cpp b/item_updater.cpp
index 261b9d6d8..b45193236 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -250,6 +250,13 @@ void ItemUpdater::processPNORImage()
*this)));
}
}
+
+ // Look at the RO symlink to determine if there is a functional image
+ auto id = determineId(PNOR_RO_ACTIVE_PATH);
+ if (!id.empty())
+ {
+ updateFunctionalAssociation(std::string{SOFTWARE_OBJPATH} + '/' + id);
+ }
return;
}
@@ -559,6 +566,26 @@ void ItemUpdater::removeActiveAssociation(std::string path)
}
}
+std::string ItemUpdater::determineId(const std::string& symlinkPath)
+{
+ if (!fs::exists(symlinkPath))
+ {
+ return {};
+ }
+
+ auto target = fs::canonical(symlinkPath).string();
+
+ // check to make sure the target really exists
+ if (!fs::is_regular_file(target + "/" + PNOR_TOC_FILE))
+ {
+ return {};
+ }
+ // Get the image <id> from the symlink target
+ // for example /media/ro-2a1022fe
+ static const auto PNOR_RO_PREFIX_LEN = strlen(PNOR_RO_PREFIX);
+ return target.substr(PNOR_RO_PREFIX_LEN);
+}
+
} // namespace updater
} // namespace software
} // namespace openpower
diff --git a/item_updater.hpp b/item_updater.hpp
index 7f9a88b6f..1c65a1c06 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -91,6 +91,14 @@ class ItemUpdater : public ItemUpdaterInherit
*/
void freeSpace();
+ /** @brief Determine the software version id
+ * from the symlink target (e.g. /media/ro-2a1022fe).
+ *
+ * @param[in] symlinkPath - The path of the symlink.
+ * @param[out] id - The version id as a string.
+ */
+ static std::string determineId(const std::string& symlinkPath);
+
/** @brief Creates an active association to the
* newly active software image
*
diff --git a/watch.cpp b/watch.cpp
index da06bbc1e..2212e01a3 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -8,6 +8,7 @@
#include <phosphor-logging/log.hpp>
#include "config.h"
#include "watch.hpp"
+#include "item_updater.hpp"
namespace openpower
{
@@ -97,12 +98,7 @@ int Watch::callback(sd_event_source* s,
path /= event->name;
if (fs::equivalent(path, PNOR_RO_ACTIVE_PATH))
{
- auto target = fs::canonical(path).string();
-
- // Get the image <id> from the symlink target
- // for example /media/ro-2a1022fe
- static const auto PNOR_RO_PREFIX_LEN = strlen(PNOR_RO_PREFIX);
- auto id = target.substr(PNOR_RO_PREFIX_LEN);
+ auto id = ItemUpdater::determineId(path);
auto objPath = std::string{SOFTWARE_OBJPATH} + '/' + id;
static_cast<Watch*>(userdata)->functionalCallback(objPath);
OpenPOWER on IntegriCloud