[gparted] Improve crypt-luks detection (#578300)



commit 7695593d21a51422c230001083858e738b94c5e5
Author: Curtis Gedak <gedakc gmail com>
Date:   Wed Apr 22 16:47:13 2009 -0600

    Improve crypt-luks detection (#578300)
    
    Move crypt-luks detection prior to libparted file system detection.
    If libparted file system detection is performed first, then encrypted
    file systems such as ext3 will be incorrectly detected by libparted as
    plain 'ext3' when in fact these file systems are encrypted.
---
 src/GParted_Core.cc |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index b47304e..a955191 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -833,6 +833,27 @@ void GParted_Core::set_device_partitions( Device & device )
 
 GParted::FILESYSTEM GParted_Core::get_filesystem() 
 {
+	char buf[512] ;
+	char magic[16] ;
+
+	//Check for LUKS encryption prior to libparted file system detection.
+	//  Otherwise encrypted file systems such as ext3 will be detected by
+	//  libparted as 'ext3'.
+
+	//LUKS encryption
+	ped_device_open( lp_device );
+	ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ;
+	strncpy(magic, buf+0, 6) ;  magic[6] = '\0' ; //set and terminate string
+	ped_device_close( lp_device );
+
+	if ( Glib::ustring( magic ) == "LUKS\xBA\xBE" )
+	{
+		temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ;
+		temp += "\n" ;
+		partition_temp .messages .push_back( temp ) ;
+		return GParted::FS_LUKS ;
+	}
+
 	//standard libparted file systems..
 	if ( lp_partition && lp_partition ->fs_type )
 	{
@@ -883,7 +904,6 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
 	
 	//other file systems libparted couldn't detect (i've send patches for these file systems to the parted guys)
 	// - no patches sent to parted for lvm2, or luks
-	char buf[512] ;
 
 	ped_device_open( lp_device );
 
@@ -914,22 +934,6 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
 		return GParted::FS_LVM2 ;
 	}
 
-	//LUKS encryption
-	char magic[16] ;
-
-	ped_device_open( lp_device );
-	ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ;
-	strncpy(magic, buf+0, 6) ;  magic[6] = '\0' ; //set and terminate string
-	ped_device_close( lp_device );
-
-	if ( Glib::ustring( magic ) == "LUKS\xBA\xBE" )
-	{
-		temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ;
-		temp += "\n" ;
-		partition_temp .messages .push_back( temp ) ;
-		return GParted::FS_LUKS ;
-	}
-
 	//btrfs
 	const Sector BTRFS_SUPER_INFO_SIZE   = 4096 ;
 	const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;



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