Added detection of LUKS encrypted partitions

svn path=/trunk/; revision=1071
This commit is contained in:
Curtis Gedak 2009-02-18 16:19:49 +00:00
parent 42b63cc274
commit 3ef0293876
7 changed files with 64 additions and 18 deletions

View file

@ -1,3 +1,13 @@
2009-02-18 Curtis Gedak <gedakc@gmail.com>
* include/Utils.h,
src/Dialog_Partition_New.cc,
src/DialogFeatures.cc,
src/GParted_Core.cc,
src/Utils.cc,
src/Win_GParted.cc: Added detection of LUKS encrypted partitions.
- Closes GParted bug #490740
2009-02-16 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Base_Partition.cc,
@ -20,7 +30,8 @@
2009-02-11 Curtis Gedak <gedakc@gmail.com>
* gparted.in: Fixed typo of "freedeskdesktop" in hal-lock name.
- Thanks to Jonas Pedersen for finding this mistake.
- Thanks to Alain Kalker for discovering this mistake.
- Thanks to Jonas Pedersen for reporting this mistake upstream.
- Closes GParted bug #571347
2009-02-09 Curtis Gedak <gedakc@gmail.com>

View file

@ -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 @@ enum FILESYSTEM
FS_USED = 18,
FS_UNUSED = 19,
FS_LVM2 = 20
FS_LVM2 = 20,
FS_LUKS = 21
} ;
enum SIZE_UNIT

View file

@ -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 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
//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 ] ) ;
}

View file

@ -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 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
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 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
//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(

View file

@ -131,6 +131,11 @@ void GParted_Core::find_supported_filesystems()
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 @@ 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
// - no patches sent to parted for lvm2, or luks
char buf[512] ;
ped_device_open( lp_device );
@ -815,6 +820,22 @@ 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 ;
}
//no file system found....
temp = _( "Unable to detect file system! Possible reasons are:" ) ;
temp += "\n-";
@ -902,9 +923,12 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
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 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
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 )

View file

@ -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 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
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 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
case FS_USED : return _("used") ;
case FS_UNUSED : return _("unused") ;
case FS_LVM2 : return "lvm2" ;
case FS_LUKS : return "crypt-luks" ;
default : return "" ;
}

View file

@ -385,9 +385,11 @@ Gtk::Menu * Win_GParted::create_format_menu()
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() );