move unmount logic from Partition to FileSystem
This commit is contained in:
parent
3bfb0b4b5b
commit
b7a29bc3f6
|
@ -320,17 +320,7 @@ bool Partition::unmount(Report& report)
|
|||
|
||||
while (success) {
|
||||
if (fileSystem().canUnmount(deviceNode())) {
|
||||
success = fileSystem().unmount(deviceNode());
|
||||
if (success)
|
||||
setMountPoint(QString());
|
||||
} else {
|
||||
|
||||
ExternalCommand umountCmd(report,
|
||||
QStringLiteral("umount"),
|
||||
{ QStringLiteral("--verbose"),
|
||||
deviceNode() });
|
||||
if (!umountCmd.run() || umountCmd.exitCode() != 0)
|
||||
success = false;
|
||||
success = fileSystem().unmount(report, deviceNode());
|
||||
}
|
||||
|
||||
KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName);
|
||||
|
|
|
@ -410,10 +410,14 @@ bool FileSystem::mount(const QString &deviceNode, const QString &mountPoint)
|
|||
@param mountPoint the mount point the FileSystem is mounted on
|
||||
@return true on success
|
||||
*/
|
||||
bool FileSystem::unmount(const QString& mountPoint)
|
||||
bool FileSystem::unmount(Report& report, const QString& deviceNode)
|
||||
{
|
||||
Q_UNUSED(mountPoint);
|
||||
|
||||
ExternalCommand umountCmd( report,
|
||||
QStringLiteral("umount"),
|
||||
{ QStringLiteral("--verbose"),
|
||||
deviceNode });
|
||||
if ( umountCmd.run() && umountCmd.exitCode() == 0 )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -179,14 +179,14 @@ public:
|
|||
return false; /**< @return true if this FileSystem can be mounted */
|
||||
}
|
||||
virtual bool canUnmount(const QString&) const {
|
||||
return false; /**< @return true if this FileSystem can be unmounted */
|
||||
return true; /**< @return true if this FileSystem can be unmounted */
|
||||
}
|
||||
|
||||
virtual QString mountTitle() const;
|
||||
virtual QString unmountTitle() const;
|
||||
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint);
|
||||
virtual bool unmount(const QString& deviceNode);
|
||||
virtual bool unmount(Report& report, const QString& deviceNode);
|
||||
|
||||
qint64 firstSector() const {
|
||||
return m_FirstSector; /**< @return the FileSystem's first sector */
|
||||
|
|
|
@ -139,9 +139,9 @@ bool linuxswap::mount(const QString& deviceNode, const QString& mountPoint)
|
|||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool linuxswap::unmount(const QString& deviceNode)
|
||||
bool linuxswap::unmount(Report& report, const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("swapoff"), { deviceNode });
|
||||
ExternalCommand cmd(report, QStringLiteral("swapoff"), { deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint) override;
|
||||
virtual bool unmount(const QString& deviceNode) override;
|
||||
virtual bool unmount(Report& report, const QString& deviceNode) override;
|
||||
|
||||
virtual QString mountTitle() const override;
|
||||
virtual QString unmountTitle() const override;
|
||||
|
|
|
@ -403,7 +403,7 @@ bool luks::mount(const QString& deviceNode, const QString& mountPoint)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool luks::unmount(const QString& deviceNode)
|
||||
bool luks::unmount(Report& report, const QString& deviceNode)
|
||||
{
|
||||
if (!m_isCryptOpen)
|
||||
{
|
||||
|
@ -427,14 +427,14 @@ bool luks::unmount(const QString& deviceNode)
|
|||
|
||||
if (m_innerFs->canUnmount(mapperNode))
|
||||
{
|
||||
if (m_innerFs->unmount(mapperNode))
|
||||
if (m_innerFs->unmount(report, mapperNode))
|
||||
{
|
||||
m_isMounted = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExternalCommand unmountCmd(
|
||||
ExternalCommand unmountCmd( report,
|
||||
QStringLiteral("umount"),
|
||||
{ QStringLiteral("--verbose"), mapperNode });
|
||||
if (unmountCmd.run() && unmountCmd.exitCode() == 0)
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
void createInnerFileSystem(Type type);
|
||||
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint) override;
|
||||
virtual bool unmount(const QString& deviceNode) override;
|
||||
virtual bool unmount(Report& report, const QString& deviceNode) override;
|
||||
|
||||
virtual FileSystem::Type type() const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue