diff --git a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/diskencrypt.cpp b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/diskencrypt.cpp index ac44c22..01b6ff7 100644 --- a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/diskencrypt.cpp +++ b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/diskencrypt.cpp @@ -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; } diff --git a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/encryptworker.cpp b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/encryptworker.cpp index 50471ac..336fa55 100644 --- a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/encryptworker.cpp +++ b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/encryptworker.cpp @@ -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 @@ -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()) { diff --git a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/globaltypesdefine.h b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/globaltypesdefine.h index e28211e..2126020 100644 --- a/src/dde-file-manager-daemon/daemonplugin-file-encrypt/globaltypesdefine.h +++ b/src/dde-file-manager-daemon/daemonplugin-file-encrypt/globaltypesdefine.h @@ -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 { @@ -127,6 +128,7 @@ struct EncryptConfig QString configPath; QString clearDevUUID; bool isDetachedHeader; + QString fsUuid; QVariantMap keyConfig() { @@ -135,8 +137,9 @@ struct EncryptConfig { "device-path", devicePath }, { "device-name", deviceName }, { "volume", clearDev }, + { "file-system-uuid", fsUuid } }; - }; + } }; enum EncryptState { diff --git a/src/dde-file-manager/dfmplugin-disk-encrypt-entry/events/eventshandler.cpp b/src/dde-file-manager/dfmplugin-disk-encrypt-entry/events/eventshandler.cpp index 306f454..ad89596 100644 --- a/src/dde-file-manager/dfmplugin-disk-encrypt-entry/events/eventshandler.cpp +++ b/src/dde-file-manager/dfmplugin-disk-encrypt-entry/events/eventshandler.cpp @@ -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()); diff --git a/src/dde-file-manager/dfmplugin-disk-encrypt-entry/menu/diskencryptmenuscene.cpp b/src/dde-file-manager/dfmplugin-disk-encrypt-entry/menu/diskencryptmenuscene.cpp index 5a463cf..a8d3b12 100644 --- a/src/dde-file-manager/dfmplugin-disk-encrypt-entry/menu/diskencryptmenuscene.cpp +++ b/src/dde-file-manager/dfmplugin-disk-encrypt-entry/menu/diskencryptmenuscene.cpp @@ -302,6 +302,12 @@ void DiskEncryptMenuScene::doEncryptDevice(const DeviceEncryptParam ¶m) 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 }, @@ -314,7 +320,8 @@ void DiskEncryptMenuScene::doEncryptDevice(const DeviceEncryptParam ¶m) { 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);