John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 1 | #pragma once |
John Wedig | d32b966 | 2022-04-13 18:12:25 -0700 | [diff] [blame^] | 2 | #include "getConfig.hpp" |
| 3 | |
| 4 | #include <filesystem> |
John Edward Broadbent | 5d799bb | 2022-03-22 16:14:24 -0700 | [diff] [blame] | 5 | #include <string> |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 6 | |
| 7 | namespace estoraged |
| 8 | { |
| 9 | namespace util |
| 10 | { |
| 11 | |
John Edward Broadbent | 5d799bb | 2022-03-22 16:14:24 -0700 | [diff] [blame] | 12 | /** @brief finds the size of the linux block device in bytes |
| 13 | * @param[in] devpath - the name of the linux block device |
| 14 | * @return size of a block device using the devPath |
| 15 | */ |
| 16 | uint64_t findSizeOfBlockDevice(const std::string& devPath); |
| 17 | |
| 18 | /** @brief finds the predicted life left for a eMMC device |
| 19 | * @param[in] sysfsPath - The path to the linux sysfs interface |
| 20 | * @return the life remaing for the emmc, as a percentage. |
| 21 | */ |
| 22 | uint8_t findPredictedMediaLifeLeftPercent(const std::string& sysfsPath); |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 23 | |
John Wedig | d32b966 | 2022-04-13 18:12:25 -0700 | [diff] [blame^] | 24 | /** @brief Look for the device described by the provided StorageData. |
| 25 | * @details Currently, this function assumes that there's only one eMMC. |
| 26 | * When we need to support multiple eMMCs, we will put more information in |
| 27 | * the EntityManager config, to differentiate between them. Also, if we |
| 28 | * want to support other types of storage devices, this function will need |
| 29 | * to be updated. |
| 30 | * |
| 31 | * @param[in] data - map of properties from the config object. |
| 32 | * @param[in] searchDir - directory to search for devices in sysfs, e.g. |
| 33 | * /sys/block |
| 34 | * @param[out] deviceFile - device file that was found, e.g. /dev/mmcblk0. |
| 35 | * @param[out] sysfsDir - directory containing the sysfs entries for this |
| 36 | * device. |
| 37 | * @param[out] luksName - name of the encrypted LUKS device. |
| 38 | * |
| 39 | * @return True if the device was found. False otherwise. |
| 40 | */ |
| 41 | bool findDevice(const StorageData& data, const std::filesystem::path& searchDir, |
| 42 | std::filesystem::path& deviceFile, |
| 43 | std::filesystem::path& sysfsDir, std::string& luksName); |
| 44 | |
John Edward Broadbent | a6e3b99 | 2022-03-17 14:33:15 -0700 | [diff] [blame] | 45 | } // namespace util |
| 46 | |
| 47 | } // namespace estoraged |