[gparted] Check copy destination instead of source (!95)(#723571)



commit 824287e6782ce073033c8f3b02e7affbb36f0e1e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Oct 31 11:36:58 2021 +0000

    Check copy destination instead of source (!95)(#723571)
    
    GParted currently performs these relevant steps for a copy operation:
    1.  Check source file system
    2.  Copy to destination
    3.  If destination partition is larger than source
    3.1.  check destination file system
    3.2.  grow destination file system
    
    Always checking the source was added by this commit:
        a54b52ea33abb1f5a44b52bcad5858ba41cd135d
        xfs copy now uses xfsdump and xfsrestore. icw some hacks in the other 2
        ...
        Also the source file system is now checked before the actual copy
        is performed.  If damaged beyond repair, the copy won't start.
    
    I think users have an expectation that a copy operation accesses the
    source read-only and performing a file system check on the source
    breaks that expectation.  Also uses may accidentally or deliberately try
    to copy a file system off a failing drive, where trying to check the
    source could lead to further data loss.  (ddrescue is the proper tool
    for recovering data from damaged drives but ddrescue is not a tool the
    user may know -- they know about GParted).
    
    For a failing drive, not checking the source first means the copy might
    fail instead, however a failed copy is preferable to greater chance of
    further damaging the source file system by checking it.
    
    In order to keep the new process as similar as possible to before,
    always check the destination instead.  This changes the copy operation
    from performing one or two file system checks to always performing only
    one check.  The new relevant copy operation steps are:
    1. Copy to destination
    2. check destination file system
    3. If destination partition is larger than source
    3.1.  grow destination file system
    
    This has exactly the same error handling as before, if the check of the
    destination file system fails the operation stops and any grow step
    won't be performed.  This represents the minimum change in behaviour
    from before.
    
    Bug 723571 - Copying ext4 partitions should not fix the source but the
                 destination
    Closes !95 - Check copy destination instead of source

 src/GParted_Core.cc | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index b85c0f0a..982bca30 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2994,9 +2994,6 @@ bool GParted_Core::copy( const Partition & partition_src,
                return false ;
        }
 
-       if ( ! check_repair_filesystem( filesystem_ptn_src, operationdetail ) )
-               return false;
-
        if ( partition_dst.status == STAT_COPY )
        {
                // Handle situation where src sector size is smaller than dst sector size
@@ -3024,15 +3021,19 @@ bool GParted_Core::copy( const Partition & partition_src,
                // linux-swap is recreated, not copied
                return recreate_linux_swap_filesystem( filesystem_ptn_dst, operationdetail );
        }
-       else if ( filesystem_ptn_dst.get_byte_length() > filesystem_ptn_src.get_byte_length() )
+
+       if (! check_repair_filesystem(filesystem_ptn_dst, operationdetail))
+               return false;
+
+       if (filesystem_ptn_dst.get_byte_length() > filesystem_ptn_src.get_byte_length())
        {
                // Copied into a bigger partition so maximise file system
-               return    check_repair_filesystem( filesystem_ptn_dst, operationdetail )
-                      && maximize_filesystem( filesystem_ptn_dst, operationdetail );
+               return maximize_filesystem(filesystem_ptn_dst, operationdetail);
        }
        return true;
 }
 
+
 bool GParted_Core::copy_filesystem( const Partition & partition_src,
                                     Partition & partition_dst,
                                     OperationDetail & operationdetail )


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