summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdestoragedevice.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/tdestoragedevice.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/tdestoragedevice.cpp')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp39
1 files changed, 23 insertions, 16 deletions
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;