blob: 4def784fc80567c6c37f106696fec68d9361a3fa [file] [log] [blame]
John Edward Broadbent7f2ab642021-11-11 21:00:38 -08001#pragma once
2
3#include "erase.hpp"
John Edward Broadbenta6e3b992022-03-17 14:33:15 -07004#include "util.hpp"
John Edward Broadbent7f2ab642021-11-11 21:00:38 -08005
6#include <stdplus/fd/create.hpp>
7#include <stdplus/fd/managed.hpp>
8
9#include <span>
10#include <string>
11
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080012namespace estoraged
13{
John Edward Broadbent7f2ab642021-11-11 21:00:38 -080014using stdplus::fd::ManagedFd;
15
16class Pattern : public Erase
17{
18 public:
19 /** @brief Creates a pattern erase object.
20 *
21 * @param[in] inDevPath - the linux device path for the block device.
22 */
23 Pattern(std::string_view inDevPath) : Erase(inDevPath)
24 {}
25
26 /** @brief writes an uncompressible random pattern to the drive
27 * and throws errors accordingly.
28 *
29 * @param[in] bytes - Size of the block device
John Edward Broadbent7f2ab642021-11-11 21:00:38 -080030 */
John Edward Broadbenta6e3b992022-03-17 14:33:15 -070031 void writePattern()
32 {
33 writePattern(util::Util::findSizeOfBlockDevice(devPath));
34 }
35
John Edward Broadbent69786762022-01-21 14:16:23 -080036 void writePattern(uint64_t driveSize);
John Edward Broadbent7f2ab642021-11-11 21:00:38 -080037
38 /** @brief verifies the uncompressible random pattern is on the drive
39 * and throws errors accordingly.
40 *
41 * @param[in] bytes - Size of the block device
John Edward Broadbent7f2ab642021-11-11 21:00:38 -080042 */
John Edward Broadbenta6e3b992022-03-17 14:33:15 -070043
44 void verifyPattern()
45 {
46 verifyPattern(util::Util::findSizeOfBlockDevice(devPath));
47 }
John Edward Broadbent69786762022-01-21 14:16:23 -080048 void verifyPattern(uint64_t driveSize);
John Edward Broadbent7f2ab642021-11-11 21:00:38 -080049};
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080050
51} // namespace estoraged