summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Kim <brandonkim@google.com>2019-10-18 15:15:50 -0700
committerBrandon Kim <brandonkim@google.com>2019-10-18 16:07:36 -0700
commit8fc6087670430363dbad5a45459a35ce48392497 (patch)
tree1adec4e723def8541d9bb2fb9585fe8869939e8e
parent6749ba1c93c9b4f65c9ef7791987fc2f98bc15d1 (diff)
downloadphosphor-ipmi-flash-8fc6087670430363dbad5a45459a35ce48392497.tar.gz
phosphor-ipmi-flash-8fc6087670430363dbad5a45459a35ce48392497.zip
bmc: Replace fileOpen flag
Instead of keeping track of a fileOpen flag, keep track of fileOpen using !lookup.empty() instead. Signed-off-by: Brandon Kim <brandonkim@google.com> Change-Id: I09d16479d2a52deae5e8d63582376a27a6a39bb5
-rw-r--r--bmc/firmware_handler.cpp12
-rw-r--r--bmc/firmware_handler.hpp8
-rw-r--r--ipmi_flash.md10
3 files changed, 14 insertions, 16 deletions
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index fede302..96b4eba 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -110,12 +110,12 @@ bool FirmwareBlobHandler::deleteBlob(const std::string& path)
* we cannot close an active session. To enforce this, we only allow
* deleting if there isn't a file open.
*/
- if (fileOpen)
+ if (fileOpen())
{
return false;
}
- /* only includes states where fileOpen == false */
+ /* only includes states where fileOpen() == false */
switch (state)
{
case UpdateState::notYetStarted:
@@ -315,7 +315,7 @@ bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
* verification process has begun -- which is done via commit() on the hash
* blob_id, we no longer want to allow updating the contents.
*/
- if (fileOpen)
+ if (fileOpen())
{
return false;
}
@@ -356,7 +356,7 @@ bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
break;
case UpdateState::verificationPending:
/* Handle opening the verifyBlobId --> we know the image and hash
- * aren't open because of the fileOpen check. They can still open
+ * aren't open because of the fileOpen() check. They can still open
* other files from this state to transition back into
* uploadInProgress.
*
@@ -369,7 +369,6 @@ bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
lookup[session] = &verifyImage;
- fileOpen = true;
return true;
}
break;
@@ -386,7 +385,6 @@ bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
lookup[session] = &updateImage;
- fileOpen = true;
return true;
}
else
@@ -516,7 +514,6 @@ bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
removeBlobId(verifyBlobId);
changeState(UpdateState::uploadInProgress);
- fileOpen = true;
return true;
}
@@ -753,7 +750,6 @@ bool FirmwareBlobHandler::close(uint16_t session)
}
lookup.erase(item);
- fileOpen = false;
return true;
}
diff --git a/bmc/firmware_handler.hpp b/bmc/firmware_handler.hpp
index 472bb8e..3a4b4be 100644
--- a/bmc/firmware_handler.hpp
+++ b/bmc/firmware_handler.hpp
@@ -210,6 +210,11 @@ class FirmwareBlobHandler : public blobs::GenericBlobInterface
blobIDs.end());
}
+ inline bool fileOpen()
+ {
+ return !lookup.empty();
+ }
+
ActionStatus getVerifyStatus();
ActionStatus getActionStatus();
@@ -252,9 +257,6 @@ class FirmwareBlobHandler : public blobs::GenericBlobInterface
bool preparationTriggered = false;
ActionMap actionPacks;
- /** Temporary variable to track whether a blob is open. */
- bool fileOpen = false;
-
ActionStatus lastVerificationStatus = ActionStatus::unknown;
ActionStatus lastUpdateStatus = ActionStatus::unknown;
diff --git a/ipmi_flash.md b/ipmi_flash.md
index f69d226..ef982d1 100644
--- a/ipmi_flash.md
+++ b/ipmi_flash.md
@@ -17,13 +17,13 @@ Opening the active image or hash always fails:
The two files are only present once their corresponding blob has been opened.
-# The state of fileOpen per state
+# The state of fileOpen() per state
You can only open one file at a time, and some of the states exist only when a
file is open.
-State | fileOpen
-:---------------------- | :-------
+State | fileOpen()
+:---------------------- | :---------
`notYetStarted` | `false`
`uploadInProgress` | `true`
`verificationPending` | `false`
@@ -49,7 +49,7 @@ State | fileOpen
**The BMC is expecting to receive bytes.**
-* `open(/flash/*)` returns false because `fileOpen == true`
+* `open(/flash/*)` returns false because `fileOpen() == true`
* `close(/flash/*)` triggers `state -> verificationPending`
@@ -95,7 +95,7 @@ State | fileOpen
**The update process has started.**
-* `open(/flash/*)`r eturns false because `fileOpen == true`
+* `open(/flash/*)`r eturns false because `fileOpen() == true`
## `updatedCompleted`
OpenPOWER on IntegriCloud