| #pragma once |
| |
| #include "erase.hpp" |
| #include "util.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] 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] 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. |
| */ |
| static constexpr size_t blockSize = 4096; |
| }; |
| |
| } // namespace estoraged |