[gparted] Fix regression when shrinking, moving and copying swap (#670017)



commit 93241cccbf4974a4a0ce4024cf94278f9ba3f386
Author: Curtis Gedak <gedakc gmail com>
Date:   Tue Feb 14 11:24:07 2012 -0700

    Fix regression when shrinking, moving and copying swap (#670017)
    
    Since linux-swap does not contain data and does not have a resize
    command, linux-swap is recreated instead of moved, copied, or resized.
    
    GParted 0.11.0 contained the following enhancement:
    Bug #663980 - Avoid redundant file system maximize actions
    
    An unfortunate side effect of this change was that the required
    maximize action to recreate linux-swap would not occur when the new
    size for the partition was less than or equal to the original size.
    
    The changes associated with this commit address this regression.
    
    Closes Bug #670017 - Corrupting swap partitions

 src/GParted_Core.cc |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 9d6ceb8..1f35b10 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1,5 +1,5 @@
 /* Copyright (C) 2004 Bart 'plors' Hakvoort
- * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -1887,8 +1887,10 @@ bool GParted_Core::move( const Device & device,
 
 		succes = (    succes
 		          && update_bootsector( partition_new, operationdetail )
-		          && (   //Do not maximize file system if new size <= old
-		                 ( partition_new .get_sector_length() <= partition_old .get_sector_length() )
+		          && (   //Do not maximize file system if FS not linux-swap and new size <= old
+		                 (   partition_new .filesystem != FS_LINUX_SWAP  //linux-swap is recreated, not moved
+		                  && partition_new .get_sector_length() <= partition_old .get_sector_length()
+		                 )
 		              || (   check_repair_filesystem( partition_new, operationdetail )
 		                  && maximize_filesystem( partition_new, operationdetail )
 		                 )
@@ -2039,8 +2041,10 @@ bool GParted_Core::resize( const Partition & partition_old,
 			succes = resize_move_partition( partition_old, partition_new, operationdetail ) ;
 
 		//expand file system to fit exactly in partition
-		if ( ! (   //Do not maximize file system if new size <= old
-		           ( partition_new .get_sector_length() <= partition_old .get_sector_length() )
+		if ( ! (   //Do not maximize file system if FS not linux-swap and new size <= old
+		           (   partition_new .filesystem != FS_LINUX_SWAP  //linux-swap is recreated, not resized
+		            && partition_new .get_sector_length() <= partition_old .get_sector_length()
+		           )
 		        || (   check_repair_filesystem( partition_new, operationdetail )
 		            && maximize_filesystem( partition_new, operationdetail )
 		           )
@@ -2366,8 +2370,10 @@ bool GParted_Core::copy( const Partition & partition_src,
 
 			return (   succes
 			        && update_bootsector( partition_dst, operationdetail )
-			        && (   //Do not maximize file system if destination size <= source
-			               ( partition_dst .get_sector_length() <= partition_src .get_sector_length() )
+			        && (   //Do not maximize file system if FS not linux-swap and destination size <= source
+			               (   partition_dst .filesystem != FS_LINUX_SWAP  //linux-swap is recreated, not copied
+			                && partition_dst .get_sector_length() <= partition_src .get_sector_length()
+			               )
 			            || (   check_repair_filesystem( partition_dst, operationdetail )
 			                && maximize_filesystem( partition_dst, operationdetail )
 			               )



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