From ab6798510758ffc8009629fb688f7e50747ac1c7 Mon Sep 17 00:00:00 2001 From: wangrong Date: Thu, 13 Nov 2025 14:32:50 +0800 Subject: [PATCH 1/2] feat: Exclude removable devices when creating logical volume groups When a user creates and mounts a logical volume on a removable device using deepin-diskmanager, there's no graphical way to stop the logical volume except by deleting the logical volume group. This prevents the user from safely removing the removable device, and even if they do manage to remove it safely, subsequent mounts of the logical volume will fail because it wasn't stopped. Therefore, let's exclude removable devices when creating logical volume groups. Log: Exclude removable devices when creating logical volume groups Bug: https://pms.uniontech.com/bug-view-340061.html --- application/widgets/createvgwidget.cpp | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/application/widgets/createvgwidget.cpp b/application/widgets/createvgwidget.cpp index 7300855..791fa41 100644 --- a/application/widgets/createvgwidget.cpp +++ b/application/widgets/createvgwidget.cpp @@ -1140,6 +1140,34 @@ void CreateVGWidget::updateData() qDebug() << "CreateVGWidget::updateData completed"; } +static bool isDeviceRemovable(const QString &devicePath) +{ + QFileInfo deviceInfo(devicePath); + QString deviceName = deviceInfo.fileName(); // e.g., "sda" + + QString sysfsRemovablePath = QString("/sys/block/%1/removable").arg(deviceName); + QFile removableFile(sysfsRemovablePath); + bool removable = false; + QByteArray content; + + if (!removableFile.exists()) { + qWarning() << "Sysfs path does not exist:" << sysfsRemovablePath; + goto quit; + } + + if (!removableFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + qWarning() << "Could not open sysfs removable file:" << sysfsRemovablePath; + goto quit; + } + + content = removableFile.readAll().trimmed(); // trimmed() 移除换行符和空格 + removable = (content == "1"); + +quit: + qDebug() << "isDeviceRemovable:" << devicePath << removable; + return removable; +} + QList CreateVGWidget::createAvailableDiskData() { qDebug() << "CreateVGWidget::createAvailableDiskData called."; @@ -1155,6 +1183,11 @@ QList CreateVGWidget::createAvailableDiskData() continue; } + // 排除可移动设备 + if (isDeviceRemovable(info.m_path)) { + continue; + } + // 排除已加入VG的磁盘以及分区表错误的磁盘 if (isJoinAllVG.value(info.m_path) == "false") {//还需加上磁盘分区表是否错误的判断 PartitionVec lstNewPartition; From 657afcfc96b4022fa8379d7c17b6a979b6023428 Mon Sep 17 00:00:00 2001 From: wangrong Date: Thu, 13 Nov 2025 14:35:19 +0800 Subject: [PATCH 2/2] chore: Update version to 6.0.22 As title. Log: Update version to 6.0.22 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 2671086..fec3a54 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +deepin-diskmanager (6.0.22) unstable; urgency=medium + + * feat: Exclude removable devices when creating logical volume groups + + -- wangrong Thu, 13 Nov 2025 14:34:03 +0800 + deepin-diskmanager (6.0.21) unstable; urgency=medium * fix: Fix non-reproducible builds