Static layout: Do not update PNOR when host is on

Static layout only has 1 active and functional PNOR. When host is
running, do not update PNOR.
This is done by checking the return value of freeSpace(), and if it
returns false, it means there is no space for PNOR because the host is
running and erase() returns false.

Tested: Verify the status becomes Failed when trying to activate a PNOR
        while host is running.

Change-Id: Ie2986b0c6fd29557685f67eb77ccc29709e1669a
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/ubi/item_updater_ubi.cpp b/ubi/item_updater_ubi.cpp
index 875847f..61a8e01 100644
--- a/ubi/item_updater_ubi.cpp
+++ b/ubi/item_updater_ubi.cpp
@@ -357,8 +357,9 @@
 }
 
 // TODO: openbmc/openbmc#1402 Monitor flash usage
-void ItemUpdaterUbi::freeSpace()
+bool ItemUpdaterUbi::freeSpace()
 {
+    bool isSpaceFreed = false;
     //  Versions with the highest priority in front
     std::priority_queue<std::pair<int, std::string>,
                         std::vector<std::pair<int, std::string>>,
@@ -393,7 +394,9 @@
         erase(versionsPQ.top().second);
         versionsPQ.pop();
         count--;
+        isSpaceFreed = true;
     }
+    return isSpaceFreed;
 }
 
 std::string ItemUpdaterUbi::determineId(const std::string& symlinkPath)
diff --git a/ubi/item_updater_ubi.hpp b/ubi/item_updater_ubi.hpp
index 5de51d3..ce1b5b8 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -35,7 +35,7 @@
 
     void deleteAll() override;
 
-    void freeSpace() override;
+    bool freeSpace() override;
 
     bool isVersionFunctional(const std::string& versionId) override;