summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdehardwaredevices.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-10-10 14:40:20 +0800
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-10-10 14:40:20 +0800
commit9bc16841d1d0388001b26d00700456cd9263bd57 (patch)
tree87286af93443ad2386d4b7ecf3003805eb11d5a8 /tdecore/tdehw/tdehardwaredevices.cpp
parent33794c4ec3572327ac077e272523234aac464aa2 (diff)
downloadtdelibs-9bc16841d1d0388001b26d00700456cd9263bd57.tar.gz
tdelibs-9bc16841d1d0388001b26d00700456cd9263bd57.zip
Fixed mounting and unmounting of mapped storage devices.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdecore/tdehw/tdehardwaredevices.cpp')
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index acdd67b8a..3f694cedc 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -348,6 +348,13 @@ TDEGenericDevice* TDEHardwareDevices::findByDeviceNode(TQString devnode) {
if (hwdevice->deviceNode() == devnode) {
return hwdevice;
}
+ // For storage devices, check also against the mapped name
+ TDEStorageDevice *sdevice = dynamic_cast<TDEStorageDevice*>(hwdevice);
+ if (sdevice) {
+ if (sdevice->mappedName() == devnode) {
+ return sdevice;
+ }
+ }
}
return 0;
@@ -368,11 +375,11 @@ TDEStorageDevice* TDEHardwareDevices::findDiskByUID(TQString uid) {
}
void TDEHardwareDevices::processHotPluggedHardware() {
- udev_device* dev = udev_monitor_receive_device(m_udevMonitorStruct);
+ udev_device *dev = udev_monitor_receive_device(m_udevMonitorStruct);
if (dev) {
TQString actionevent(udev_device_get_action(dev));
if (actionevent == "add") {
- TDEGenericDevice* device = classifyUnknownDevice(dev);
+ TDEGenericDevice *device = classifyUnknownDevice(dev);
// Make sure this device is not a duplicate
TDEGenericDevice *hwdevice;
@@ -1970,7 +1977,9 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
|| (devicesubsystem == "scsi_tape"))
&& ((devicenode != "")
)) {
- if (!device) device = new TDEStorageDevice(TDEGenericDeviceType::Disk);
+ if (!device) {
+ device = new TDEStorageDevice(TDEGenericDeviceType::Disk);
+ }
}
else if (devicetype == "host") {
if (devicesubsystem == "bluetooth") {
@@ -2466,10 +2475,20 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
udev_device_unref(dev);
}
+ // Get the device mapped name if present
+ TDEStorageDevice *sdevice = dynamic_cast<TDEStorageDevice*>(device);
+ if (sdevice) {
+ sdevice->updateMappedName();
+ }
+
return device;
}
-void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev) {
+void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice *device, udev_device *dev) {
+ if (!device) {
+ return;
+ }
+
TQString devicename;
TQString devicetype;
TQString devicedriver;
@@ -2485,7 +2504,6 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
TQString devicetypestring;
TQString devicetypestring_alt;
TQString devicepciclass;
- TDEGenericDevice* device = existingdevice;
bool temp_udev_device = !dev;
devicename = device->name();
@@ -2766,7 +2784,9 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
// Set mountable flag if device is likely to be mountable
diskstatus = diskstatus | TDEDiskDeviceStatus::Mountable;
- if ((devicetypestring.upper().isNull()) && (disktype & TDEDiskDeviceType::HDD)) {
+ if (devicetypestring.upper().isNull() && devicetypestring_alt.upper().isNull() && (disktype & TDEDiskDeviceType::HDD)) {
+ // For mapped devices, ID_TYPE may be missing, so need to check the alternative device
+ // type string too. For example for LUKS disk, ID_TYPE is null and DEVTYPE is "disk"
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
}
if (removable) {
@@ -2795,6 +2815,11 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
}
}
+ // Encrypted or RAID disks are not mountable
+ if (filesystemtype.upper() == "CRYPTO_LUKS" || filesystemtype.upper() == "CRYPTO" ||
+ filesystemusage.upper() == "RAID") {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
if (holdingDeviceNodes.count() > 0) {
diskstatus = diskstatus | TDEDiskDeviceStatus::UsedByDevice;