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:
    a54b52ea33
    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
This commit is contained in:
Mike Fleetwood 2021-10-31 11:36:58 +00:00
parent ed8ff63141
commit 824287e678
1 changed files with 7 additions and 6 deletions

View File

@ -2994,9 +2994,6 @@ bool GParted_Core::copy( const Partition & partition_src,
return false ; return false ;
} }
if ( ! check_repair_filesystem( filesystem_ptn_src, operationdetail ) )
return false;
if ( partition_dst.status == STAT_COPY ) if ( partition_dst.status == STAT_COPY )
{ {
// Handle situation where src sector size is smaller than dst sector size // 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 // linux-swap is recreated, not copied
return recreate_linux_swap_filesystem( filesystem_ptn_dst, operationdetail ); 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 // Copied into a bigger partition so maximise file system
return check_repair_filesystem( filesystem_ptn_dst, operationdetail ) return maximize_filesystem(filesystem_ptn_dst, operationdetail);
&& maximize_filesystem( filesystem_ptn_dst, operationdetail );
} }
return true; return true;
} }
bool GParted_Core::copy_filesystem( const Partition & partition_src, bool GParted_Core::copy_filesystem( const Partition & partition_src,
Partition & partition_dst, Partition & partition_dst,
OperationDetail & operationdetail ) OperationDetail & operationdetail )