John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "erase.hpp" |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 4 | #include "util.hpp" |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 5 | |
| 6 | #include <string_view> |
| 7 | |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 8 | namespace estoraged |
| 9 | { |
| 10 | |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 11 | class VerifyDriveGeometry : public Erase |
| 12 | { |
| 13 | public: |
| 14 | /** @brief Creates a verifyDriveGeomentry erase object. |
| 15 | * |
| 16 | * @param[in] inDevPath - the linux device path for the block device. |
| 17 | */ |
Patrick Williams | 04c28fa | 2023-05-10 07:51:24 -0500 | [diff] [blame] | 18 | VerifyDriveGeometry(std::string_view inDevPath) : Erase(inDevPath) {} |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 19 | |
| 20 | /** @brief Test if input is in between the max and min expected sizes, |
| 21 | * and throws errors accordingly. |
| 22 | * |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 23 | * @param[in] eraseMaxGeometry - the max expected size to erase. |
| 24 | * @param[in] eraseMinGeometry - the min expected size to erase. |
| 25 | * @param[in] bytes - Size of the block device. |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 26 | */ |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 27 | void geometryOkay(uint64_t eraseMaxGeometry, uint64_t eraseMinGemoetry) |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 28 | { |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 29 | geometryOkay(eraseMaxGeometry, eraseMinGemoetry, |
| 30 | util::findSizeOfBlockDevice(devPath)); |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 31 | } |
Tom Tung | 043af59 | 2023-11-24 13:37:05 +0800 | [diff] [blame] | 32 | void geometryOkay(uint64_t eraseMaxGeometry, uint64_t eraseMinGemoetry, |
| 33 | uint64_t bytes); |
John Edward Broadbent | e6ffe70 | 2021-10-14 14:03:11 -0700 | [diff] [blame] | 34 | }; |
John Edward Broadbent | d3bfa7b | 2022-01-13 17:41:32 -0800 | [diff] [blame] | 35 | |
| 36 | } // namespace estoraged |