estoraged.cpp (0cec4286e4b83d48e7e0b2cb6971443b61a7fcf8) | estoraged.cpp (15b63e12bdc3f3116fb841349dd4f1cd17a8398b) |
---|---|
1 2#include "estoraged.hpp" 3 4#include "cryptErase.hpp" 5#include "cryptsetupInterface.hpp" 6#include "pattern.hpp" 7#include "sanitize.hpp" 8#include "verifyDriveGeometry.hpp" --- 18 unchanged lines hidden (view full) --- 27{ 28 29using Association = std::tuple<std::string, std::string, std::string>; 30using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 31using sdbusplus::xyz::openbmc_project::Common::Error::UnsupportedRequest; 32using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Drive; 33using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume; 34 | 1 2#include "estoraged.hpp" 3 4#include "cryptErase.hpp" 5#include "cryptsetupInterface.hpp" 6#include "pattern.hpp" 7#include "sanitize.hpp" 8#include "verifyDriveGeometry.hpp" --- 18 unchanged lines hidden (view full) --- 27{ 28 29using Association = std::tuple<std::string, std::string, std::string>; 30using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 31using sdbusplus::xyz::openbmc_project::Common::Error::UnsupportedRequest; 32using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Drive; 33using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume; 34 |
35EStoraged::EStoraged(sdbusplus::asio::object_server& server, 36 const std::string& configPath, const std::string& devPath, 37 const std::string& luksName, uint64_t size, 38 uint8_t lifeTime, const std::string& partNumber, 39 const std::string& serialNumber, 40 const std::string& locationCode, uint64_t eraseMaxGeometry, 41 uint64_t eraseMinGeometry, const std::string& driveType, 42 const std::string& driveProtocol, 43 std::unique_ptr<CryptsetupInterface> cryptInterface, 44 std::unique_ptr<FilesystemInterface> fsInterface) : 45 devPath(devPath), 46 containerName(luksName), mountPoint("/mnt/" + luksName + "_fs"), 47 eraseMaxGeometry(eraseMaxGeometry), eraseMinGeometry(eraseMinGeometry), 48 cryptIface(std::move(cryptInterface)), fsIface(std::move(fsInterface)), | 35EStoraged::EStoraged( 36 sdbusplus::asio::object_server& server, const std::string& configPath, 37 const std::string& devPath, const std::string& luksName, uint64_t size, 38 uint8_t lifeTime, const std::string& partNumber, 39 const std::string& serialNumber, const std::string& locationCode, 40 uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry, 41 const std::string& driveType, const std::string& driveProtocol, 42 std::unique_ptr<CryptsetupInterface> cryptInterface, 43 std::unique_ptr<FilesystemInterface> fsInterface) : 44 devPath(devPath), containerName(luksName), 45 mountPoint("/mnt/" + luksName + "_fs"), eraseMaxGeometry(eraseMaxGeometry), 46 eraseMinGeometry(eraseMinGeometry), cryptIface(std::move(cryptInterface)), 47 fsIface(std::move(fsInterface)), |
49 cryptDevicePath(cryptIface->cryptGetDir() + "/" + luksName), 50 objectServer(server) 51{ 52 /* Get the filename of the device (without "/dev/"). */ 53 std::string deviceName = std::filesystem::path(devPath).filename().string(); 54 /* DBus object path */ | 48 cryptDevicePath(cryptIface->cryptGetDir() + "/" + luksName), 49 objectServer(server) 50{ 51 /* Get the filename of the device (without "/dev/"). */ 52 std::string deviceName = std::filesystem::path(devPath).filename().string(); 53 /* DBus object path */ |
55 std::string objectPath = "/xyz/openbmc_project/inventory/storage/" + 56 deviceName; | 54 std::string objectPath = 55 "/xyz/openbmc_project/inventory/storage/" + deviceName; |
57 58 /* Add Volume interface. */ 59 volumeInterface = objectServer.add_interface( 60 objectPath, "xyz.openbmc_project.Inventory.Item.Volume"); 61 volumeInterface->register_method( 62 "FormatLuks", [this](const std::vector<uint8_t>& password, 63 Volume::FilesystemType type) { | 56 57 /* Add Volume interface. */ 58 volumeInterface = objectServer.add_interface( 59 objectPath, "xyz.openbmc_project.Inventory.Item.Volume"); 60 volumeInterface->register_method( 61 "FormatLuks", [this](const std::vector<uint8_t>& password, 62 Volume::FilesystemType type) { |
64 this->formatLuks(password, type); 65 }); | 63 this->formatLuks(password, type); 64 }); |
66 volumeInterface->register_method( 67 "Erase", 68 [this](Volume::EraseMethod eraseType) { this->erase(eraseType); }); 69 volumeInterface->register_method("Lock", [this]() { this->lock(); }); 70 volumeInterface->register_method( 71 "Unlock", 72 [this](std::vector<uint8_t>& password) { this->unlock(password); }); 73 volumeInterface->register_method( 74 "ChangePassword", [this](const std::vector<uint8_t>& oldPassword, 75 const std::vector<uint8_t>& newPassword) { | 65 volumeInterface->register_method( 66 "Erase", 67 [this](Volume::EraseMethod eraseType) { this->erase(eraseType); }); 68 volumeInterface->register_method("Lock", [this]() { this->lock(); }); 69 volumeInterface->register_method( 70 "Unlock", 71 [this](std::vector<uint8_t>& password) { this->unlock(password); }); 72 volumeInterface->register_method( 73 "ChangePassword", [this](const std::vector<uint8_t>& oldPassword, 74 const std::vector<uint8_t>& newPassword) { |
76 this->changePassword(oldPassword, newPassword); 77 }); | 75 this->changePassword(oldPassword, newPassword); 76 }); |
78 volumeInterface->register_property_r( 79 "Locked", lockedProperty, sdbusplus::vtable::property_::emits_change, 80 [this](bool& value) { | 77 volumeInterface->register_property_r( 78 "Locked", lockedProperty, sdbusplus::vtable::property_::emits_change, 79 [this](bool& value) { |
81 value = this->isLocked(); 82 return value; 83 }); | 80 value = this->isLocked(); 81 return value; 82 }); |
84 85 /* Add Drive interface. */ 86 driveInterface = objectServer.add_interface( 87 objectPath, "xyz.openbmc_project.Inventory.Item.Drive"); 88 driveInterface->register_property("Capacity", size); 89 driveInterface->register_property("PredictedMediaLifeLeftPercent", 90 lifeTime); 91 driveInterface->register_property( 92 "Type", 93 "xyz.openbmc_project.Inventory.Item.Drive.DriveType." + driveType); 94 driveInterface->register_property( 95 "Protocol", "xyz.openbmc_project.Inventory.Item.Drive.DriveProtocol." + 96 driveProtocol); 97 /* This registers the Locked property for the Drives interface. 98 * Now it is the same as the volume Locked property */ 99 driveInterface->register_property_r( 100 "Locked", lockedProperty, sdbusplus::vtable::property_::emits_change, 101 [this](bool& value) { | 83 84 /* Add Drive interface. */ 85 driveInterface = objectServer.add_interface( 86 objectPath, "xyz.openbmc_project.Inventory.Item.Drive"); 87 driveInterface->register_property("Capacity", size); 88 driveInterface->register_property("PredictedMediaLifeLeftPercent", 89 lifeTime); 90 driveInterface->register_property( 91 "Type", 92 "xyz.openbmc_project.Inventory.Item.Drive.DriveType." + driveType); 93 driveInterface->register_property( 94 "Protocol", "xyz.openbmc_project.Inventory.Item.Drive.DriveProtocol." + 95 driveProtocol); 96 /* This registers the Locked property for the Drives interface. 97 * Now it is the same as the volume Locked property */ 98 driveInterface->register_property_r( 99 "Locked", lockedProperty, sdbusplus::vtable::property_::emits_change, 100 [this](bool& value) { |
102 value = this->isLocked(); 103 return value; 104 }); | 101 value = this->isLocked(); 102 return value; 103 }); |
105 106 driveInterface->register_property_r( 107 "EncryptionStatus", encryptionStatus, 108 sdbusplus::vtable::property_::emits_change, 109 [this](Drive::DriveEncryptionState& value) { | 104 105 driveInterface->register_property_r( 106 "EncryptionStatus", encryptionStatus, 107 sdbusplus::vtable::property_::emits_change, 108 [this](Drive::DriveEncryptionState& value) { |
110 value = this->findEncryptionStatus(); 111 return value; 112 }); | 109 value = this->findEncryptionStatus(); 110 return value; 111 }); |
113 114 embeddedLocationInterface = objectServer.add_interface( 115 objectPath, "xyz.openbmc_project.Inventory.Connector.Embedded"); 116 117 if (!locationCode.empty()) 118 { 119 locationCodeInterface = objectServer.add_interface( 120 objectPath, "xyz.openbmc_project.Inventory.Decorator.LocationCode"); --- 403 unchanged lines hidden --- | 112 113 embeddedLocationInterface = objectServer.add_interface( 114 objectPath, "xyz.openbmc_project.Inventory.Connector.Embedded"); 115 116 if (!locationCode.empty()) 117 { 118 locationCodeInterface = objectServer.add_interface( 119 objectPath, "xyz.openbmc_project.Inventory.Decorator.LocationCode"); --- 403 unchanged lines hidden --- |