[gparted] Remove incorrect rounding in file system resize (#723543)



commit 5f9a55fdcb37adc15655753dce1e714a3ab50075
Author: Phillip Susi <psusi ubuntu com>
Date:   Wed Feb 5 13:43:02 2014 -0500

    Remove incorrect rounding in file system resize (#723543)
    
    Work on bug 701075 inadvertently introduced a problem where ext2/3/4,
    resierfs, and ntfs file systems were rounding the file system size up
    to the nearest kiB.
    
    The problem was discovered when a user resized a partition by moving
    only the start boundary to the right thereby shrinking the partition.
    In the situation where the resulting partition size was not an integer
    kiB value (such as might occur on a 512 byte per sector device) the
    file system size was rounded up to the nearest kiB.  This resulted in
    a file system size being set one sector larger than the partition
    size.
    
    This problem was introduced with the following commit:
    
    Shrink file systems to exact size (#701075)
    3461413d283f1bac77e541b1054e775ec105212f
    
    The fix chosen for this problem involved removing the rounding logic.
    
    Bug 723543 - Shrink ext2/3/4 results in attempt to set partition
                 smaller than file system

 src/ext2.cc     |    4 ++--
 src/ntfs.cc     |    2 +-
 src/reiserfs.cc |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/ext2.cc b/src/ext2.cc
index 34f50ec..c77d49a 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -189,8 +189,8 @@ bool ext2::resize( const Partition & partition_new, OperationDetail & operationd
        Glib::ustring str_temp = "resize2fs -p " + partition_new .get_path() ;
        
        if ( ! fill_partition )
-               str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( 
-                                       partition_new .get_sector_length(), partition_new .sector_size, 
UNIT_KIB ) ) ) + "K" ;
+               str_temp += " " + Utils::num_to_str( floor( Utils::sector_to_unit(
+                                       partition_new .get_sector_length(), partition_new .sector_size, 
UNIT_KIB ) ) ) + "K";
 
        return ! execute_command( str_temp, operationdetail ) ;
 }
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 6ac19cb..61da501 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -203,7 +203,7 @@ bool ntfs::resize( const Partition & partition_new, OperationDetail & operationd
        Glib::ustring size = "" ;
        if ( ! fill_partition )
        {
-               size = " -s " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
+               size = " -s " + Utils::num_to_str( floor( Utils::sector_to_unit(
                                partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) 
) ;
        }
        Glib::ustring cmd = "ntfsresize --force --force" + size ;
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 2c44471..fc89a08 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -165,7 +165,7 @@ bool reiserfs::resize( const Partition & partition_new, OperationDetail & operat
        Glib::ustring size = "" ;
        if ( ! fill_partition )
        {
-               size = " -s " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
+               size = " -s " + Utils::num_to_str( floor( Utils::sector_to_unit(
                                   partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE 
) ) ) ;
        }
        Glib::ustring cmd = "sh -c 'echo y | resize_reiserfs" + size + " " + partition_new .get_path() + "'" ;


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