diff --git a/src/fs/luks.h b/src/fs/luks.h index 07b2723..fa802fa 100644 --- a/src/fs/luks.h +++ b/src/fs/luks.h @@ -1,158 +1,166 @@ /************************************************************************* * Copyright (C) 2012 by Volker Lanz * * Copyright (C) 2013 by Andrius Štikonas * * Copyright (C) 2015-2016 by Teo Mrnjavac * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 3 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see .* *************************************************************************/ #if !defined(LUKS__H) #define LUKS__H #include "../util/libpartitionmanagerexport.h" #include "../fs/filesystem.h" #include #include class Report; class QString; namespace FS { /** A LUKS crypto file system. @author Andrius Štikonas */ class LIBKPMCORE_EXPORT luks : public FileSystem { public: luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label); virtual ~luks(); public: static void init(); virtual CommandSupportType supportGetUsed() const { return m_GetUsed; } virtual CommandSupportType supportGetLabel() const { return m_GetLabel; } virtual CommandSupportType supportCreate() const { return m_Create; } virtual CommandSupportType supportGrow() const { - return m_Grow; + if (!m_isCryptOpen) + return cmdSupportNone; + if (m_Grow && m_innerFs) + return m_innerFs->supportGrow(); + return cmdSupportNone; } virtual CommandSupportType supportShrink() const { - return m_Shrink; + if (!m_isCryptOpen) + return cmdSupportNone; + if (m_Shrink && m_innerFs) + return m_innerFs->supportShrink(); + return cmdSupportNone; } virtual CommandSupportType supportMove() const { return m_Move; } virtual CommandSupportType supportCheck() const { return m_Check; } virtual CommandSupportType supportCopy() const { return m_Copy; } virtual CommandSupportType supportBackup() const { return m_Backup; } virtual CommandSupportType supportSetLabel() const { return m_SetLabel; } virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; } virtual CommandSupportType supportGetUUID() const { return m_GetUUID; } virtual bool create(Report &report, const QString &deviceNode) const override; virtual qint64 minCapacity() const; virtual SupportTool supportToolName() const; virtual bool supportToolFound() const; virtual QString readUUID(const QString& deviceNode) const; virtual bool updateUUID(Report& report, const QString& deviceNode) const; virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const; virtual QString readLabel(const QString& deviceNode) const; virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel); virtual QString mountTitle() const override; virtual QString unmountTitle() const override; QString cryptOpenTitle() const; QString cryptCloseTitle() const; void setPassphrase(const QString&); virtual bool canMount(const QString&) const; virtual bool canUnmount(const QString&) const; bool isMounted() const; void setMounted(bool mounted); bool canCryptOpen(const QString& deviceNode) const; bool canCryptClose(const QString& deviceNode) const; bool isCryptOpen() const; void setCryptOpen(bool cryptOpen); bool cryptOpen(const QString& deviceNode); bool cryptClose(const QString& deviceNode); void loadInnerFileSystem(const QString& mapperNode); void createInnerFileSystem(Type type); virtual bool mount(const QString& deviceNode, const QString& mountPoint) override; virtual bool unmount(const QString& deviceNode) override; virtual FileSystem::Type type() const override; QString suggestedMapperName(const QString& deviceNode) const; static QString mapperName(const QString& deviceNode); static QString getCipherName(const QString& deviceNode); static QString getCipherMode(const QString& deviceNode); static QString getHashName(const QString& deviceNode); static QString getKeySize(const QString& deviceNode); static QString getPayloadOffset(const QString& deviceNode); static bool canEncryptType(FileSystem::Type type); public: static CommandSupportType m_GetUsed; static CommandSupportType m_GetLabel; static CommandSupportType m_Create; static CommandSupportType m_Grow; static CommandSupportType m_Shrink; static CommandSupportType m_Move; static CommandSupportType m_Check; static CommandSupportType m_Copy; static CommandSupportType m_Backup; static CommandSupportType m_SetLabel; static CommandSupportType m_UpdateUUID; static CommandSupportType m_GetUUID; private: mutable FileSystem* m_innerFs; mutable bool m_isCryptOpen; QString m_passphrase; bool m_isMounted; }; } #endif