[gparted] Correct whole disk device file system format to cleared preview (#743181)



commit 63f701033ebd30d948ce3c885f3475f6ef210013
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Feb 17 15:14:23 2015 +0000

    Correct whole disk device file system format to cleared preview (#743181)
    
    The preview of clearing a whole disk device file system was previewing
    the same as formatting to all other file system types; as a cleared file
    system spanning the whole disk device.  However when implemented this
    removes all signatures on the disk so it actually becomes an unallocated
    and unpartitioned device.  Make the preview match what happens in when
    implemented.
    
    GParted previously used mydevice.max_prims = -1 to represent an
    unpartitioned device.  It is now represented as:
    
        mydevice.max_prims = 1
        mydevice.disktype  = _("unrecognized")
        mydevice.partitions[0].type         = TYPE_UNALLOCATED
        mydevice.partitions[0].whole_device = true
        mydevice.partitions[0].filesystem   = FS_UNALLOCATED
    
    and the check for an unpartitioned device in Win_GParted.cc becomes:
    
        partitions[0].type == TYPE_UNALLOCATED && partitions[0].whole_device
    
    Bug 743181 - Add unpartitioned drive read-write support

 src/GParted_Core.cc    |    2 +-
 src/OperationFormat.cc |   17 ++++++++++++++++-
 src/Win_GParted.cc     |    8 ++++----
 3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index f3963af..55ea9ce 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -385,7 +385,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
                                                 * disk device is unknown or not recognized.
                                                 */
                                                _("unrecognized") ;
-                                       temp_device.max_prims = -1;
+                                       temp_device.max_prims = 1;
 
                                        Partition partition_temp;
                                        partition_temp.Set_Unallocated( temp_device .get_path(),
diff --git a/src/OperationFormat.cc b/src/OperationFormat.cc
index dbbf465..a26807b 100644
--- a/src/OperationFormat.cc
+++ b/src/OperationFormat.cc
@@ -32,7 +32,22 @@ OperationFormat::OperationFormat( const Device & device,
        
 void OperationFormat::apply_to_visual( std::vector<Partition> & partitions ) 
 {
-       if ( partition_original .inside_extended )
+       if ( partition_original.whole_device && partition_new.filesystem == FS_CLEARED )
+       {
+               // Make format to cleared whole disk device file system preview as
+               // unallocated device, matching what happens when implemented.
+               partitions.clear();
+
+               Partition temp_partition;
+               temp_partition.Set_Unallocated( device.get_path(),
+                                               true,
+                                               0LL,
+                                               device.length -1LL,
+                                               device.sector_size,
+                                               false );
+               partitions.push_back( temp_partition );
+       }
+       else if ( partition_original.inside_extended )
        {
                index_extended = find_index_extended( partitions ) ;
                
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 1cf0e77..fac415a 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1718,8 +1718,8 @@ void Win_GParted::activate_copy()
 
 void Win_GParted::activate_paste()
 {
-       //if max_prims == -1 the current device has an unrecognised disklabel (see also 
GParted_Core::get_devices)
-       if ( devices [ current_device ] .max_prims == -1 )
+       // Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
+       if ( selected_partition.whole_device && selected_partition.type == TYPE_UNALLOCATED )
        {
                show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
                return ;
@@ -1822,8 +1822,8 @@ void Win_GParted::activate_paste()
 
 void Win_GParted::activate_new()
 {
-       //if max_prims == -1 the current device has an unrecognised disklabel (see also 
GParted_Core::get_devices)
-       if ( devices [ current_device ] .max_prims == -1 )
+       // Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
+       if ( selected_partition.whole_device && selected_partition.type == TYPE_UNALLOCATED )
        {
                show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
        }


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