Fix crashes in LVM scanner when external device is unplugged without deactivating LVM partitions.

This commit removes stderror channel from output of external commands.
This commit is contained in:
Andrius Štikonas 2016-07-30 21:11:15 +01:00
parent db836f292b
commit 2b9c63ffe0
2 changed files with 9 additions and 6 deletions

View File

@ -28,9 +28,10 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QStringList> #include <QStringList>
#include <KMountPoint>
#include <KDiskFreeSpaceInfo> #include <KDiskFreeSpaceInfo>
#include <KLocalizedString> #include <KLocalizedString>
#include <KMountPoint>
/** Constructs a representation of LVM device with functionning LV as Partition /** Constructs a representation of LVM device with functionning LV as Partition
* *
@ -139,10 +140,12 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, const LvmDevice& dev,
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
//TODO: test used space report. probably incorrect //TODO: test used space report. probably incorrect
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) { if (logicalSize() > 0) {
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize()); if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) {
} else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) { fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
fs->setSectorsUsed(fs->readUsedCapacity(lvpath) / logicalSize()); } else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) {
fs->setSectorsUsed(fs->readUsedCapacity(lvpath) / logicalSize());
}
} }
} }

View File

@ -61,7 +61,7 @@ ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStri
void ExternalCommand::setup() void ExternalCommand::setup()
{ {
setEnvironment(QStringList() << QStringLiteral("LC_ALL=C") << QStringLiteral("PATH=") + QString::fromUtf8(getenv("PATH")) << QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1")); setEnvironment(QStringList() << QStringLiteral("LC_ALL=C") << QStringLiteral("PATH=") + QString::fromUtf8(getenv("PATH")) << QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1"));
setProcessChannelMode(MergedChannels); setProcessChannelMode(SeparateChannels);
connect(this, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &ExternalCommand::onFinished); connect(this, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &ExternalCommand::onFinished);
connect(this, &ExternalCommand::readyReadStandardOutput, this, &ExternalCommand::onReadOutput); connect(this, &ExternalCommand::readyReadStandardOutput, this, &ExternalCommand::onReadOutput);