flash-ipmi: implement flashStartHash
Change-Id: Ia134b1faef99510bbed5eb4e36dada164c010305
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/flash-ipmi.cpp b/flash-ipmi.cpp
index 42333dd..f58363b 100644
--- a/flash-ipmi.cpp
+++ b/flash-ipmi.cpp
@@ -47,6 +47,7 @@
void FlashUpdate::closeEverything()
{
closeFile(&flashFd);
+ closeFile(&hashFd);
}
FlashUpdate::~FlashUpdate()
@@ -76,6 +77,19 @@
return false;
}
+ /* hash path is basically optional. */
+ if (!hashPath.empty())
+ {
+ hashFd = std::fopen(hashPath.c_str(), "wb");
+ if (hashFd == nullptr)
+ {
+ log<level::INFO>("Unable to open hash storage path",
+ entry("PATH=%s", hashPath.c_str()));
+ closeFile(&flashFd);
+ return false;
+ }
+ }
+
return true;
}
@@ -141,8 +155,13 @@
bool FlashUpdate::startHash(uint32_t length)
{
- /* TODO: implement. */
- return false;
+ if (!hashFd)
+ {
+ return false;
+ }
+
+ hashLength = length;
+ return true;
}
bool FlashUpdate::hashData(uint32_t offset, const std::vector<uint8_t>& bytes)