Refactor findsize into util away from erase
At first the size was only needed for erase, now it is needed for the
drives interface. The code needed to be refactored to make drive
interface implementation possible.
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I0a23ee23a0de3fd89a9e776b4854e8da9a8ff2e4
diff --git a/include/zero.hpp b/include/zero.hpp
index e8675e8..00c2b38 100644
--- a/include/zero.hpp
+++ b/include/zero.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "erase.hpp"
+#include "util.hpp"
#include <stdplus/fd/create.hpp>
#include <stdplus/fd/managed.hpp>
@@ -19,21 +20,34 @@
*/
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] driveSize - the size of the block device in bytes
*/
void writeZero(uint64_t driveSize);
+ /** @brief writes zero to the drive
+ * and throws errors accordingly.
+ */
+ void writeZero()
+ {
+ writeZero(util::Util::findSizeOfBlockDevice(devPath));
+ }
+
/** @brief verifies the uncompressible random pattern is on the drive
* and throws errors accordingly.
- *
- * @param[in] bytes - Size of the block device
+ * @param[in] driveSize - the size of the block device in bytes
*/
void verifyZero(uint64_t driveSize);
+ /** @brief verifies the uncompressible random pattern is on the drive
+ * and throws errors accordingly.
+ */
+ void verifyZero()
+ {
+ verifyZero(util::Util::findSizeOfBlockDevice(devPath));
+ }
+
private:
/* @brief the size of the blocks in bytes used for write and verify.
* 32768 was also tested. It had almost identical performance.