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/estoraged.cpp b/src/estoraged.cpp
index dcbb524..4e64ca6 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -2,6 +2,7 @@
#include "estoraged.hpp"
#include "cryptsetupInterface.hpp"
+#include "verifyDriveGeometry.hpp"
#include <libcryptsetup.h>
#include <openssl/rand.h>
@@ -15,6 +16,8 @@
#include <string_view>
#include <vector>
+using sdbusplus::xyz::openbmc_project::eStoraged::Error::EraseError;
+
namespace estoraged
{
@@ -42,11 +45,49 @@
mountFilesystem();
}
-void eStoraged::erase(std::vector<uint8_t>, EraseMethod)
+void eStoraged::erase(std::vector<uint8_t>, EraseMethod inEraseMethod)
{
std::cerr << "Erasing encrypted eMMC" << std::endl;
- std::string msg = "OpenBMC.0.1.DriveErase";
- lg2::info("Starting erase", "REDFISH_MESSAGE_ID", msg);
+ lg2::info("Starting erase", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DriveErase"));
+ switch (inEraseMethod)
+ {
+ case EraseMethod::CryptoErase:
+ {
+ break;
+ }
+ case EraseMethod::VerifyGeometry:
+ {
+ VerifyDriveGeometry myVerifyGeometry(devPath);
+ uint64_t size = myVerifyGeometry.findSizeOfBlockDevice();
+ myVerifyGeometry.geometryOkay(size);
+ break;
+ }
+ case EraseMethod::LogicalOverWrite:
+ {
+ break;
+ }
+ case EraseMethod::LogicalVerify:
+ {
+ break;
+ }
+ case EraseMethod::VendorSanitize:
+ {
+ break;
+ }
+ case EraseMethod::ZeroOverWrite:
+ {
+ break;
+ }
+ case EraseMethod::ZeroVerify:
+ {
+ break;
+ }
+ case EraseMethod::SecuredLocked:
+ {
+ break;
+ }
+ }
}
void eStoraged::lock(std::vector<uint8_t>)
@@ -79,8 +120,8 @@
void eStoraged::changePassword(std::vector<uint8_t>, std::vector<uint8_t>)
{
std::cerr << "Changing password for encrypted eMMC" << std::endl;
- std::string msg = "OpenBMC.0.1.DrivePasswordChanged";
- lg2::info("Starting change password", "REDFISH_MESSAGE_ID", msg);
+ lg2::info("Starting change password", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DrivePasswordChanged"));
}
bool eStoraged::isLocked() const