Implement lvm PV resizing

This commit is contained in:
Chantara Tith 2016-05-25 03:13:23 +07:00 committed by Andrius Štikonas
parent 0a6de0c2f0
commit 0af98556ac
2 changed files with 15 additions and 4 deletions

View File

@ -47,7 +47,9 @@ lvm2_pv::lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, cons
void lvm2_pv::init()
{
m_Create = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
m_Grow = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
m_Shrink = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
m_GetLabel = cmdSupportCore;
m_UpdateUUID = findExternal(QStringLiteral("lvm")) ? cmdSupportFileSystem : cmdSupportNone;
@ -69,8 +71,8 @@ bool lvm2_pv::supportToolFound() const
m_Create != cmdSupportNone &&
m_Check != cmdSupportNone &&
m_UpdateUUID != cmdSupportNone &&
// m_Grow != cmdSupportNone &&
// m_Shrink != cmdSupportNone &&
m_Grow != cmdSupportNone &&
m_Shrink != cmdSupportNone &&
// m_Copy != cmdSupportNone &&
m_Move != cmdSupportNone &&
m_Backup != cmdSupportNone &&
@ -106,6 +108,15 @@ bool lvm2_pv::remove(Report& report, const QString& deviceNode) const
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool lvm2_pv::resize(Report& report, const QString& deviceNode, qint64 length) const
{
// TODO: check if the it is legal to reize
const QString len = QString::number(length / 512) + QStringLiteral("s");
ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvresize"), QStringLiteral("--yes"), QStringLiteral("--setphysicalvolumesize"), len, deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool lvm2_pv::updateUUID(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvchange"), QStringLiteral("--uuid"), deviceNode });

View File

@ -47,7 +47,7 @@ public:
bool check(Report& report, const QString& deviceNode) const override;
bool create(Report& report, const QString& deviceNode) const override;
bool remove(Report& report, const QString& deviceNode) const override;
// bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
// bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
bool updateUUID(Report& report, const QString& deviceNode) const override;
bool canMount(const QString & deviceNode, const QString & mountPoint) const override;