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)
3461413d28

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
This commit is contained in:
Phillip Susi 2014-02-05 13:43:02 -05:00 committed by Curtis Gedak
parent 510e9eafc4
commit 5f9a55fdcb
3 changed files with 4 additions and 4 deletions

View File

@ -189,8 +189,8 @@ bool ext2::resize( const Partition & partition_new, OperationDetail & operationd
Glib::ustring str_temp = "resize2fs -p " + partition_new .get_path() ; Glib::ustring str_temp = "resize2fs -p " + partition_new .get_path() ;
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( str_temp += " " + Utils::num_to_str( floor( Utils::sector_to_unit(
partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K" ; partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K";
return ! execute_command( str_temp, operationdetail ) ; return ! execute_command( str_temp, operationdetail ) ;
} }

View File

@ -203,7 +203,7 @@ bool ntfs::resize( const Partition & partition_new, OperationDetail & operationd
Glib::ustring size = "" ; Glib::ustring size = "" ;
if ( ! fill_partition ) 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 ) ) ) ; partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) ) ;
} }
Glib::ustring cmd = "ntfsresize --force --force" + size ; Glib::ustring cmd = "ntfsresize --force --force" + size ;

View File

@ -165,7 +165,7 @@ bool reiserfs::resize( const Partition & partition_new, OperationDetail & operat
Glib::ustring size = "" ; Glib::ustring size = "" ;
if ( ! fill_partition ) 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 ) ) ) ; 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() + "'" ; Glib::ustring cmd = "sh -c 'echo y | resize_reiserfs" + size + " " + partition_new .get_path() + "'" ;