[gparted] Add busy detection of LUKS mapping (#760080)



commit 070d734e57e8c10cfc4264b34e8bd95bba7cf3ff
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Nov 15 10:07:42 2015 +0000

    Add busy detection of LUKS mapping (#760080)
    
    Provide a minimal implementation of a luks file system class which only
    does busy detection.
    
    NOTE:
    For now, read-only LUKS support, a LUKS partition will be busy when a
    dm-crypt mapping exists.  Later when read-write LUKS support is added
    GParted will need to look at the busy status of the encrypted file
    system within the open LUKS partition and map LUKS partition busy status
    to encryption being open or closed.
    
    Bug 760080 - Implement read-only LUKS support

 include/Makefile.am |    1 +
 include/Utils.h     |   18 +++++++++---------
 include/luks.h      |   35 +++++++++++++++++++++++++++++++++++
 po/POTFILES.in      |    1 +
 src/GParted_Core.cc |    3 ++-
 src/Makefile.am     |    1 +
 src/Utils.cc        |    1 +
 src/luks.cc         |   40 ++++++++++++++++++++++++++++++++++++++++
 8 files changed, 90 insertions(+), 10 deletions(-)
---
diff --git a/include/Makefile.am b/include/Makefile.am
index 1930b41..039b135 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -55,6 +55,7 @@ EXTRA_DIST = \
        jfs.h                           \
        linux_swap.h                    \
        lvm2_pv.h                       \
+       luks.h                          \
        nilfs2.h                        \
        ntfs.h                          \
        reiser4.h                       \
diff --git a/include/Utils.h b/include/Utils.h
index 8cef57b..f2ae5fe 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -79,17 +79,17 @@ enum FILESYSTEM
        FS_HFSPLUS         = 14,
        FS_JFS             = 15,
        FS_LINUX_SWAP      = 16,
-       FS_LVM2_PV         = 17,
-       FS_NILFS2          = 18,
-       FS_NTFS            = 19,
-       FS_REISER4         = 20,
-       FS_REISERFS        = 21,
-       FS_UFS             = 22,
-       FS_XFS             = 23,
+       FS_LUKS            = 17,
+       FS_LVM2_PV         = 18,
+       FS_NILFS2          = 19,
+       FS_NTFS            = 20,
+       FS_REISER4         = 21,
+       FS_REISERFS        = 22,
+       FS_UFS             = 23,
+       FS_XFS             = 24,
 
        // Recognised signatures but otherwise unsupported file system types
-       FS_BITLOCKER       = 24,
-       FS_LUKS            = 25,
+       FS_BITLOCKER       = 25,
        FS_LINUX_SWRAID    = 26,
        FS_LINUX_SWSUSPEND = 27,
        FS_REFS            = 28,
diff --git a/include/luks.h b/include/luks.h
new file mode 100644
index 0000000..a5dfa37
--- /dev/null
+++ b/include/luks.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2015 Mike Fleetwood
+ *
+ *  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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef GPARTED_LUKS_H
+#define GPARTED_LUKS_H
+
+#include "../include/FileSystem.h"
+
+namespace GParted
+{
+
+class luks : public FileSystem
+{
+public:
+       FS get_filesystem_support();
+       bool is_busy( const Glib::ustring & path );
+};
+
+} //GParted
+
+#endif /* GPARTED_LUKS_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index dd39db3..6f69c31 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -47,6 +47,7 @@ src/hfsplus.cc
 src/jfs.cc
 src/linux_swap.cc
 src/lvm2_pv.cc
+src/luks.cc
 src/main.cc
 src/ntfs.cc
 src/nilfs2.cc
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 032f860..52be0e5 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -35,6 +35,7 @@
 #include "../include/fat16.h"
 #include "../include/linux_swap.h"
 #include "../include/lvm2_pv.h"
+#include "../include/luks.h"
 #include "../include/reiserfs.h"
 #include "../include/nilfs2.h"
 #include "../include/ntfs.h"
@@ -3948,6 +3949,7 @@ void GParted_Core::init_filesystems()
        FILESYSTEM_MAP[FS_JFS]             = new jfs();
        FILESYSTEM_MAP[FS_LINUX_SWAP]      = new linux_swap();
        FILESYSTEM_MAP[FS_LVM2_PV]         = new lvm2_pv();
+       FILESYSTEM_MAP[FS_LUKS]            = new luks();
        FILESYSTEM_MAP[FS_NILFS2]          = new nilfs2();
        FILESYSTEM_MAP[FS_NTFS]            = new ntfs();
        FILESYSTEM_MAP[FS_REISER4]         = new reiser4();
@@ -3955,7 +3957,6 @@ void GParted_Core::init_filesystems()
        FILESYSTEM_MAP[FS_UFS]             = new ufs();
        FILESYSTEM_MAP[FS_XFS]             = new xfs();
        FILESYSTEM_MAP[FS_BITLOCKER]       = NULL;
-       FILESYSTEM_MAP[FS_LUKS]            = NULL;
        FILESYSTEM_MAP[FS_LINUX_SWRAID]    = NULL;
        FILESYSTEM_MAP[FS_LINUX_SWSUSPEND] = NULL;
 }
diff --git a/src/Makefile.am b/src/Makefile.am
index c2311ba..042036d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,6 +65,7 @@ gpartedbin_SOURCES = \
        jfs.cc                          \
        linux_swap.cc                   \
        lvm2_pv.cc                      \
+       luks.cc                         \
        main.cc                         \
        nilfs2.cc                       \
        ntfs.cc                         \
diff --git a/src/Utils.cc b/src/Utils.cc
index d925096..55cbbf8 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -337,6 +337,7 @@ Glib::ustring Utils::get_filesystem_software( FILESYSTEM filesystem )
                case FS_JFS         : return "jfsutils" ;
                case FS_LINUX_SWAP  : return "util-linux" ;
                case FS_LVM2_PV     : return "lvm2" ;
+               case FS_LUKS        : return "dmsetup";
                case FS_NILFS2      : return "nilfs-utils" ;
                case FS_NTFS        : return "ntfs-3g / ntfsprogs" ;
                case FS_REISER4     : return "reiser4progs" ;
diff --git a/src/luks.cc b/src/luks.cc
new file mode 100644
index 0000000..608e263
--- /dev/null
+++ b/src/luks.cc
@@ -0,0 +1,40 @@
+/* Copyright (C) 2015 Mike Fleetwood
+ *
+ *  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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "../include/LUKS_Info.h"
+#include "../include/luks.h"
+
+namespace GParted
+{
+
+FS luks::get_filesystem_support()
+{
+       FS fs;
+       fs.filesystem = FS_LUKS;
+
+       fs.busy = FS::EXTERNAL;
+
+       return fs;
+}
+
+bool luks::is_busy( const Glib::ustring & path )
+{
+       Glib::ustring name = LUKS_Info::get_mapping_name( path );
+       return ! name.empty();
+}
+
+} //GParted


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]