pattern.cpp (d3bfa7bb99d0609657a13b8ec410eb4396607e58) pattern.cpp (82897c35761f505c2b881f72c61f726f7d562692)
1#include "pattern.hpp"
2
3#include "erase.hpp"
4
5#include <unistd.h>
6
7#include <phosphor-logging/lg2.hpp>
8#include <stdplus/fd/create.hpp>

--- 16 unchanged lines hidden (view full) ---

25using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
26using stdplus::fd::ManagedFd;
27
28void Pattern::writePattern(const uint64_t driveSize)
29{
30 // static seed defines a fixed prng sequnce so it can be verified later,
31 // and validated for entropy
32 uint64_t currentIndex = 0;
1#include "pattern.hpp"
2
3#include "erase.hpp"
4
5#include <unistd.h>
6
7#include <phosphor-logging/lg2.hpp>
8#include <stdplus/fd/create.hpp>

--- 16 unchanged lines hidden (view full) ---

25using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
26using stdplus::fd::ManagedFd;
27
28void Pattern::writePattern(const uint64_t driveSize)
29{
30 // static seed defines a fixed prng sequnce so it can be verified later,
31 // and validated for entropy
32 uint64_t currentIndex = 0;
33
34 // random number generator seeded with a constant value will
35 // generate a predictable sequence of values NOLINTNEXTLINE
33 std::minstd_rand0 generator(seed);
36 std::minstd_rand0 generator(seed);
34 std::array<std::byte, blockSize> randArr;
37 std::array<std::byte, blockSize> randArr{};
35
36 ManagedFd fd =
37 stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
38
39 while (currentIndex < driveSize)
40 {
41 // generate a 4k block of prng
42 std::array<uint32_t, blockSizeUsing32>* randArrFill =

--- 17 unchanged lines hidden (view full) ---

60 currentIndex = currentIndex + writeSize;
61 }
62}
63
64void Pattern::verifyPattern(const uint64_t driveSize)
65{
66
67 uint64_t currentIndex = 0;
38
39 ManagedFd fd =
40 stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
41
42 while (currentIndex < driveSize)
43 {
44 // generate a 4k block of prng
45 std::array<uint32_t, blockSizeUsing32>* randArrFill =

--- 17 unchanged lines hidden (view full) ---

63 currentIndex = currentIndex + writeSize;
64 }
65}
66
67void Pattern::verifyPattern(const uint64_t driveSize)
68{
69
70 uint64_t currentIndex = 0;
71 // random number generator seeded with a constant value will
72 // generate a predictable sequence of values NOLINTNEXTLINE
68 std::minstd_rand0 generator(seed);
73 std::minstd_rand0 generator(seed);
69 std::array<std::byte, blockSize> randArr;
70 std::array<std::byte, blockSize> readArr;
74 std::array<std::byte, blockSize> randArr{};
75 std::array<std::byte, blockSize> readArr{};
71
72 ManagedFd fd =
73 stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
74
75 while (currentIndex < driveSize)
76 {
77 size_t readSize = currentIndex + blockSize < driveSize
78 ? blockSize

--- 34 unchanged lines hidden ---
76
77 ManagedFd fd =
78 stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
79
80 while (currentIndex < driveSize)
81 {
82 size_t readSize = currentIndex + blockSize < driveSize
83 ? blockSize

--- 34 unchanged lines hidden ---