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