Skip to content

Commit

Permalink
fix: [part-encrypt] Set the device to partUuid.
Browse files Browse the repository at this point in the history
Set the device to partUuid.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-263863.html
  • Loading branch information
GongHeng2017 authored and deepin-bot[bot] committed Jul 30, 2024
1 parent d665f21 commit e227a34
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ bool disk_encrypt_utils::bcReadEncryptConfig(disk_encrypt::EncryptConfig *config
config->configPath = encryptConfigPath;
config->clearDevUUID = obj.value("clear-device-uuid").toString();
config->isDetachedHeader = obj.value("is-detached-header").toBool();
config->fsUuid = obj.value("file-system-uuid").toString();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ int PrencryptWorker::writeEncryptParams(const QString &device)
QString dmDev = QString("dm-%1").arg(dev.mid(5));
if (params.value(encrypt_param_keys::kKeyIsDetachedHeader).toBool())
dmDev = params.value(encrypt_param_keys::kKeyPrefferDevice).toString();
QString uuid = QString("UUID=%1").arg(params.value(encrypt_param_keys::kKeyUUID).toString());
QString fsUuid = QString("UUID=%1").arg(params.value(encrypt_param_keys::kKeyUUID).toString());
QString partUuid = QString("PARTUUID=%1").arg(params.value(encrypt_param_keys::kKeyPartUUID).toString());

obj.insert("volume", dmDev); // used to name a opened luks device.
obj.insert("device", uuid); // used to locate the backing device.
obj.insert("device", partUuid); // used to locate the backing device.
obj.insert("device-path", dev); // used to locate the backing device by device path.
obj.insert("device-name", params.value(encrypt_param_keys::kKeyDeviceName).toString()); // the device name display in dde-file-manager
obj.insert("device-mountpoint", params.value(encrypt_param_keys::kKeyMountPoint).toString()); // the mountpoint of the device
Expand All @@ -141,6 +142,7 @@ int PrencryptWorker::writeEncryptParams(const QString &device)
obj.insert("mode", encMode.value(params.value(encrypt_param_keys::kKeyEncMode).toInt()));
obj.insert("clear-device-uuid", params.value(encrypt_param_keys::kKeyClearDevUUID).toString());
obj.insert("is-detached-header", params.value(encrypt_param_keys::kKeyIsDetachedHeader).toBool());
obj.insert("file-system-uuid", fsUuid);

QString expPath = params.value(encrypt_param_keys::kKeyRecoveryExportPath).toString();
if (!expPath.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ inline constexpr char kKeyBackingDevUUID[] { "backingDevUUID" };
inline constexpr char kKeyClearDevUUID[] { "clearDevUUID" };
inline constexpr char kKeyIsDetachedHeader[] { "isDetachedHeader" };
inline constexpr char kKeyPrefferDevice[] { "prefferDevice" };
inline constexpr char kKeyPartUUID[] { "partUuid" };
} // namespace encrypt_param_keys

inline const QStringList kDisabledEncryptPath {
Expand Down Expand Up @@ -127,6 +128,7 @@ struct EncryptConfig
QString configPath;
QString clearDevUUID;
bool isDetachedHeader;
QString fsUuid;

QVariantMap keyConfig()
{
Expand All @@ -135,8 +137,9 @@ struct EncryptConfig
{ "device-path", devicePath },
{ "device-name", deviceName },
{ "volume", clearDev },
{ "file-system-uuid", fsUuid }
};
};
}
};

enum EncryptState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void EventsHandler::onRequestEncryptParams(const QVariantMap &encConfig)
disk_encrypt::DeviceEncryptParam param;
param.devDesc = devPath;
param.initOnly = false;
param.clearDevUUID = encConfig.value("device").toString().remove("UUID=");
param.clearDevUUID = encConfig.value("file-system-uuid").toString().remove("UUID=");
param.backingDevUUID = blkDev ? blkDev->getProperty(dfmmount::Property::kBlockIDUUID).toString() : "";
param.deviceDisplayName = encConfig.value("device-name").toString();
auto dlg = new EncryptParamsInputDialog(param, qApp->activeWindow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ void DiskEncryptMenuScene::doEncryptDevice(const DeviceEncryptParam &param)
kDaemonBusIface,
QDBusConnection::systemBus());
if (iface.isValid()) {
auto blkDev = device_utils::createBlockDevice(param.devID);
if (!blkDev) {
qCritical() << "Create block device failed, the object is: " << param.devID;
return;
}
QString partUuid { blkDev->getProperty(dfmmount::Property::kPartitionUUID).toString() };
QVariantMap params {
{ encrypt_param_keys::kKeyDevice, param.devDesc },
{ encrypt_param_keys::kKeyUUID, param.uuid },
Expand All @@ -314,7 +320,8 @@ void DiskEncryptMenuScene::doEncryptDevice(const DeviceEncryptParam &param)
{ encrypt_param_keys::kKeyMountPoint, param.mountPoint },
{ encrypt_param_keys::kKeyIsDetachedHeader, param.isDetachedHeader },
{ encrypt_param_keys::kKeyPrefferDevice, param.prefferDevName },
{ encrypt_param_keys::kKeyClearDevUUID, param.clearDevUUID }
{ encrypt_param_keys::kKeyClearDevUUID, param.clearDevUUID },
{ encrypt_param_keys::kKeyPartUUID, partUuid }
};
if (!tpmConfig.isEmpty()) params.insert(encrypt_param_keys::kKeyTPMConfig, tpmConfig);
if (!tpmToken.isEmpty()) params.insert(encrypt_param_keys::kKeyTPMToken, tpmToken);
Expand Down

0 comments on commit e227a34

Please sign in to comment.