summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tdecore/tdehw/tdegenericdevice.cpp4
-rw-r--r--tdecore/tdehw/tdegenericdevice.h2
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp37
-rw-r--r--tdecore/tdehw/tdehardwaredevices.h2
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp39
-rw-r--r--tdecore/tdehw/tdestoragedevice.h13
6 files changed, 70 insertions, 27 deletions
diff --git a/tdecore/tdehw/tdegenericdevice.cpp b/tdecore/tdehw/tdegenericdevice.cpp
index 8662e5e8e..e9a645cf1 100644
--- a/tdecore/tdehw/tdegenericdevice.cpp
+++ b/tdecore/tdehw/tdegenericdevice.cpp
@@ -91,8 +91,8 @@ TQString TDEGenericDevice::deviceNode() {
return m_deviceNode;
}
-void TDEGenericDevice::internalSetDeviceNode(TQString sn) {
- m_deviceNode = sn;
+void TDEGenericDevice::internalSetDeviceNode(TQString dn) {
+ m_deviceNode = dn;
}
TQString TDEGenericDevice::deviceBus() {
diff --git a/tdecore/tdehw/tdegenericdevice.h b/tdecore/tdehw/tdegenericdevice.h
index 7536b44a7..91e9ac79e 100644
--- a/tdecore/tdehw/tdegenericdevice.h
+++ b/tdecore/tdehw/tdegenericdevice.h
@@ -231,7 +231,7 @@ class TDECORE_EXPORT TDEGenericDevice : public TQObject
*
* This method is non-portable, so be careful!
*/
- void internalSetDeviceNode(TQString sn);
+ void internalSetDeviceNode(TQString dn);
/**
* @param bl true if this device has been blacklisted for update actions
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;
diff --git a/tdecore/tdehw/tdehardwaredevices.h b/tdecore/tdehw/tdehardwaredevices.h
index 7f27681f2..6d9b63ea6 100644
--- a/tdecore/tdehw/tdehardwaredevices.h
+++ b/tdecore/tdehw/tdehardwaredevices.h
@@ -274,7 +274,7 @@ class TDECORE_EXPORT TDEHardwareDevices : public TQObject
private:
TDEGenericDevice *classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice=0, bool force_full_classification=true);
TDEGenericDevice *classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice=0, bool classifySubDevices=false);
- void updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev=NULL);
+ void updateExistingDeviceInformation(TDEGenericDevice *device, udev_device *dev=NULL);
void updateParentDeviceInformation();
void updateParentDeviceInformation(TDEGenericDevice* hwdevice);
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 862e7b10e..ef22ca239 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -69,6 +69,26 @@ TDEStorageDevice::~TDEStorageDevice() {
#endif
}
+TQString TDEStorageDevice::mappedName() {
+ return m_mappedName;
+}
+
+void TDEStorageDevice::updateMappedName() {
+ // Get the device mapped name if present
+ m_mappedName = TQString::null;
+ TQString dmnodename = systemPath();
+ dmnodename.append("/dm/name");
+ TQFile dmnamefile(dmnodename);
+ if (dmnamefile.open(IO_ReadOnly)) {
+ TQTextStream stream(&dmnamefile);
+ m_mappedName = stream.readLine();
+ dmnamefile.close();
+ }
+ if (!m_mappedName.isEmpty()) {
+ m_mappedName.prepend("/dev/mapper/");
+ }
+}
+
TDEDiskDeviceType::TDEDiskDeviceType TDEStorageDevice::diskType() {
return m_diskType;
}
@@ -266,8 +286,8 @@ TQString TDEStorageDevice::cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::TDELUK
}
}
-void TDEStorageDevice::internalSetDeviceNode(TQString sn) {
- TDEGenericDevice::internalSetDeviceNode(sn);
+void TDEStorageDevice::internalSetDeviceNode(TQString dn) {
+ TDEGenericDevice::internalSetDeviceNode(dn);
internalInitializeLUKSIfNeeded();
}
@@ -659,19 +679,6 @@ TQString TDEStorageDevice::mountPath() {
// First, ensure that all device information (mainly holders/slaves) is accurate
TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
- TQString dmnodename = systemPath();
- dmnodename.append("/dm/name");
- TQFile namefile( dmnodename );
- TQString dmaltname;
- if ( namefile.open( IO_ReadOnly ) ) {
- TQTextStream stream( &namefile );
- dmaltname = stream.readLine();
- namefile.close();
- }
- if (!dmaltname.isNull()) {
- dmaltname.prepend("/dev/mapper/");
- }
-
TQStringList lines;
TQFile file( "/proc/mounts" );
if ( file.open( IO_ReadOnly ) ) {
@@ -682,7 +689,7 @@ TQString TDEStorageDevice::mountPath() {
TQStringList mountInfo = TQStringList::split(" ", line, true);
TQString testNode = *mountInfo.at(0);
// Check for match
- if ((testNode == deviceNode()) || (testNode == dmaltname) || (testNode == ("/dev/disk/by-uuid/" + diskUUID()))) {
+ if ((testNode == deviceNode()) || (testNode == mappedName()) || (testNode == ("/dev/disk/by-uuid/" + diskUUID()))) {
TQString ret = *mountInfo.at(1);
ret.replace("\\040", " ");
return ret;
diff --git a/tdecore/tdehw/tdestoragedevice.h b/tdecore/tdehw/tdestoragedevice.h
index 88991315e..47ea4debc 100644
--- a/tdecore/tdehw/tdestoragedevice.h
+++ b/tdecore/tdehw/tdestoragedevice.h
@@ -194,6 +194,16 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
TQString diskUUID();
/**
+ * @return a TQString with the device mapped name, if any
+ */
+ TQString mappedName();
+
+ /**
+ * Find and store the alternative mapped name of a mapped device
+ */
+ void updateMappedName();
+
+ /**
* @return an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
*/
TDEDiskDeviceType::TDEDiskDeviceType diskType();
@@ -425,7 +435,7 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
*
* This method is non-portable, so be careful!
*/
- void internalSetDeviceNode(TQString sn);
+ void internalSetDeviceNode(TQString dn);
/**
* @param a TQString with the disk or partition label, if any
@@ -492,6 +502,7 @@ class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
void internalGetLUKSKeySlotStatus();
private:
+ TQString m_mappedName; // Alternative name for a mapped device
TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
TQString m_diskName;