John Edward Broadbent | 4bc8a10 | 2021-12-30 16:11:49 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "erase.hpp" |
| 4 | |
| 5 | #include <stdplus/fd/create.hpp> |
| 6 | #include <stdplus/fd/managed.hpp> |
| 7 | |
| 8 | namespace estoraged |
| 9 | { |
| 10 | |
| 11 | using stdplus::fd::ManagedFd; |
| 12 | |
| 13 | class Zero : public Erase |
| 14 | { |
| 15 | public: |
| 16 | /** @brief Creates a zero erase object. |
| 17 | * |
| 18 | * @param[in] inDevPath - the linux device path for the block device. |
| 19 | */ |
| 20 | Zero(std::string_view inDevPath) : Erase(inDevPath) |
| 21 | {} |
| 22 | |
| 23 | /** @brief writes zero to the drive |
| 24 | * and throws errors accordingly. |
| 25 | * |
| 26 | * @param[in] bytes - Size of the block device |
John Edward Broadbent | 4bc8a10 | 2021-12-30 16:11:49 -0800 | [diff] [blame] | 27 | */ |
John Edward Broadbent | 6978676 | 2022-01-21 14:16:23 -0800 | [diff] [blame] | 28 | void writeZero(uint64_t driveSize); |
John Edward Broadbent | 4bc8a10 | 2021-12-30 16:11:49 -0800 | [diff] [blame] | 29 | |
| 30 | /** @brief verifies the uncompressible random pattern is on the drive |
| 31 | * and throws errors accordingly. |
| 32 | * |
| 33 | * @param[in] bytes - Size of the block device |
John Edward Broadbent | 4bc8a10 | 2021-12-30 16:11:49 -0800 | [diff] [blame] | 34 | */ |
John Edward Broadbent | 6978676 | 2022-01-21 14:16:23 -0800 | [diff] [blame] | 35 | void verifyZero(uint64_t driveSize); |
John Edward Broadbent | 4bc8a10 | 2021-12-30 16:11:49 -0800 | [diff] [blame] | 36 | |
| 37 | private: |
| 38 | /* @brief the size of the blocks in bytes used for write and verify. |
| 39 | * 32768 was also tested. It had almost identical performance. |
| 40 | */ |
| 41 | static constexpr size_t blockSize = 4096; |
| 42 | }; |
| 43 | |
| 44 | } // namespace estoraged |