summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-04-26 02:40:48 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-04-26 02:40:48 -0500
commitbf8c2f287f571c07d9f3c8a451d39abce1be5207 (patch)
tree31c00130df9fafe192e2d910db03a5adbc2d1f03 /tdecore
parent79ebece2d75b35e852064aab51fb8327fe32473b (diff)
downloadtdelibs-bf8c2f287f571c07d9f3c8a451d39abce1be5207.tar.gz
tdelibs-bf8c2f287f571c07d9f3c8a451d39abce1be5207.zip
Fix disk device media insert remove detection
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehardwaredevices.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index c916ded9a..18878a1bd 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -2185,7 +2185,7 @@ void TDEHardwareDevices::processModifiedMounts() {
emit mountTableModified();
}
-TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQString &devicebus, const TQString &disktypestring, const TQString &systempath, const TQString &devicevendor, const TQString &devicemodel, const TQString &filesystemtype, const TQString &devicedriver) {
+TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQString devicebus, const TQString disktypestring, const TQString systempath, const TQString devicevendor, const TQString devicemodel, const TQString filesystemtype, const TQString devicedriver) {
// Classify a disk device type to the best of our ability
TDEDiskDeviceType::TDEDiskDeviceType disktype = TDEDiskDeviceType::Null;
@@ -2751,6 +2751,7 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
TQString devicetypestring_alt;
TQString devicepciclass;
TDEGenericDevice* device = existingdevice;
+ bool temp_udev_device = !dev;
if (dev) {
devicename = (udev_device_get_sysname(dev));
devicetype = (udev_device_get_devtype(dev));
@@ -2787,6 +2788,9 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
devicetypestring_alt = device->udevdevicetypestring_alt;
devicepciclass = device->PCIClass();
}
+ TQString syspathudev = systempath;
+ syspathudev.truncate(syspathudev.length()-1); // Remove trailing slash
+ dev = udev_device_new_from_syspath(m_udevStruct, syspathudev.ascii());
}
// FIXME
@@ -3300,7 +3304,7 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
- TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = sdevice->diskStatus();
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
if (force_full_classification) {
disktype = classifyDiskType(dev, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
@@ -3344,7 +3348,7 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
++floppyblkdirit;
}
}
-
+
// Some interesting information can be gleaned from the CMOS type file
// 0 : Defaults
// 1 : 5 1/4 DD
@@ -3376,7 +3380,7 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_STATE")).upper() == "BLANK") {
diskstatus = diskstatus | TDEDiskDeviceStatus::Blank;
}
- sdevice->internalSetMediaInserted(!(TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) == "0"));
+ sdevice->internalSetMediaInserted((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) != ""));
}
if (disktype & TDEDiskDeviceType::Zip) {
@@ -3419,6 +3423,12 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
}
}
+ // If certain disk types do not report the presence of a filesystem, they are likely not mountable
+ if ((disktype & TDEDiskDeviceType::HDD) || (disktype & TDEDiskDeviceType::Optical)) {
+ if (!(diskstatus & TDEDiskDeviceStatus::ContainsFilesystem)) {
+ diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
+ }
+ }
if (holdingDeviceNodes.count() > 0) {
diskstatus = diskstatus | TDEDiskDeviceStatus::UsedByDevice;
@@ -4192,6 +4202,10 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
device->m_udevdevicetypestring = devicetypestring;
device->udevdevicetypestring_alt = devicetypestring_alt;
+ if (temp_udev_device) {
+ udev_device_unref(dev);
+ }
+
return device;
}