setting VG name as PV mount point

This commit is contained in:
Chantara Tith 2016-05-23 17:29:33 +07:00
parent 6e4c330410
commit 2f700570e0
3 changed files with 34 additions and 6 deletions

View File

@ -22,6 +22,7 @@
#include "util/capacity.h"
#include <QString>
#include <QRegularExpression>
namespace FS
{
@ -110,4 +111,18 @@ bool lvm2_pv::updateUUID(Report& report, const QString& deviceNode) const
ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvchange"), QStringLiteral("--uuid"), deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
}
QString lvm2_pv::getVGName(const QString& deviceNode) //PV node
{
ExternalCommand cmd( QStringLiteral("lvm"),
{ QStringLiteral("pvdisplay"), QStringLiteral("--verbose"), deviceNode });
if (cmd.run(-1) && cmd.exitCode() == 0) {
QRegularExpression re(QStringLiteral("VG Name\\h+(\\w+)"));
QRegularExpressionMatch vgName = re.match(cmd.output());
if (vgName.hasMatch())
return vgName.captured(1);
}
return QString();
}
}

View File

@ -92,6 +92,8 @@ public:
SupportTool supportToolName() const override;
bool supportToolFound() const override;
static QString getVGName(const QString& deviceNode);
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;

View File

@ -35,6 +35,7 @@
#include "fs/hfs.h"
#include "fs/hfsplus.h"
#include "fs/luks.h"
#include "fs/lvm2_pv.h"
#include "util/globallog.h"
#include "util/helpers.h"
@ -369,12 +370,18 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk)
if (isCryptOpen) {
luksFs->loadInnerFileSystem(node, mapperNode);
mountPoint = mountPoints.findByDevice(mapperNode) ?
mountPoints.findByDevice(mapperNode)->mountPoint() :
QString();
// We cannot use libparted to check the mounted status because
// we don't have a PedPartition for the mapper device, so we use lsblk
mounted = isMounted(mapperNode);
if (luksFs->type() == FileSystem::Lvm2_PV) {
mountPoint = FS::lvm2_pv::getVGName(mapperNode);
mounted = false;
} else {
mountPoint = mountPoints.findByDevice(mapperNode) ?
mountPoints.findByDevice(mapperNode)->mountPoint() :
QString();
// We cannot use libparted to check the mounted status because
// we don't have a PedPartition for the mapper device, so we use lsblk
mounted = isMounted(mapperNode);
}
if (mounted) {
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (freeSpaceInfo.isValid() && mountPoint != QString())
@ -385,6 +392,10 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk)
}
luksFs->setMounted(mounted);
} else if (type == FileSystem::Lvm2_PV) {
//TODO: adding PartitionRole
mountPoint = FS::lvm2_pv::getVGName(node);
mounted = false;
} else {
mountPoint = mountPoints.findByDevice(node) ?
mountPoints.findByDevice(node)->mountPoint() :