Add pattern write and verify to erase
The goals are to write a non-compressible and verifiable pattern to the
drive as a means to validate that the drive is working, and ensure all
blocks have been overwritten.
Tested:
$ systemctl stop emmc.service
$ ./eStoraged -b /dev/mmcblk0&
$busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Erase s xyz.openbmc_project.Inventory.Item.Volume.EraseMethod.LogicalOverWrite --timeout=1200
$busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Erase s xyz.openbmc_project.Inventory.Item.Volume.EraseMethod.LogicalVerify --timeout=1200
$echo "jebr" > /dev/mmcblk0
$busctl call xyz.openbmc_project.eStoraged.mmcblk0 /xyz/openbmc_project/storage/mmcblk0 xyz.openbmc_project.Inventory.Item.Volume Erase s xyz.openbmc_project.Inventory.Item.Volume.EraseMethod.LogicalVerify --timeout=1200
Call failed: The operation failed internally.
Change-Id: Ibc1254279b1f46246eb37056ea6e4e1a57159bb9
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index 91a7f12..777232a 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -2,6 +2,7 @@
#include "estoraged.hpp"
#include "cryptsetupInterface.hpp"
+#include "pattern.hpp"
#include "verifyDriveGeometry.hpp"
#include <libcryptsetup.h>
@@ -70,10 +71,20 @@
}
case EraseMethod::LogicalOverWrite:
{
+ Pattern myErasePattern(devPath);
+ ManagedFd drivefd =
+ stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
+ myErasePattern.writePattern(myErasePattern.findSizeOfBlockDevice(),
+ drivefd);
break;
}
case EraseMethod::LogicalVerify:
{
+ Pattern myErasePattern(devPath);
+ ManagedFd drivefd =
+ stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
+ myErasePattern.verifyPattern(myErasePattern.findSizeOfBlockDevice(),
+ drivefd);
break;
}
case EraseMethod::VendorSanitize: