Add zero write and verify

This code implements the zero verify and zero write dbus interface. The
goal is to fill the whole block device with zeros, then check to make
sure the operation worked correctly.

Tested:
$ systemctl stop emmc.service
$ ./eStoraged -b /dev/mmcblk0 &
$ time 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.ZeroOverWrite --timeout=1200
Erasing encrypted eMMC                                                                                                                                                   <6> Starting erase

real    5m59.695s
user    0m0.000s
sys     0m0.030s

root@ytbaz20-nfd01:~/jebr# hexdump /dev/mmcblk0
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
$ time 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.ZeroVerify  --timeout=1200
Erasing encrypted eMMC
<6> Starting erase

real    5m46.920s
user    0m0.010s
sys     0m0.010s
$ echo "not zero" > /dev/mmcblk0
$ time 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.ZeroVerify  --timeout=1200
Erasing encrypted eMMC
<6> Starting erase
<3> Estoraged erase zeros block is not zero
Call failed: The operation failed internally.

real    0m0.022s
user    0m0.000s
sys     0m0.020s

Change-Id: Ie78ad427de1aa75472fc7ddd72d094866fe14b66
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/include/zero.hpp b/include/zero.hpp
new file mode 100644
index 0000000..b6ca93f
--- /dev/null
+++ b/include/zero.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "erase.hpp"
+
+#include <stdplus/fd/create.hpp>
+#include <stdplus/fd/managed.hpp>
+
+namespace estoraged
+{
+
+using stdplus::fd::ManagedFd;
+
+class Zero : public Erase
+{
+  public:
+    /** @brief Creates a zero erase object.
+     *
+     *  @param[in] inDevPath - the linux device path for the block device.
+     */
+    Zero(std::string_view inDevPath) : Erase(inDevPath)
+    {}
+
+    /** @brief writes zero to the drive
+     * and throws errors accordingly.
+     *
+     *  @param[in] bytes - Size of the block device
+     *  @param[in] managedFd - the file descriptor for the open drive
+     */
+    void writeZero(uint64_t driveSize, ManagedFd& fd);
+
+    /** @brief verifies the  uncompressible random pattern is on the drive
+     * and throws errors accordingly.
+     *
+     *  @param[in] bytes - Size of the block device
+     *  @param[in] managedFd - the file descriptor for the open drive
+     */
+    void verifyZero(uint64_t driveSize, ManagedFd& fd);
+
+  private:
+    /* @brief the size of the blocks in bytes used for write and verify.
+     * 32768 was also tested. It had almost identical performance.
+     */
+    static constexpr size_t blockSize = 4096;
+};
+
+} // namespace estoraged