Add Erase verifyGeometry
This confirms specified amount of the drive is accessible. The min and
max expected drive size are set as a build configuration, and compared
against the drive size (found by using the linux ioctl). Also adds
testing build files, testing options, and verifyGeometry test.
Tested: Ran eStoraged on a machine with an eMMC, using the following
$ ./eStoraged -b /dev/mmcblk0 &
$ busctl call xyz.openbmc_project.eStoraged.mmcblk0 \
/xyz/openbmc_project/storage/mmcblk0 \
xyz.openbmc_project.eStoraged Erase ays 1 1 \
xyz.openbmc_project.eStoraged.EraseMethod.VerifyGeometry
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: Ie47f8666996a6085a115d1b86f2643bc278638c5
diff --git a/src/erase/verifyDriveGeometry.cpp b/src/erase/verifyDriveGeometry.cpp
new file mode 100644
index 0000000..2996912
--- /dev/null
+++ b/src/erase/verifyDriveGeometry.cpp
@@ -0,0 +1,38 @@
+#include "verifyDriveGeometry.hpp"
+
+#include "estoraged_conf.hpp"
+
+#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/eStoraged/error.hpp>
+
+#include <string>
+
+using sdbusplus::xyz::openbmc_project::eStoraged::Error::EraseError;
+
+void VerifyDriveGeometry::geometryOkay(uint64_t bytes)
+{
+ if (bytes > ERASE_MAX_GEOMETRY)
+ {
+ lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DriveEraseFailure"),
+ "REDFISH_MESSAGE_ARGS",
+ std::to_string(bytes) + ">" +
+ std::to_string(ERASE_MAX_GEOMETRY));
+ throw EraseError();
+ }
+ else if (bytes < ERASE_MIN_GEOMETRY)
+ {
+ lg2::error(
+ "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DriveEraseFailure"),
+ "REDFISH_MESSAGE_ARGS",
+ std::to_string(bytes) + "<" + std::to_string(ERASE_MIN_GEOMETRY));
+ throw EraseError();
+ }
+ else
+ {
+ lg2::info("eStorageD erase verify Geometry in range",
+ "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DriveEraseSuccess"));
+ }
+}