diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 16b0516..f3bd927 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -143,7 +143,7 @@ bool FileSystem::detectMountStatus(FileSystem* fs, const QString& partitionPath) bool mounted = false; if (fs->type() == FileSystem::Lvm2_PV) { - mounted = false; + mounted = FS::lvm2_pv::getVGName(partitionPath) != QString(); // FIXME: VG name is scanned twice } else { mounted = isMounted(partitionPath); } @@ -166,8 +166,8 @@ QString FileSystem::readLabel(const QString& deviceNode) const */ bool FileSystem::create(Report& report, const QString& deviceNode) { - Q_UNUSED(report); - Q_UNUSED(deviceNode); + Q_UNUSED(report) + Q_UNUSED(deviceNode) return true; } @@ -188,9 +188,9 @@ void FileSystem::scan(const QString& deviceNode) */ bool FileSystem::resize(Report& report, const QString& deviceNode, qint64 newLength) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); - Q_UNUSED(newLength); + Q_UNUSED(report) + Q_UNUSED(deviceNode) + Q_UNUSED(newLength) return true; } diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index c886ead..92f9650 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -151,6 +151,9 @@ public: virtual CommandSupportType supportCheck() const { return cmdSupportNone; /**< @return CommandSupportType for checking */ } + virtual CommandSupportType supportCheckOnline() const { + return cmdSupportNone; /**< @return CommandSupportType for checking */ + } virtual CommandSupportType supportCopy() const { return cmdSupportNone; /**< @return CommandSupportType for copying */ } diff --git a/src/fs/luks.h b/src/fs/luks.h index 918d38c..7ef75b3 100644 --- a/src/fs/luks.h +++ b/src/fs/luks.h @@ -64,6 +64,13 @@ public: return m_innerFs->supportGrow(); return cmdSupportNone; } + CommandSupportType supportGrowOnline() const override { + if (!m_isCryptOpen) + return cmdSupportNone; + if (m_Grow && m_innerFs) + return m_innerFs->supportGrowOnline(); + return cmdSupportNone; + } CommandSupportType supportShrink() const override { if (!m_isCryptOpen) return cmdSupportNone; @@ -71,6 +78,13 @@ public: return m_innerFs->supportShrink(); return cmdSupportNone; } + CommandSupportType supportShrinkOnline() const override { + if (!m_isCryptOpen) + return cmdSupportNone; + if (m_Shrink && m_innerFs) + return m_innerFs->supportShrinkOnline(); + return cmdSupportNone; + } CommandSupportType supportMove() const override { if (m_isCryptOpen) return cmdSupportNone; @@ -83,6 +97,13 @@ public: return m_innerFs->supportCheck(); return cmdSupportNone; } + CommandSupportType supportCheckOnline() const override { + if (!m_isCryptOpen) + return cmdSupportNone; + if (m_Check && m_innerFs) + return m_innerFs->supportCheckOnline(); + return cmdSupportNone; + } CommandSupportType supportCopy() const override { if (m_isCryptOpen) return cmdSupportNone; diff --git a/src/fs/lvm2_pv.cpp b/src/fs/lvm2_pv.cpp index a85980e..3487d55 100644 --- a/src/fs/lvm2_pv.cpp +++ b/src/fs/lvm2_pv.cpp @@ -78,14 +78,11 @@ bool lvm2_pv::supportToolFound() const { return m_GetUsed != cmdSupportNone && -// m_GetLabel != cmdSupportNone && -// m_SetLabel != cmdSupportNone && m_Create != cmdSupportNone && m_Check != cmdSupportNone && m_UpdateUUID != cmdSupportNone && m_Grow != cmdSupportNone && m_Shrink != cmdSupportNone && -// m_Copy != cmdSupportNone && m_Move != cmdSupportNone && m_Backup != cmdSupportNone && m_GetUUID != cmdSupportNone; @@ -158,6 +155,12 @@ bool lvm2_pv::resize(Report& report, const QString& deviceNode, qint64 length) c return rval && cmd.run(-1) && cmd.exitCode() == 0; } +bool lvm2_pv::resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const +{ + Q_UNUSED(mountPoint) + return resize(report, deviceNode, length); +} + bool lvm2_pv::updateUUID(Report& report, const QString& deviceNode) const { ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("pvchange"), QStringLiteral("--uuid"), deviceNode }); diff --git a/src/fs/lvm2_pv.h b/src/fs/lvm2_pv.h index 244a439..6f74acd 100644 --- a/src/fs/lvm2_pv.h +++ b/src/fs/lvm2_pv.h @@ -53,6 +53,7 @@ public: bool create(Report& report, const QString& deviceNode) override; bool remove(Report& report, const QString& deviceNode) const override; bool resize(Report& report, const QString& deviceNode, qint64 length) const override; + bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override; // bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; bool updateUUID(Report& report, const QString& deviceNode) const override; QString readUUID(const QString& deviceNode) const override; @@ -76,15 +77,24 @@ public: CommandSupportType supportGrow() const override { return m_Grow; } + CommandSupportType supportGrowOnline() const override { + return m_Grow; + } CommandSupportType supportShrink() const override { return m_Shrink; } + CommandSupportType supportShrinkOnline() const override { + return m_Shrink; + } CommandSupportType supportMove() const override { return m_Move; } CommandSupportType supportCheck() const override { return m_Check; } + CommandSupportType supportCheckOnline() const override { + return m_Check; + } CommandSupportType supportCopy() const override { return m_Copy; } diff --git a/src/ops/checkoperation.cpp b/src/ops/checkoperation.cpp index 8e9921a..5c04652 100644 --- a/src/ops/checkoperation.cpp +++ b/src/ops/checkoperation.cpp @@ -70,7 +70,7 @@ bool CheckOperation::canCheck(const Partition* p) return false; if (p->isMounted()) - return false; + return p->fileSystem().supportCheckOnline() != FileSystem::cmdSupportNone; return p->fileSystem().supportCheck() != FileSystem::cmdSupportNone; } diff --git a/src/ops/resizeoperation.cpp b/src/ops/resizeoperation.cpp index 13a48d5..290a6ab 100644 --- a/src/ops/resizeoperation.cpp +++ b/src/ops/resizeoperation.cpp @@ -29,6 +29,8 @@ #include "jobs/resizefilesystemjob.h" #include "jobs/movefilesystemjob.h" +#include "ops/checkoperation.h" + #include "fs/filesystem.h" #include "util/capacity.h" @@ -63,7 +65,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6 m_GrowSetGeomJob(nullptr), m_CheckResizedJob(nullptr) { - if(!partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. + if(CheckOperation::canCheck(&partition())) addJob(checkOriginalJob()); if (partition().roles().has(PartitionRole::Extended)) { @@ -100,7 +102,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6 m_CheckResizedJob = new CheckFileSystemJob(partition()); - if(!partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. + if(CheckOperation::canCheck(&partition())) addJob(checkResizedJob()); } } @@ -143,13 +145,11 @@ void ResizeOperation::undo() bool ResizeOperation::execute(Report& parent) { - bool rval = false; + bool rval = true; Report* report = parent.newChild(description()); - if (partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. - rval = true; - else + if (CheckOperation::canCheck(&partition())) rval = checkOriginalJob()->run(*report); if (rval) { @@ -165,13 +165,11 @@ bool ResizeOperation::execute(Report& parent) rval = shrink(*report) && move(*report) && grow(*report); if (rval) { - if (partition().isMounted()) // FIXME: add support for checkOnline for file systems that support it. - rval = true; - else + if (CheckOperation::canCheck(&partition())) { rval = checkResizedJob()->run(*report); - - if (!rval) - report->line() << xi18nc("@info:status", "Checking partition %1 after resize/move failed.", partition().deviceNode()); + if (!rval) + report->line() << xi18nc("@info:status", "Checking partition %1 after resize/move failed.", partition().deviceNode()); + } } else report->line() << xi18nc("@info:status", "Resizing/moving partition %1 failed.", partition().deviceNode()); }