Change ownership of handle to eStorageD object
Clients used to create both the CryptHandle and the eStorageD objects
using the same information. Then the client would pass the CryptHandle
into eStorageD methods in order to perform crypto methods. This change
creates the CryptHandle closer to where it is used. This makes the code
simpler and easier to understand.
Tested:
busctl call xyz.openbmc_project.eStoraged.mmcblk0 \
> /xyz/openbmc_project/inventory/storage/mmcblk0 \
> xyz.openbmc_project.Inventory.Item.Volume FormatLuks ays 3 1 2 3 \
> xyz.openbmc_project.Inventory.Item.Volume.FilesystemType.ext4 \
> --timeout=60
Change-Id: I276e97146f4498191eb19512bc244a1e8d9cd2cb
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/include/cryptsetupInterface.hpp b/include/cryptsetupInterface.hpp
index 0fb0c32..5942b60 100644
--- a/include/cryptsetupInterface.hpp
+++ b/include/cryptsetupInterface.hpp
@@ -7,6 +7,7 @@
#include <xyz/openbmc_project/Common/error.hpp>
#include <string>
+#include <string_view>
namespace estoraged
{
@@ -222,7 +223,7 @@
*
* @param[in] device - path to device file
*/
- explicit CryptHandle(const char* device) : handle(init(device))
+ explicit CryptHandle(const std::string_view& device) : handle(init(device))
{}
/** @brief Get a pointer to the crypt_device struct. */
@@ -244,10 +245,10 @@
*
* @param[in] device - path to device file
*/
- struct crypt_device* init(const char* device)
+ struct crypt_device* init(const std::string_view& device)
{
struct crypt_device* cryptDev = nullptr;
- int retval = crypt_init(&cryptDev, device);
+ int retval = crypt_init(&cryptDev, device.data());
if (retval < 0)
{
lg2::error("Failed to crypt_init", "REDFISH_MESSAGE_ID",