firmare: start implementing session stat
Session-specific stat is a call required by the P2A bridge to allow the
host to configure its side of the equation.
Change-Id: I90570641cf9a6816fb91e8329582b882aef212cf
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 5578b18..fda533e 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -180,10 +180,37 @@
*/
bool FirmwareBlobHandler::stat(uint16_t session, struct BlobMeta* meta)
{
- /*
- * Return session specific information.
+ auto item = lookup.find(session);
+ if (item == lookup.end())
+ {
+ return false;
+ }
+
+ /* The blobState here relates to an active sesion, so we should return the
+ * flags used to open this session.
*/
- return false;
+ meta->blobState = item->second->flags;
+ /* The size here refers to the size of the file -- of something analagous.
+ */
+ meta->size = item->second->imageHandler->getSize();
+
+ /* The metadata blob returned comes from the data handler... it's used for
+ * instance, in P2A bridging to get required information about the mapping,
+ * and is the "opposite" of the lpc writemeta requirement.
+ */
+ meta->metadata.clear();
+ if (item->second->dataHandler)
+ {
+ auto bytes = item->second->dataHandler->read();
+ meta->metadata.insert(meta->metadata.begin(), bytes.begin(),
+ bytes.end());
+ }
+
+ /* TODO: During things like verification, etc, we can report the state as
+ * committed, etc, so we'll need to do that.
+ */
+
+ return true;
}
/*