xref: /openbmc/estoraged/include/pattern.hpp (revision 67a47446)
1 #pragma once
2 
3 #include "erase.hpp"
4 #include "util.hpp"
5 
6 #include <stdplus/fd/create.hpp>
7 #include <stdplus/fd/managed.hpp>
8 
9 #include <span>
10 #include <string>
11 
12 namespace estoraged
13 {
14 using stdplus::fd::ManagedFd;
15 
16 class 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
30      */
31     void writePattern()
32     {
33         writePattern(util::Util::findSizeOfBlockDevice(devPath));
34     }
35 
36     void writePattern(uint64_t driveSize);
37 
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
42      */
43 
44     void verifyPattern()
45     {
46         verifyPattern(util::Util::findSizeOfBlockDevice(devPath));
47     }
48     void verifyPattern(uint64_t driveSize);
49 };
50 
51 } // namespace estoraged
52