[gparted] Recognise BitLocker encrypted partitions (#723232)



commit 97284797717d750173540e6f35f639ac85b8f61b
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Jan 29 09:45:31 2014 +0000

    Recognise BitLocker encrypted partitions (#723232)
    
    Only recognises partitions containing BitLocker Disk Encryption content.
    No other actions are supported.
    
    Bug #723232 - BitLocker Disk Encryption not recognised

 include/Utils.h             |    7 ++++---
 src/DialogFeatures.cc       |    1 +
 src/Dialog_Partition_New.cc |    1 +
 src/GParted_Core.cc         |   28 ++++++++++++++++++++++++++++
 src/Utils.cc                |    2 ++
 src/Win_GParted.cc          |    1 +
 6 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index c4d9dd9..818d7d8 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -86,9 +86,10 @@ enum FILESYSTEM
        FS_USED            = 24,
        FS_UNUSED          = 25,
 
-       FS_LUKS            = 26,
-       FS_LINUX_SWRAID    = 27,
-       FS_LINUX_SWSUSPEND = 28
+       FS_BITLOCKER       = 26,
+       FS_LUKS            = 27,
+       FS_LINUX_SWRAID    = 28,
+       FS_LINUX_SWSUSPEND = 29
 } ;
 
 enum SIZE_UNIT
diff --git a/src/DialogFeatures.cc b/src/DialogFeatures.cc
index 231f077..ee8af2a 100644
--- a/src/DialogFeatures.cc
+++ b/src/DialogFeatures.cc
@@ -145,6 +145,7 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
                //Skip non-file systems or file systems only recognised but not otherwise supported
                if (    FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN
                     || FILESYSTEMS[ t ] .filesystem == FS_CLEARED
+                    || FILESYSTEMS[ t ] .filesystem == FS_BITLOCKER
                     || FILESYSTEMS[ t ] .filesystem == FS_LUKS
                     || FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWRAID
                     || FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWSUSPEND
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 809a2fb..0222d4e 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -52,6 +52,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
        {
                if (   f ->filesystem == FS_UNKNOWN
                    || f ->filesystem == FS_CLEARED
+                   || f ->filesystem == FS_BITLOCKER
                    || f ->filesystem == FS_LUKS
                    || f ->filesystem == FS_LINUX_SWRAID
                    || f ->filesystem == FS_LINUX_SWSUSPEND
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 362e22e..57cee05 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -116,6 +116,7 @@ void GParted_Core::find_supported_filesystems()
        FILESYSTEM_MAP[ FS_REISERFS ]        = new reiserfs() ;
        FILESYSTEM_MAP[ FS_UFS ]             = new ufs() ;
        FILESYSTEM_MAP[ FS_XFS ]             = new xfs() ;
+       FILESYSTEM_MAP[ FS_BITLOCKER ]       = NULL ;
        FILESYSTEM_MAP[ FS_LUKS ]            = NULL ;
        FILESYSTEM_MAP[ FS_LINUX_SWRAID ]    = NULL ;
        FILESYSTEM_MAP[ FS_LINUX_SWSUSPEND ] = NULL ;
@@ -1346,6 +1347,31 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
                return GParted::FS_BTRFS ;
        }
 
+       //bitlocker
+       //  Detecting BitLocker
+       //  http://blogs.msdn.com/b/si_team/archive/2006/10/26/detecting-bitlocker.aspx
+       //  Validation of BIOS Parameter Block fields is unnecessary for recognition only
+       const size_t BITLOCKER_SIG_OFFSET = 3UL ;
+       const char * const BITLOCKER_SIGNATURE = "-FVE-FS-" ;
+       const size_t BITLOCKER_SIG_LEN = strlen( BITLOCKER_SIGNATURE ) ;
+       buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
+       if ( buf )
+       {
+               memset( buf, 0, lp_device ->sector_size ) ;
+               if ( ped_device_open( lp_device ) )
+               {
+                       if ( ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) != 0 )
+                       {
+                               memcpy( magic1, buf + BITLOCKER_SIG_OFFSET, BITLOCKER_SIG_LEN ) ;
+                       }
+                       ped_device_close( lp_device );
+               }
+               free( buf ) ;
+
+               if ( 0 == memcmp( magic1, BITLOCKER_SIGNATURE, BITLOCKER_SIG_LEN ) )
+                       return FS_BITLOCKER ;
+       }
+
        //no file system found....
        Glib::ustring  temp = _( "Unable to detect file system! Possible reasons are:" ) ;
        temp += "\n- "; 
@@ -1474,6 +1500,7 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
                     ) &&
                     partitions[ t ] .filesystem != FS_LINUX_SWAP      &&
                     partitions[ t ] .filesystem != FS_LVM2_PV         &&
+                    partitions[ t ] .filesystem != FS_BITLOCKER       &&
                     partitions[ t ] .filesystem != FS_LUKS            &&
                     partitions[ t ] .filesystem != FS_LINUX_SWRAID    &&
                     partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
@@ -1546,6 +1573,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions, PedDis
        for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
        {
                if ( partitions[ t ] .filesystem != FS_UNKNOWN         &&
+                    partitions[ t ] .filesystem != FS_BITLOCKER       &&
                     partitions[ t ] .filesystem != FS_LUKS            &&
                     partitions[ t ] .filesystem != FS_LINUX_SWRAID    &&
                     partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
diff --git a/src/Utils.cc b/src/Utils.cc
index 65bc071..693b067 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -104,6 +104,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_PV         : return "#CC9966" ;    // ~ medium brown
+               case FS_BITLOCKER       : return "#494066" ;    //purple shadow
                case FS_LUKS            : return "#625B81" ;    //purple dark
                case FS_LINUX_SWRAID    : return "#5A4733" ;    // ~ dark brown
                case FS_LINUX_SWSUSPEND : return "#884631" ;    //red dark
@@ -233,6 +234,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
                case FS_USED            : return _("used") ;
                case FS_UNUSED          : return _("unused") ;
                case FS_LVM2_PV         : return "lvm2 pv" ;
+               case FS_BITLOCKER       : return "bitlocker" ;
                case FS_LUKS            : return "crypt-luks" ;
                case FS_LINUX_SWRAID    : return "linux-raid" ;
                case FS_LINUX_SWSUSPEND : return "linux-suspend" ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 6cf5a83..655548c 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -418,6 +418,7 @@ Gtk::Menu * Win_GParted::create_format_menu()
                //Skip non-file systems or file systems only recognised but not otherwise supported
                if (    fss[ t ] .filesystem == FS_UNKNOWN
                     || fss[ t ] .filesystem == FS_CLEARED
+                    || fss[ t ] .filesystem == FS_BITLOCKER
                     || fss[ t ] .filesystem == FS_LUKS
                     || fss[ t ] .filesystem == FS_LINUX_SWRAID
                     || fss[ t ] .filesystem == FS_LINUX_SWSUSPEND


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