|
|
@ -28,6 +28,7 @@
|
|
|
|
#include <tqregexp.h>
|
|
|
|
#include <tqregexp.h>
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
#include <tqfile.h>
|
|
|
|
#include <tqfile.h>
|
|
|
|
|
|
|
|
#include <tqvariant.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "tdelocale.h"
|
|
|
|
#include "tdelocale.h"
|
|
|
@ -309,7 +310,8 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
|
|
|
|
|
|
|
|
|
|
|
|
bool TDEStorageDevice::ejectDrive() {
|
|
|
|
bool TDEStorageDevice::ejectDrive() {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
|
|
|
|
if (ejectDriveUDisks2(this)) {
|
|
|
|
TDEStorageOpResult ejectResult = UDisks2EjectDrive(this);
|
|
|
|
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -318,7 +320,8 @@ bool TDEStorageDevice::ejectDrive() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
|
|
|
|
if (ejectDriveUDisks(this)) {
|
|
|
|
TDEStorageOpResult ejectResult = UDisksEjectDrive(this);
|
|
|
|
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -699,15 +702,15 @@ TQString TDEStorageDevice::mountPath() {
|
|
|
|
return TQString::null;
|
|
|
|
return TQString::null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) {
|
|
|
|
TDEStorageOpResult TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions) {
|
|
|
|
// Device is already mounted
|
|
|
|
TDEStorageOpResult result;
|
|
|
|
if (!mountPath().isNull()) {
|
|
|
|
|
|
|
|
return mountPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int internal_retcode;
|
|
|
|
// Check if device is already mounted
|
|
|
|
if (!retcode) {
|
|
|
|
TQString mountpath = mountPath();
|
|
|
|
retcode = &internal_retcode;
|
|
|
|
if (!mountpath.isEmpty()) {
|
|
|
|
|
|
|
|
result["mountPath"] = mountpath;
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
TQString devNode = deviceNode();
|
|
|
@ -716,8 +719,6 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare filesystem options for mount
|
|
|
|
// Prepare filesystem options for mount
|
|
|
|
TQStringList udisksOptions;
|
|
|
|
TQStringList udisksOptions;
|
|
|
|
TQString optionString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mountOptions["ro"] == "true") {
|
|
|
|
if (mountOptions["ro"] == "true") {
|
|
|
|
udisksOptions.append("ro");
|
|
|
|
udisksOptions.append("ro");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -730,11 +731,8 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
udisksOptions.append("sync");
|
|
|
|
udisksOptions.append("sync");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( (mountOptions["filesystem"] == "fat")
|
|
|
|
if ((mountOptions["filesystem"] == "fat") || (mountOptions["filesystem"] == "vfat") ||
|
|
|
|
|| (mountOptions["filesystem"] == "vfat")
|
|
|
|
(mountOptions["filesystem"] == "msdos") || (mountOptions["filesystem"] == "umsdos")) {
|
|
|
|
|| (mountOptions["filesystem"] == "msdos")
|
|
|
|
|
|
|
|
|| (mountOptions["filesystem"] == "umsdos")
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (mountOptions.contains("shortname")) {
|
|
|
|
if (mountOptions.contains("shortname")) {
|
|
|
|
udisksOptions.append(TQString("shortname=%1").arg(mountOptions["shortname"]));
|
|
|
|
udisksOptions.append(TQString("shortname=%1").arg(mountOptions["shortname"]));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -753,15 +751,14 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( (mountOptions["filesystem"] == "ext3")
|
|
|
|
if ((mountOptions["filesystem"] == "ext3") || (mountOptions["filesystem"] == "ext4")) {
|
|
|
|
|| (mountOptions["filesystem"] == "ext4")
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
if (mountOptions.contains("journaling")) {
|
|
|
|
if (mountOptions.contains("journaling")) {
|
|
|
|
// udisks/udisks2 for now does not support option data= for ext3/ext4
|
|
|
|
// udisks/udisks2 for now does not support option data= for ext3/ext4
|
|
|
|
// udisksOptions.append(TQString("data=%1").arg(mountOptions["journaling"]));
|
|
|
|
// udisksOptions.append(TQString("data=%1").arg(mountOptions["journaling"]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString optionString;
|
|
|
|
for (TQStringList::Iterator it = udisksOptions.begin(); it != udisksOptions.end(); ++it) {
|
|
|
|
for (TQStringList::Iterator it = udisksOptions.begin(); it != udisksOptions.end(); ++it) {
|
|
|
|
optionString.append(",");
|
|
|
|
optionString.append(",");
|
|
|
|
optionString.append(*it);
|
|
|
|
optionString.append(*it);
|
|
|
@ -772,50 +769,49 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
TQString errorString;
|
|
|
|
|
|
|
|
TQString fileSystemType;
|
|
|
|
TQString fileSystemType;
|
|
|
|
|
|
|
|
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
fileSystemType = mountOptions["filesystem"];
|
|
|
|
fileSystemType = mountOptions["filesystem"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int uDisks2Ret = mountDriveUDisks2(devNode, fileSystemType, optionString, &errorString);
|
|
|
|
TDEStorageOpResult mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString);
|
|
|
|
if (uDisks2Ret == 0) {
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return mountPath();
|
|
|
|
result["mountPath"] = mountPath();
|
|
|
|
}
|
|
|
|
result["result"] = true;
|
|
|
|
else if (uDisks2Ret == -1) {
|
|
|
|
return result;
|
|
|
|
if (errRet) {
|
|
|
|
|
|
|
|
*errRet = errorString;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (mountResult["retcode"].toInt() == -1) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return mountPath();
|
|
|
|
result["errStr"] = mountResult["errStr"];
|
|
|
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
int uDisksRet = mountDriveUDisks(devNode, fileSystemType, udisksOptions, &errorString);
|
|
|
|
mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions);
|
|
|
|
if (uDisksRet == 0) {
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return mountPath();
|
|
|
|
result["mountPath"] = mountPath();
|
|
|
|
}
|
|
|
|
result["result"] = true;
|
|
|
|
else if (uDisksRet == -1) {
|
|
|
|
return result;
|
|
|
|
if (errRet) {
|
|
|
|
|
|
|
|
*errRet = errorString;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (mountResult["retcode"].toInt() == -1) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return mountPath();
|
|
|
|
result["errStr"] = mountResult["errStr"];
|
|
|
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
TQString command = TQString::null;
|
|
|
|
TQString command = TQString::null;
|
|
|
|
TQString udevilProg = TDEGlobal::dirs()->findExe("udevil");
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
if (!udevilProg.isEmpty()) {
|
|
|
|
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]);
|
|
|
|
fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -834,8 +830,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
|
|
|
|
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
TQString pmountProg = TDEGlobal::dirs()->findExe("pmount");
|
|
|
|
if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
|
|
|
|
if (!pmountProg.isEmpty()) {
|
|
|
|
|
|
|
|
// Create dummy password file
|
|
|
|
// Create dummy password file
|
|
|
|
KTempFile passwordFile(TQString::null, "tmp", 0600);
|
|
|
|
KTempFile passwordFile(TQString::null, "tmp", 0600);
|
|
|
|
passwordFile.setAutoDelete(true);
|
|
|
|
passwordFile.setAutoDelete(true);
|
|
|
@ -884,39 +879,38 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if (errRet) {
|
|
|
|
result["errStr"] = i18n("No supported mounting methods were detected on your system");
|
|
|
|
*errRet = i18n("No supported mounting methods were detected on your system");
|
|
|
|
result["result"] = false;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return mountPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
if (exepipe) {
|
|
|
|
if (exepipe) {
|
|
|
|
TQString mount_output;
|
|
|
|
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
mount_output = ts->read();
|
|
|
|
TQString mount_output = ts->read();
|
|
|
|
delete ts;
|
|
|
|
delete ts;
|
|
|
|
*retcode = pclose(exepipe);
|
|
|
|
int retcode = pclose(exepipe);
|
|
|
|
if (errRet) {
|
|
|
|
result["errStr"] = mount_output;
|
|
|
|
*errRet = mount_output;
|
|
|
|
result["retCode"] = retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return mountPath();
|
|
|
|
result["mountPath"] = mountPath();
|
|
|
|
|
|
|
|
result["result"] = !mountPath().isEmpty();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) {
|
|
|
|
TDEStorageOpResult TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName,
|
|
|
|
int internal_retcode;
|
|
|
|
TDEStorageMountOptions mountOptions) {
|
|
|
|
if (!retcode) {
|
|
|
|
TDEStorageOpResult result;
|
|
|
|
retcode = &internal_retcode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString ret = mountPath();
|
|
|
|
// Check if device is already mounted
|
|
|
|
|
|
|
|
TQString mountpath = mountPath();
|
|
|
|
if (!ret.isNull()) {
|
|
|
|
if (!mountpath.isEmpty()) {
|
|
|
|
return ret;
|
|
|
|
result["mountPath"] = mountpath;
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create dummy password file
|
|
|
|
// Create dummy password file
|
|
|
@ -924,7 +918,9 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me
|
|
|
|
passwordFile.setAutoDelete(true);
|
|
|
|
passwordFile.setAutoDelete(true);
|
|
|
|
TQFile* pwFile = passwordFile.file();
|
|
|
|
TQFile* pwFile = passwordFile.file();
|
|
|
|
if (!pwFile) {
|
|
|
|
if (!pwFile) {
|
|
|
|
return TQString::null;
|
|
|
|
result["errStr"] = i18n("Cannot create temporary password file");
|
|
|
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pwFile->writeBlock(passphrase.ascii(), passphrase.length());
|
|
|
|
pwFile->writeBlock(passphrase.ascii(), passphrase.length());
|
|
|
@ -960,119 +956,112 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me
|
|
|
|
passFileName.replace("'", "'\\''");
|
|
|
|
passFileName.replace("'", "'\\''");
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
mediaName.replace("'", "'\\''");
|
|
|
|
mediaName.replace("'", "'\\''");
|
|
|
|
TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
|
|
|
|
TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1")
|
|
|
|
|
|
|
|
.arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
|
|
|
|
|
|
|
|
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
if (exepipe) {
|
|
|
|
if (exepipe) {
|
|
|
|
TQString mount_output;
|
|
|
|
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
mount_output = ts->read();
|
|
|
|
TQString mount_output = ts->read();
|
|
|
|
delete ts;
|
|
|
|
delete ts;
|
|
|
|
*retcode = pclose(exepipe);
|
|
|
|
int retcode = pclose(exepipe);
|
|
|
|
if (errRet) {
|
|
|
|
result["errStr"] = mount_output;
|
|
|
|
*errRet = mount_output;
|
|
|
|
result["retCode"] = retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
|
|
|
|
result["mountPath"] = mountPath();
|
|
|
|
ret = mountPath();
|
|
|
|
result["result"] = !mountPath().isEmpty();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) {
|
|
|
|
TDEStorageOpResult TDEStorageDevice::unmountDevice() {
|
|
|
|
if (mountPath().isNull()) {
|
|
|
|
TDEStorageOpResult result;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int internal_retcode;
|
|
|
|
|
|
|
|
if (!retcode) {
|
|
|
|
|
|
|
|
retcode = &internal_retcode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if device is already unmounted
|
|
|
|
TQString mountpoint = mountPath();
|
|
|
|
TQString mountpoint = mountPath();
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
if (mountpoint.isEmpty()) {
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mountpoint.replace("'", "'\\''");
|
|
|
|
mountpoint.replace("'", "'\\''");
|
|
|
|
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
|
|
|
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
TQString errorString;
|
|
|
|
TDEStorageOpResult unmountResult = UDisks2UnmountDrive(devNode, TQString::null);
|
|
|
|
int unMountUDisks2Ret = unMountDriveUDisks2(devNode, TQString::null, &errorString);
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
if (unMountUDisks2Ret == 0) {
|
|
|
|
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return true;
|
|
|
|
result["result"] = true;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
else if (unMountUDisks2Ret == -1) {
|
|
|
|
|
|
|
|
if (errRet) {
|
|
|
|
|
|
|
|
*errRet = errorString;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (unmountResult["retcode"].toInt() == -1) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return false;
|
|
|
|
result["errStr"] = unmountResult["errStr"];
|
|
|
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
int unMountUDisksRet = unMountDriveUDisks(devNode, TQStringList(), &errorString);
|
|
|
|
unmountResult = UDisksUnmountDrive(devNode, TQStringList());
|
|
|
|
if (unMountUDisksRet == 0) {
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return true;
|
|
|
|
result["result"] = true;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
else if (unMountUDisksRet == -1) {
|
|
|
|
|
|
|
|
if (errRet) {
|
|
|
|
|
|
|
|
*errRet = errorString;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (unmountResult["retcode"].toInt() == -1) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return false;
|
|
|
|
result["errStr"] = unmountResult["errStr"];
|
|
|
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// Try to use udevil, if available
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
TQString command;
|
|
|
|
TQString command = TQString::null;
|
|
|
|
if(!(TDEGlobal::dirs()->findExe("udevil").isEmpty())) {
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
|
|
|
|
command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
if(command.isEmpty() &&
|
|
|
|
if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
|
|
|
|
!(TDEGlobal::dirs()->findExe("pumount").isEmpty())) {
|
|
|
|
|
|
|
|
command = TQString("pumount '%1' 2>&1").arg(mountpoint);
|
|
|
|
command = TQString("pumount '%1' 2>&1").arg(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if (errRet) {
|
|
|
|
result["errStr"] = i18n("No supported unmounting methods were detected on your system");
|
|
|
|
*errRet = i18n("No supported unmounting methods were detected on your system");
|
|
|
|
result["result"] = false;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
FILE *exepipe = popen(command.local8Bit(), "r");
|
|
|
|
if (exepipe) {
|
|
|
|
if (exepipe) {
|
|
|
|
TQString umount_output;
|
|
|
|
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
|
|
|
|
umount_output = ts->read();
|
|
|
|
TQString umount_output = ts->read();
|
|
|
|
delete ts;
|
|
|
|
delete ts;
|
|
|
|
*retcode = pclose(exepipe);
|
|
|
|
int retcode = pclose(exepipe);
|
|
|
|
if (*retcode == 0) {
|
|
|
|
if (retcode == 0) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return true;
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (errRet) {
|
|
|
|
result["errStr"] = umount_output;
|
|
|
|
*errRet = umount_output;
|
|
|
|
result["retCode"] = retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
return false;
|
|
|
|
result["result"] = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString TDEStorageDevice::determineFileSystemType(TQString path) {
|
|
|
|
TQString TDEStorageDevice::determineFileSystemType(TQString path) {
|
|
|
|