From a179d5d6967c204d5973fff2839a517175671b5b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 27 Dec 2013 17:33:48 -0600 Subject: [PATCH] Fix crash in mount/umount operations when using pmount Remove unneeded hack in dirlister for media device root directory --- tdecore/tdehw/tdestoragedevice.cpp | 15 +++++++++------ tdeio/tdeio/connection.cpp | 18 ++++++++++-------- tdeio/tdeio/kdirlister.cpp | 11 ----------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp index 9a3897133..36712cb1e 100644 --- a/tdecore/tdehw/tdestoragedevice.cpp +++ b/tdecore/tdehw/tdestoragedevice.cpp @@ -956,8 +956,9 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString mount_output; - TQTextStream ts(exepipe, IO_ReadOnly); - mount_output = ts.read(); + TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly); + mount_output = ts->read(); + delete ts; *retcode = pclose(exepipe); if (errRet) { *errRet = mount_output; @@ -1030,8 +1031,9 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString mount_output; - TQTextStream ts(exepipe, IO_ReadOnly); - mount_output = ts.read(); + TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly); + mount_output = ts->read(); + delete ts; *retcode = pclose(exepipe); if (errRet) { *errRet = mount_output; @@ -1132,8 +1134,9 @@ bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) { FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString umount_output; - TQTextStream ts(exepipe, IO_ReadOnly); - umount_output = ts.read(); + TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly); + umount_output = ts->read(); + delete ts; *retcode = pclose(exepipe); if (*retcode == 0) { // Update internal mount data diff --git a/tdeio/tdeio/connection.cpp b/tdeio/tdeio/connection.cpp index cbe737693..119ab6a10 100644 --- a/tdeio/tdeio/connection.cpp +++ b/tdeio/tdeio/connection.cpp @@ -43,6 +43,8 @@ #include #include +extern char *__progname; + using namespace TDEIO; Connection::Connection() @@ -187,19 +189,19 @@ bool Connection::sendnow( int _cmd, const TQByteArray &data ) size_t n = fwrite( buffer, 1, 10, f_out ); if ( n != 10 ) { - kdError(7017) << "Could not send header" << endl; + kdError(7017) << "Could not send header (pid " << getpid() << " process \"" << __progname << "\")" << endl; return false; } n = fwrite( data.data(), 1, data.size(), f_out ); if ( n != data.size() ) { - kdError(7017) << "Could not write data" << endl; + kdError(7017) << "Could not write data (pid " << getpid() << " process \"" << __progname << "\")" << endl; return false; } if (fflush( f_out )) { - kdError(7017) << "Could not write data" << endl; + kdError(7017) << "Could not write data (pid " << getpid() << " process \"" << __progname << "\")" << endl; return false; } @@ -209,7 +211,7 @@ bool Connection::sendnow( int _cmd, const TQByteArray &data ) int Connection::read( int* _cmd, TQByteArray &data ) { if (fd_in == -1 ) { - kdError(7017) << "read: not yet inited" << endl; + kdError(7017) << "read: not yet inited (pid " << getpid() << " process \"" << __progname << "\")" << endl; return -1; } @@ -221,12 +223,12 @@ int Connection::read( int* _cmd, TQByteArray &data ) goto again1; if ( n == -1) { - kdError(7017) << "Header read failed, errno=" << errno << endl; + kdError(7017) << "Header read failed, errno=" << errno << " (pid " << getpid() << " process \"" << __progname << "\")" << endl; } if ( n != 10 ) { if ( n ) // 0 indicates end of file - kdError(7017) << "Header has invalid size (" << n << ")" << endl; + kdError(7017) << "Header has invalid size (" << n << ") (pid " << getpid() << " process \"" << __progname << "\")" << endl; return -1; } @@ -252,11 +254,11 @@ int Connection::read( int* _cmd, TQByteArray &data ) if (errno == EINTR) continue; - kdError(7017) << "Data read failed, errno=" << errno << endl; + kdError(7017) << "Data read failed, errno=" << errno << " (pid " << getpid() << " process \"" << __progname << "\")" << endl; return -1; } if ( !n ) { // 0 indicates end of file - kdError(7017) << "Connection ended unexpectedly (" << n << "/" << bytesToGo << ")" << endl; + kdError(7017) << "Connection ended unexpectedly (" << n << "/" << bytesToGo << ") (pid " << getpid() << " process \"" << __progname << "\")" << endl; return -1; } diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp index 1bf9ac78c..bae304f74 100644 --- a/tdeio/tdeio/kdirlister.cpp +++ b/tdeio/tdeio/kdirlister.cpp @@ -90,17 +90,6 @@ KDirListerCache::~KDirListerCache() bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u, bool _keep, bool _reload ) { - // HACK - // The media:/ tdeioslave has massive problems related to not properly updating its root directory - // Therefore, force a reload every time the media:/ tdeioslave root is accessed! - // FIXME - // For anyone wanting to tackle this problem, it was traced into the KDirListerCache::updateDirectory TDEIO::listDir TDEIO job - // Specifically, slotUpdateResult is never called for the root directory *iff* the user descends into an unmounted media device - // Strangely, slotUpdateResult *is* called if the user instead right-clicks on the unmounted media device and selects Mount from the context menu - if ((_u.protocol() == "media") && (_u.path() == "/")) { - _reload = true; - } - // like this we don't have to worry about trailing slashes any further KURL _url = _u; _url.cleanPath(); // kill consecutive slashes