[gparted] Add PartitionLUKS class and create objects (#760080)



commit 99ff0c762835a0d501abcb9c0bb9d128c1607330
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Nov 11 21:12:39 2015 +0000

    Add PartitionLUKS class and create objects (#760080)
    
    Absolute minimum implementation of a PartitionLUKS class which can be
    constructed, polymorphically copied and destroyed.  Contains an
    "encrypted" member of type Partition to represent the encrypted file
    system within the LUKS format.
    
    Create PartitionLUKS objects instead of base Partition objects when a
    LUKS formatted partition is found.  Only the base Partition object
    member values have been populated, and the "encrypted" member remains
    blank at this point.
    
    Bug 760080 - Implement read-only LUKS support

 include/Makefile.am     |    1 +
 include/PartitionLUKS.h |   40 ++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in          |    1 +
 src/GParted_Core.cc     |   12 ++++++++++--
 src/Makefile.am         |    1 +
 src/PartitionLUKS.cc    |   40 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 93 insertions(+), 2 deletions(-)
---
diff --git a/include/Makefile.am b/include/Makefile.am
index 039b135..9a09c1e 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -37,6 +37,7 @@ EXTRA_DIST = \
        OperationNamePartition.h        \
        OperationResizeMove.h           \
        Partition.h                     \
+       PartitionLUKS.h                 \
        PartitionVector.h               \
        PipeCapture.h                   \
        Proc_Partitions_Info.h          \
diff --git a/include/PartitionLUKS.h b/include/PartitionLUKS.h
new file mode 100644
index 0000000..bade4a8
--- /dev/null
+++ b/include/PartitionLUKS.h
@@ -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/>.
+ */
+
+
+#ifndef GPARTED_PARTITIONLUKS_H
+#define GPARTED_PARTITIONLUKS_H
+
+#include "../include/Partition.h"
+#include "../include/Utils.h"
+
+namespace GParted
+{
+
+class PartitionLUKS : public Partition
+{
+public:
+       PartitionLUKS();
+       virtual ~PartitionLUKS();
+       virtual PartitionLUKS * clone() const;
+
+private:
+       Partition encrypted;
+};
+
+}//GParted
+
+#endif /* GPARTED_PARTITIONLUKS_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6f69c31..5cce178 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -32,6 +32,7 @@ src/OperationLabelFileSystem.cc
 src/OperationNamePartition.cc
 src/OperationResizeMove.cc
 src/Partition.cc
+src/PartitionLUKS.cc
 src/PartitionVector.cc
 src/SWRaid_Info.cc
 src/TreeView_Detail.cc
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 037da43..59ac712 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -24,6 +24,7 @@
 #include "../include/Operation.h"
 #include "../include/OperationCopy.h"
 #include "../include/Partition.h"
+#include "../include/PartitionLUKS.h"
 #include "../include/PartitionVector.h"
 #include "../include/Proc_Partitions_Info.h"
 #include "../include/SWRaid_Info.h"
@@ -1281,7 +1282,10 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
                                        partition_is_busy = is_busy( filesystem, partition_path ) ;
                                }
 
-                               partition_temp = new Partition();
+                               if ( filesystem == FS_LUKS )
+                                       partition_temp = new PartitionLUKS();
+                               else
+                                       partition_temp = new Partition();
                                partition_temp->Set( device .get_path(),
                                                     partition_path,
                                                     lp_partition->num,
@@ -1393,7 +1397,11 @@ void GParted_Core::set_device_one_partition( Device & device, PedDevice * lp_dev
        Glib::ustring path = lp_device->path;
        bool partition_is_busy = is_busy( fstype, path );
 
-       Partition * partition_temp = new Partition();
+       Partition * partition_temp = NULL;
+       if ( fstype == FS_LUKS )
+               partition_temp = new PartitionLUKS();
+       else
+               partition_temp = new Partition();
        partition_temp->Set( device.get_path(),
                             path,
                             1,
diff --git a/src/Makefile.am b/src/Makefile.am
index 042036d..ef3447b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,6 +48,7 @@ gpartedbin_SOURCES = \
        OperationNamePartition.cc       \
        OperationResizeMove.cc          \
        Partition.cc                    \
+       PartitionLUKS.cc                \
        PartitionVector.cc              \
        PipeCapture.cc                  \
        Proc_Partitions_Info.cc         \
diff --git a/src/PartitionLUKS.cc b/src/PartitionLUKS.cc
new file mode 100644
index 0000000..b6d070c
--- /dev/null
+++ b/src/PartitionLUKS.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/PartitionLUKS.h"
+#include "../include/Utils.h"
+
+namespace GParted
+{
+
+PartitionLUKS::PartitionLUKS()
+{
+       // Nothing further to do here as the base class Partition default constructor,
+       // which calls Partition::Reset(), is called for this object and also to
+       // initialise the encrypted member variable of type Partition.
+}
+
+PartitionLUKS::~PartitionLUKS()
+{
+}
+
+PartitionLUKS * PartitionLUKS::clone() const
+{
+       // Virtual copy constructor method
+       return new PartitionLUKS( *this );
+}
+
+} //GParted


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