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/src/main.cpp b/src/main.cpp
index e5f9d09..088d693 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,6 +19,7 @@
#include <filesystem>
#include <iostream>
#include <memory>
+#include <optional>
#include <string>
/*
@@ -69,12 +70,8 @@
/* Look for the device file. */
const std::filesystem::path blockDevDir{"/sys/block"};
- std::filesystem::path deviceFile, sysfsDir;
- std::string luksName, locationCode;
- bool found = estoraged::util::findDevice(data, blockDevDir,
- deviceFile, sysfsDir,
- luksName, locationCode);
- if (!found)
+ auto deviceInfo = estoraged::util::findDevice(data, blockDevDir);
+ if (!deviceInfo)
{
lg2::error("Device not found for path {PATH}", "PATH", path,
"REDFISH_MESSAGE_ID",
@@ -87,6 +84,14 @@
continue;
}
+ std::filesystem::path deviceFile =
+ std::move(deviceInfo->deviceFile);
+ std::filesystem::path sysfsDir = std::move(deviceInfo->sysfsDir);
+ std::string luksName = std::move(deviceInfo->luksName);
+ std::string locationCode = std::move(deviceInfo->locationCode);
+ uint64_t eraseMaxGeometry = deviceInfo->eraseMaxGeometry;
+ uint64_t eraseMinGeometry = deviceInfo->eraseMinGeometry;
+
uint64_t size = estoraged::util::findSizeOfBlockDevice(deviceFile);
uint8_t lifeleft =
@@ -97,7 +102,8 @@
/* Create the storage object. */
storageObjects[path] = std::make_unique<estoraged::EStoraged>(
objectServer, path, deviceFile, luksName, size, lifeleft,
- partNumber, serialNumber, locationCode);
+ partNumber, serialNumber, locationCode, eraseMaxGeometry,
+ eraseMinGeometry);
lg2::info("Created eStoraged object for path {PATH}", "PATH", path,
"REDFISH_MESSAGE_ID",
std::string("OpenBMC.0.1.CreateStorageObjects"));