Add implementation capacity for drive interface
This will set the capacity property when the eStoraged object is
created. This change does not expect the drive size to change.
Change-Id: I72cd68c5045e9ef49939f4655a223a02234c7434
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/include/estoraged.hpp b/include/estoraged.hpp
index d14a007..3a4fb6c 100644
--- a/include/estoraged.hpp
+++ b/include/estoraged.hpp
@@ -8,6 +8,7 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
#include <sdbusplus/server/object.hpp>
+#include <util.hpp>
#include <xyz/openbmc_project/Inventory/Item/Drive/server.hpp>
#include <xyz/openbmc_project/Inventory/Item/Volume/server.hpp>
@@ -45,6 +46,7 @@
*/
EStoraged(sdbusplus::bus::bus& bus, const char* path,
const std::string& devPath, const std::string& luksName,
+ uint64_t size,
std::unique_ptr<CryptsetupInterface> cryptInterface =
std::make_unique<Cryptsetup>(),
std::unique_ptr<FilesystemInterface> fsInterface =
@@ -53,7 +55,9 @@
driveInherit(bus, path), devPath(devPath), containerName(luksName),
mountPoint("/mnt/" + luksName + "_fs"),
cryptIface(std::move(cryptInterface)), fsIface(std::move(fsInterface))
- {}
+ {
+ capacity(size);
+ }
/** @brief Format the LUKS encrypted device and create empty filesystem.
*
diff --git a/src/main.cpp b/src/main.cpp
index 0207079..82ffcdd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,7 @@
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
+#include <util.hpp>
#include <filesystem>
#include <iostream>
@@ -69,8 +70,9 @@
b.request_name(busName.c_str());
/* Create an eStoraged object. */
- estoraged::EStoraged esObject{b, path.c_str(), physicalBlockDev,
- containerBlockDev};
+ estoraged::EStoraged esObject{
+ b, path.c_str(), physicalBlockDev, containerBlockDev,
+ estoraged::util::Util::findSizeOfBlockDevice(physicalBlockDev)};
lg2::info("Storage management service is running", "REDFISH_MESSAGE_ID",
std::string("OpenBMC.1.0.ServiceStarted"));
diff --git a/src/test/estoraged_test.cpp b/src/test/estoraged_test.cpp
index e77d4c6..e7ad562 100644
--- a/src/test/estoraged_test.cpp
+++ b/src/test/estoraged_test.cpp
@@ -43,6 +43,7 @@
public:
const char* testFileName = "testfile";
const char* testLuksDevName = "testfile_luksDev";
+ uint64_t testSize = 24;
std::ofstream testFile;
std::unique_ptr<estoraged::EStoraged> esObject;
const char* testPath = "/test/openbmc_project/storage/test_dev";
@@ -97,8 +98,8 @@
mockFsIface = fsIface.get();
esObject = std::make_unique<estoraged::EStoraged>(
- bus, testPath, testFileName, testLuksDevName, std::move(cryptIface),
- std::move(fsIface));
+ bus, testPath, testFileName, testLuksDevName, testSize,
+ std::move(cryptIface), std::move(fsIface));
}
void TearDown() override