[gparted] Make copy into existing whole disk device file systems work (#743181)



commit 85a6c88eee59bb0f36a79c0d6450d133e4a03883
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Jan 12 14:52:45 2015 +0000

    Make copy into existing whole disk device file systems work (#743181)
    
    First, copying into a whole disk device fails on the set partition type
    step.  Fails with either libparted error "The flag 'lvm' is not
    available for loop disk labels" or "unrecognised disk label" depending
    whether libparted recognised the content and created a virtual partition
    or not.  (This is with libparted 2.4).
    
    Fix by just skipping setting the partition type on whole disk devices.
    
    Second, if any file system specific tools are used during the copy, they
    will fail because they are passed the device name as "copy of /dev/SRC"
    instead of "/dev/DST".  Occurs when either the destination whole disk
    device is not an identical size to the source so the file system check
    and grow steps are added, or when file system specific tools are used to
    copy the file system as with XFS or recent EXT2/3/4 tools.
    
    Fix by re-adding the real partition path from libparted for whole disk
    devices, as is already done for partitioned device names in
    GParted_Core::calibrate_partition().
    
    Bug 743181 - Add unpartitioned drive read-write support

 src/GParted_Core.cc |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index ff4e393..569afb4 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2821,7 +2821,13 @@ bool GParted_Core::copy( const Partition & partition_src,
                        succes = create_partition( partition_dst, operationdetail, ( (min_size + 
(partition_dst .sector_size - 1)) / partition_dst .sector_size ) ) ;
                }
 
-               if ( succes && set_partition_type( partition_dst, operationdetail ) )
+               if ( succes && ! partition_dst.whole_device )
+               {
+                       // Only set type of partition on a partitioned device.
+                       succes = set_partition_type( partition_dst, operationdetail );
+               }
+
+               if ( succes )
                {
                        operationdetail .add_child( OperationDetail( 
                                String::ucompose( _("copy file system of %1 to %2"),
@@ -3170,6 +3176,11 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
                        if ( partition.whole_device )
                        {
                                // Virtual partition spanning whole disk device
+
+                               // Re-add the real partition path from libparted.
+                               // (See just below for why this is needed).
+                               partition.add_path( lp_device->path );
+
                                success = true;
                        }
                        else if ( get_disk( lp_device, lp_disk ) )


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