xref: /openbmc/estoraged/include/verifyDriveGeometry.hpp (revision 043af59f7fadce9b7e3872d91b1a0e841fc24cea)
1e6ffe704SJohn Edward Broadbent #pragma once
2e6ffe704SJohn Edward Broadbent 
3e6ffe704SJohn Edward Broadbent #include "erase.hpp"
4a6e3b99dSJohn Edward Broadbent #include "util.hpp"
5e6ffe704SJohn Edward Broadbent 
6e6ffe704SJohn Edward Broadbent #include <string_view>
7e6ffe704SJohn Edward Broadbent 
8d3bfa7bbSJohn Edward Broadbent namespace estoraged
9d3bfa7bbSJohn Edward Broadbent {
10d3bfa7bbSJohn Edward Broadbent 
11e6ffe704SJohn Edward Broadbent class VerifyDriveGeometry : public Erase
12e6ffe704SJohn Edward Broadbent {
13e6ffe704SJohn Edward Broadbent   public:
14e6ffe704SJohn Edward Broadbent     /** @brief Creates a verifyDriveGeomentry erase object.
15e6ffe704SJohn Edward Broadbent      *
16e6ffe704SJohn Edward Broadbent      *  @param[in] inDevPath - the linux device path for the block device.
17e6ffe704SJohn Edward Broadbent      */
VerifyDriveGeometry(std::string_view inDevPath)1804c28fadSPatrick Williams     VerifyDriveGeometry(std::string_view inDevPath) : Erase(inDevPath) {}
19e6ffe704SJohn Edward Broadbent 
20e6ffe704SJohn Edward Broadbent     /** @brief Test if input is in between the max and min expected sizes,
21e6ffe704SJohn Edward Broadbent      * and throws errors accordingly.
22e6ffe704SJohn Edward Broadbent      *
23*043af59fSTom Tung      *  @param[in] eraseMaxGeometry - the max expected size to erase.
24*043af59fSTom Tung      *  @param[in] eraseMinGeometry - the min expected size to erase.
25*043af59fSTom Tung      *  @param[in] bytes - Size of the block device.
26e6ffe704SJohn Edward Broadbent      */
geometryOkay(uint64_t eraseMaxGeometry,uint64_t eraseMinGemoetry)27*043af59fSTom Tung     void geometryOkay(uint64_t eraseMaxGeometry, uint64_t eraseMinGemoetry)
28a6e3b99dSJohn Edward Broadbent     {
29*043af59fSTom Tung         geometryOkay(eraseMaxGeometry, eraseMinGemoetry,
30*043af59fSTom Tung                      util::findSizeOfBlockDevice(devPath));
31a6e3b99dSJohn Edward Broadbent     }
32*043af59fSTom Tung     void geometryOkay(uint64_t eraseMaxGeometry, uint64_t eraseMinGemoetry,
33*043af59fSTom Tung                       uint64_t bytes);
34e6ffe704SJohn Edward Broadbent };
35d3bfa7bbSJohn Edward Broadbent 
36d3bfa7bbSJohn Edward Broadbent } // namespace estoraged
37