Setting mount point for linux_raid_member partitions.
This commit is contained in:
parent
213162c1a8
commit
1c714c7854
|
@ -369,9 +369,9 @@ QStringList SoftwareRAID::getDevicePathList(const QString &path)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftwareRAID::isRaidPath(const QString &path)
|
bool SoftwareRAID::isRaidPath(const QString &devicePath)
|
||||||
{
|
{
|
||||||
return !getDetail(path).isEmpty();
|
return !getDetail(devicePath).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftwareRAID::createSoftwareRAID(Report &report,
|
bool SoftwareRAID::createSoftwareRAID(Report &report,
|
||||||
|
@ -437,32 +437,20 @@ bool SoftwareRAID::reassembleSoftwareRAID(Report& report, const QString &deviceN
|
||||||
return stopSoftwareRAID(report, deviceNode) && assembleSoftwareRAID(deviceNode);
|
return stopSoftwareRAID(report, deviceNode) && assembleSoftwareRAID(deviceNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftwareRAID::isRaidMember(const QString &path)
|
QString SoftwareRAID::getRaidArrayName(const QString &partitionPath)
|
||||||
{
|
{
|
||||||
QFile mdstat(QStringLiteral("/proc/mdstat"));
|
ExternalCommand cmd(QStringLiteral("mdadm"),
|
||||||
|
{ QStringLiteral("--misc"), QStringLiteral("--query"), partitionPath });
|
||||||
|
|
||||||
if (!mdstat.open(QIODevice::ReadOnly))
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
return false;
|
QRegularExpression ex(QStringLiteral("device active raid\\d+\\s([\\/\\w]+)."));
|
||||||
|
QRegularExpressionMatch match = ex.match(cmd.output());
|
||||||
|
|
||||||
QTextStream stream(&mdstat);
|
if (match.hasMatch())
|
||||||
|
return match.captured(1);
|
||||||
QString content = stream.readAll();
|
|
||||||
|
|
||||||
mdstat.close();
|
|
||||||
|
|
||||||
QRegularExpression re(QStringLiteral("(\\w+)\\[\\d+\\]"));
|
|
||||||
QRegularExpressionMatchIterator i = re.globalMatch(content);
|
|
||||||
|
|
||||||
while (i.hasNext()) {
|
|
||||||
QRegularExpressionMatch reMatch = i.next();
|
|
||||||
|
|
||||||
QString match = QStringLiteral("/dev/") + reMatch.captured(1);
|
|
||||||
|
|
||||||
if (match == path)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareRAID::initPartitions()
|
void SoftwareRAID::initPartitions()
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
static QString getUUID(const QString& path);
|
static QString getUUID(const QString& path);
|
||||||
static QStringList getDevicePathList(const QString& path);
|
static QStringList getDevicePathList(const QString& path);
|
||||||
|
|
||||||
static bool isRaidPath(const QString& path);
|
static bool isRaidPath(const QString& devicePath);
|
||||||
|
|
||||||
static bool createSoftwareRAID(Report& report,
|
static bool createSoftwareRAID(Report& report,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
|
|
||||||
static bool reassembleSoftwareRAID(Report& report, const QString& deviceNode);
|
static bool reassembleSoftwareRAID(Report& report, const QString& deviceNode);
|
||||||
|
|
||||||
static bool isRaidMember(const QString& path);
|
static QString getRaidArrayName(const QString& partitionPath);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initPartitions() override;
|
void initPartitions() override;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "core/fstab.h"
|
#include "core/fstab.h"
|
||||||
|
#include "core/raid/softwareraid.h"
|
||||||
|
|
||||||
#include "fs/filesystem.h"
|
#include "fs/filesystem.h"
|
||||||
#include "fs/lvm2_pv.h"
|
#include "fs/lvm2_pv.h"
|
||||||
|
@ -125,6 +126,8 @@ QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPat
|
||||||
{
|
{
|
||||||
if (fs->type() == FileSystem::Type::Lvm2_PV)
|
if (fs->type() == FileSystem::Type::Lvm2_PV)
|
||||||
return FS::lvm2_pv::getVGName(partitionPath);
|
return FS::lvm2_pv::getVGName(partitionPath);
|
||||||
|
else if (fs->type() == FileSystem::Type::LinuxRaidMember)
|
||||||
|
return SoftwareRAID::getRaidArrayName(partitionPath);
|
||||||
|
|
||||||
if (partitionPath.isEmpty()) // Happens when during initial scan LUKS is closed
|
if (partitionPath.isEmpty()) // Happens when during initial scan LUKS is closed
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool DeleteOperation::canDelete(const Partition* p)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (p->fileSystem().type() == FileSystem::Type::LinuxRaidMember) {
|
else if (p->fileSystem().type() == FileSystem::Type::LinuxRaidMember) {
|
||||||
if (SoftwareRAID::isRaidMember(p->partitionPath()))
|
if (!SoftwareRAID::getRaidArrayName(p->partitionPath()).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
|
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
|
||||||
|
@ -138,7 +138,7 @@ bool DeleteOperation::canDelete(const Partition* p)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (fs->type() == FileSystem::Type::LinuxRaidMember) {
|
else if (fs->type() == FileSystem::Type::LinuxRaidMember) {
|
||||||
if (SoftwareRAID::isRaidMember(p->partitionPath()))
|
if (!SoftwareRAID::getRaidArrayName(p->partitionPath()).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue