[gparted] Extract some code into detect_filesystem_in_encryption_mapping() (#148)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Extract some code into detect_filesystem_in_encryption_mapping() (#148)
- Date: Sat, 3 Apr 2021 18:30:51 +0000 (UTC)
commit 1e91cb831b8df269892f76440be86c105de3daf6
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Mon Mar 29 21:39:57 2021 +0100
Extract some code into detect_filesystem_in_encryption_mapping() (#148)
To avoid making set_luks_partition() more complicated extract the file
system detection portion into a new function.
Closes 148 - Encrypted file systems are no longer recognised
include/GParted_Core.h | 2 ++
src/GParted_Core.cc | 26 ++++++++++++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 222ee4fe..18f4b686 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -90,6 +90,8 @@ private:
std::vector<Glib::ustring> & messages );
void set_luks_partition( PartitionLUKS & partition );
void set_partition_label_and_uuid( Partition & partition );
+ static FSType detect_filesystem_in_encryption_mapping(const Glib::ustring& path,
+ std::vector<Glib::ustring>& messages);
static FSType detect_filesystem_internal(const Glib::ustring& path, Byte_Value sector_size);
static FSType detect_filesystem( PedDevice * lp_device, PedPartition * lp_partition,
std::vector<Glib::ustring> & messages );
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index afbd116a..d56a323b 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1007,15 +1007,8 @@ void GParted_Core::set_luks_partition( PartitionLUKS & partition )
return;
Glib::ustring mapping_path = DEV_MAPPER_PATH + mapping.name;
- PedDevice* lp_device = NULL;
std::vector<Glib::ustring> detect_messages;
- FSType fstype = FS_UNKNOWN;
- if ( get_device( mapping_path, lp_device ) )
- {
- fstype = detect_filesystem( lp_device, NULL, detect_messages );
- PedDisk* lp_disk = NULL;
- destroy_device_and_disk( lp_device, lp_disk );
- }
+ FSType fstype = detect_filesystem_in_encryption_mapping(mapping_path, detect_messages);
bool fs_busy = is_busy( fstype, mapping_path );
partition.set_luks( mapping_path,
@@ -1076,6 +1069,23 @@ void GParted_Core::set_partition_label_and_uuid( Partition & partition )
}
+FSType GParted_Core::detect_filesystem_in_encryption_mapping(const Glib::ustring& path,
+ std::vector<Glib::ustring>& messages)
+{
+ FSType fstype = FS_UNKNOWN;
+
+ PedDevice *lp_device = NULL;
+ if (get_device(path, lp_device))
+ {
+ fstype = detect_filesystem(lp_device, NULL, messages);
+ PedDisk *lp_disk = NULL;
+ destroy_device_and_disk(lp_device, lp_disk);
+ }
+
+ return fstype;
+}
+
+
// GParted simple internal file system signature detection. Use sparingly. Only when
// (old versions of) blkid and libparted don't recognise a signature.
FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_Value sector_size)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]