[gparted] Reorder crypt-luks detection (#741430)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Reorder crypt-luks detection (#741430)
- Date: Mon, 9 Mar 2015 16:36:15 +0000 (UTC)
commit bd9c76f602e0ef4eafe96cfe04818c33ecb3d13e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Dec 23 14:29:29 2014 +0000
Reorder crypt-luks detection (#741430)
(1) Add recognition of LUKS signatures detected by blkid command, via
the FS_Info cache.
(2) Relocate internal GParted detection of LUKS signature to back after
libparted and blkid identification. This reverses previous commit:
7695593d21a51422c230001083858e738b94c5e5
Improve crypt-luks detection (#578300)
Bug 578300 must have been caused by either: (1) reading stale data from
the whole disk device, or (2) formatting as LUKS over the top of ext3
leaving old signatures behind. Case (1) has been resolved by commit:
3bea067596e3e2d6513cda2a66df1b3e4fa432fb
Flush devices when scanning to prevent reading stale signatures
(#723842)
Re-tested case (2) and find that no old signatures are left behind:
# mkfs.ext3 /dev/sda8
# wipefs /dev/sda8
offset type
----------------------------------------------------------------
0x438 ext3 [filesystem]
UUID: 756dcd5f-73c5-4881-81ee-dc88e8b18f42
# cryptsetup luksFormat /dev/sda8
# wipefs /dev/sda8
offset type
----------------------------------------------------------------
0x0 crypto_LUKS [crypto]
UUID: de15ed1a-f461-46b7-803b-d0fd3b4bd680
Bug 741430 - GParted cannot recognise LVM signature on unpartitioned
drive
src/GParted_Core.cc | 49 ++++++++++++++++++++++++-------------------------
1 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 816a9cc..650960c 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1250,32 +1250,9 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
{
char magic1[16] = "";
char magic2[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
- char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
- if ( buf )
- {
- ped_device_open( lp_device );
- ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ;
- memcpy(magic1, buf+0, 6) ; //set binary magic data
- ped_device_close( lp_device );
- free( buf ) ;
-
- if ( 0 == memcmp( magic1 , "LUKS\xBA\xBE", 6 ) )
- {
- Glib::ustring temp ;
- temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ;
- messages .push_back( temp ) ;
- return GParted::FS_LUKS ;
- }
- }
-
FS_Info fs_info ;
Glib::ustring fs_type = "" ;
+ static Glib::ustring luks_unsupported = _("Linux Unified Key Setup encryption is not yet supported.");
//Standard libparted file system detection
if ( lp_partition && lp_partition ->fs_type )
@@ -1319,6 +1296,11 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
fs_type == "linux-swap(old)" ||
fs_type == "swap" )
return GParted::FS_LINUX_SWAP ;
+ else if ( fs_type == "crypto_LUKS" )
+ {
+ messages.push_back( luks_unsupported );
+ return FS_LUKS;
+ }
else if ( fs_type == "LVM2_member" )
return GParted::FS_LVM2_PV ;
else if ( fs_type == "f2fs" )
@@ -1360,7 +1342,7 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
// - no patches sent to parted for lvm2, or luks
//reiser4
- buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
+ char * buf = static_cast<char *>( malloc( lp_device->sector_size ) );
if ( buf )
{
ped_device_open( lp_device );
@@ -1405,6 +1387,23 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
}
}
+ //LUKS encryption
+ buf = static_cast<char *>( malloc( lp_device->sector_size ) );
+ if ( buf )
+ {
+ ped_device_open( lp_device );
+ ped_geometry_read( & lp_partition->geom, buf, 0, 1 );
+ memcpy(magic1, buf+0, 6); // set binary magic data
+ ped_device_close( lp_device );
+ free( buf );
+
+ if ( 0 == memcmp( magic1 , "LUKS\xBA\xBE", 6 ) )
+ {
+ messages.push_back( luks_unsupported );
+ return 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]