Get eraseMaxGeometry and eraseMinGeometry from dbus
Also, make findDevice return output parameters based on RVO.
With the change like in EntityManager JSON:
```
{
"Name": "example_emmc",
"Type": "EmmcDevice",
"LocationCode": "location"
"EraseMaxGeometry": 10000000000,
"EraseMinGeometry": 5000000000,
}
```
and geometry values will be set to estoraged.
Tested:
- unit test pass:
```
5/7 util_test OK 0.05s
```
Change-Id: Ia8499af2168c7e740558978273fc80456eb29282
Signed-off-by: Tom Tung <shes050117@gmail.com>
diff --git a/include/util.hpp b/include/util.hpp
index ff38cdd..8f5a0ff 100644
--- a/include/util.hpp
+++ b/include/util.hpp
@@ -2,6 +2,7 @@
#include "getConfig.hpp"
#include <filesystem>
+#include <optional>
#include <string>
namespace estoraged
@@ -9,6 +10,25 @@
namespace util
{
+struct DeviceInfo
+{
+ std::filesystem::path deviceFile;
+ std::filesystem::path sysfsDir;
+ std::string luksName;
+ std::string locationCode;
+ uint64_t eraseMaxGeometry;
+ uint64_t eraseMinGeometry;
+
+ DeviceInfo(std::filesystem::path& deviceFile,
+ std::filesystem::path& sysfsDir, std::string& luksName,
+ std::string& locationCode, uint64_t eraseMaxGeometry,
+ uint64_t eraseMinGeometry) :
+ deviceFile(deviceFile),
+ sysfsDir(sysfsDir), luksName(luksName), locationCode(locationCode),
+ eraseMaxGeometry(eraseMaxGeometry), eraseMinGeometry(eraseMinGeometry)
+ {}
+};
+
/** @brief finds the size of the linux block device in bytes
* @param[in] devpath - the name of the linux block device
* @return size of a block device using the devPath
@@ -43,17 +63,11 @@
* @param[in] data - map of properties from the config object.
* @param[in] searchDir - directory to search for devices in sysfs, e.g.
* /sys/block
- * @param[out] deviceFile - device file that was found, e.g. /dev/mmcblk0.
- * @param[out] sysfsDir - directory containing the sysfs entries for this
- * device.
- * @param[out] luksName - name of the encrypted LUKS device.
- *
- * @return True if the device was found. False otherwise.
+ * @return DeviceInfo - metadata for the device if device is found. Null
+ * otherwise.
*/
-bool findDevice(const StorageData& data, const std::filesystem::path& searchDir,
- std::filesystem::path& deviceFile,
- std::filesystem::path& sysfsDir, std::string& luksName,
- std::string& locationCode);
+std::optional<DeviceInfo> findDevice(const StorageData& data,
+ const std::filesystem::path& searchDir);
} // namespace util