firmware: tie in call to data handler's open
A data handler can implement an open/close that is called during those
actions on the larger blob_id element. This is meant to allow a
possible configure step for a driver on the BMC-side.
Change-Id: I62efa762d2efb8b2140b9856819554fbf577405a
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index fc4438e..10f427a 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -158,7 +158,9 @@
bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
const std::string& path)
{
- /* Check that they've opened for writing - read back not supported. */
+ /* Check that they've opened for writing - read back not currently
+ * supported.
+ */
if ((flags & OpenFlags::write) == 0)
{
return false;
@@ -171,6 +173,7 @@
}
/* Is there an open session already? We only allow one at a time.
+ *
* TODO: Temporarily using a simple boolean flag until there's a full
* session object to check.
*
@@ -246,6 +249,19 @@
active = &activeImageBlobID;
}
+ /* Elsewhere I do this check by checking "if ::ipmi" because that's the
+ * only non-external data pathway -- but this is just a more generic
+ * approach to that.
+ */
+ if (d->handler)
+ {
+ /* If the data handler open call fails, open fails. */
+ if (!d->handler->open())
+ {
+ return false;
+ }
+ }
+
/* 2d) are they opening the /flash/tarball ? (to start the UBI process)
* 2e) are they opening the /flash/image ? (to start the process)
* 2...) are they opening the /flash/... ? (to start the process)