gparted r1071 - in trunk: . include src



Author: gedakc
Date: Wed Feb 18 16:19:49 2009
New Revision: 1071
URL: http://svn.gnome.org/viewvc/gparted?rev=1071&view=rev

Log:
Added detection of LUKS encrypted partitions

Modified:
   trunk/ChangeLog
   trunk/include/Utils.h
   trunk/src/DialogFeatures.cc
   trunk/src/Dialog_Partition_New.cc
   trunk/src/GParted_Core.cc
   trunk/src/Utils.cc
   trunk/src/Win_GParted.cc

Modified: trunk/include/Utils.h
==============================================================================
--- trunk/include/Utils.h	(original)
+++ trunk/include/Utils.h	Wed Feb 18 16:19:49 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort
  *
  *  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
@@ -68,7 +68,8 @@
 	FS_USED		= 18,
 	FS_UNUSED	= 19,
 
-	FS_LVM2		= 20   
+	FS_LVM2		= 20,
+	FS_LUKS		= 21
 } ;
 
 enum SIZE_UNIT

Modified: trunk/src/DialogFeatures.cc
==============================================================================
--- trunk/src/DialogFeatures.cc	(original)
+++ trunk/src/DialogFeatures.cc	Wed Feb 18 16:19:49 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort
  *
  *  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
@@ -104,9 +104,11 @@
 	//fill the features chart with valid file systems 
 	for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
 	{
-		//Skip lvm2 and unknown because these are not file systems
-		if( FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
-			FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN )
+		//Skip luks, lvm2, and unknown because these are not file systems
+		if ( FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS ||
+		     FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
+		     FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN
+		   )
 			continue ;
 		show_filesystem( FILESYSTEMS[ t ] ) ;
 	}

Modified: trunk/src/Dialog_Partition_New.cc
==============================================================================
--- trunk/src/Dialog_Partition_New.cc	(original)
+++ trunk/src/Dialog_Partition_New.cc	Wed Feb 18 16:19:49 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort
  *
  *  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
@@ -49,7 +49,9 @@
 	for ( unsigned int t = this ->FILESYSTEMS .size( ) ; t > 0 ; t-- )
 	{
 		if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ||
-			 this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 )
+		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
+		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS
+		   )
 			this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ;
 	}
 
@@ -287,7 +289,7 @@
 	//fill the file system menu with the file systems (except for extended) 
 	for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ ) 
 	{
-		//skip extended (lvm2 and unknown removed in Set_Data())
+		//skip extended (luks, lvm2, and unknown removed in Set_Data())
 		if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
 			continue ;
 		menu_filesystem .items() .push_back( 

Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc	(original)
+++ trunk/src/GParted_Core.cc	Wed Feb 18 16:19:49 2009
@@ -131,6 +131,11 @@
 	fs ->filesystem = GParted::FS_LVM2 ;
 	FILESYSTEMS .push_back( * fs ) ;
 
+	//luks encryption-- not a file system
+	fs = new( FS ) ;
+	fs ->filesystem = GParted::FS_LUKS ;
+	FILESYSTEMS .push_back( * fs ) ;
+
 	//unknown file system (default when no match is found)
 	fs = new( FS ) ;
 	fs ->filesystem = GParted::FS_UNKNOWN ;
@@ -783,7 +788,7 @@
 	
 	
 	//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
+	// - no patches sent to parted for lvm2, or luks
 	char buf[512] ;
 
 	ped_device_open( lp_device );
@@ -815,6 +820,22 @@
 		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 ;
+	}
+
 	//no file system found....
 	temp = _( "Unable to detect file system! Possible reasons are:" ) ;
 	temp += "\n-"; 
@@ -902,9 +923,12 @@
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
-		       partitions[ t ] .type == GParted::TYPE_LOGICAL ) &&
+		       partitions[ t ] .type == GParted::TYPE_LOGICAL
+		     ) &&
 		     partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
-		     partitions[ t ] .filesystem != GParted::FS_LVM2 )
+		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
+		     partitions[ t ] .filesystem != GParted::FS_LUKS
+		   )
 		{
 			if ( partitions[ t ] .busy )
 			{
@@ -944,8 +968,10 @@
 	for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
 	{
 		if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
+		     partitions[ t ] .filesystem != GParted::FS_LUKS &&
 		     partitions[ t ] .filesystem != GParted::FS_LVM2 &&
-		     partitions[ t ] .filesystem != GParted::FS_UNKNOWN )
+		     partitions[ t ] .filesystem != GParted::FS_UNKNOWN
+		   )
 		{
 			if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
 			     partitions[ t ] .type == GParted::TYPE_LOGICAL ) 

Modified: trunk/src/Utils.cc
==============================================================================
--- trunk/src/Utils.cc	(original)
+++ trunk/src/Utils.cc	Wed Feb 18 16:19:49 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort
  *
  *  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
@@ -88,6 +88,7 @@
 		case FS_USED		: return "#F8F8BA" ;	// ~ light tan yellow
 		case FS_UNUSED		: return "#FFFFFF" ;	//white
 		case FS_LVM2		: return "#CC9966" ;	// ~ medium brown
+		case FS_LUKS		: return "#625B81" ;	//purple dark
 
 		default				: return "#000000" ;
 	}
@@ -134,6 +135,7 @@
 		case FS_USED		: return _("used") ;
 		case FS_UNUSED		: return _("unused") ;
 		case FS_LVM2		: return "lvm2" ;
+		case FS_LUKS		: return "crypt-luks" ;
 
 		default			: return "" ;
 	}

Modified: trunk/src/Win_GParted.cc
==============================================================================
--- trunk/src/Win_GParted.cc	(original)
+++ trunk/src/Win_GParted.cc	Wed Feb 18 16:19:49 2009
@@ -385,9 +385,11 @@
 
 	for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
 	{
-		//Skip lvm2 and unknown because these are not file systems
-		if( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
-			gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN )
+		//Skip luks, lvm2, and unknown because these are not file systems
+		if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS ||
+		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
+		     gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN
+		   )
 			continue ;
 
 		hbox = manage( new Gtk::HBox() );



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