[gparted/8-shrinking-an-ext4-partition-does-not-respect-resize2fs-limits] Work in FS blocks until later while reading EXT2/3/4 usage (#8)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/8-shrinking-an-ext4-partition-does-not-respect-resize2fs-limits] Work in FS blocks until later while reading EXT2/3/4 usage (#8)
- Date: Tue, 31 Jul 2018 12:24:20 +0000 (UTC)
commit 469e99780120a3707d66312a3926ab997dc49d33
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Mon Jul 30 16:50:35 2018 +0100
Work in FS blocks until later while reading EXT2/3/4 usage (#8)
No functional change. Just work in FS block sized units until as late
as possible in ext2::set_used_sectors(), before converting to device
sector size units. This is to make the following change simpler and
easier to understand.
Closes #8 - Shrinking an EXT4 partition does not respect resize2fs
limits
src/ext2.cc | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/ext2.cc b/src/ext2.cc
index 7bd191fb..a2f5e1ec 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -160,16 +160,15 @@ void ext2::set_used_sectors( Partition & partition )
sscanf( output.substr( index ).c_str(), "Block size: %lld", &S ) != 1 )
S = -1 ;
- if ( T > -1 && S > -1 )
- T = Utils::round( T * ( S / double(partition .sector_size) ) ) ;
-
if ( partition .busy )
{
Byte_Value ignored ;
Byte_Value fs_free ;
if ( Utils::get_mounted_filesystem_usage( partition .get_mountpoint(),
ignored, fs_free, error ) == 0 )
- N = Utils::round( fs_free / double(partition .sector_size) ) ;
+ {
+ N = fs_free / S;
+ }
else
{
N = -1 ;
@@ -182,13 +181,13 @@ void ext2::set_used_sectors( Partition & partition )
if ( index >= output .length() ||
sscanf( output.substr( index ).c_str(), "Free blocks: %lld", &N ) != 1 )
N = -1 ;
-
- if ( N > -1 && S > -1 )
- N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
}
if ( T > -1 && N > -1 && S > -1 )
{
+ T = Utils::round( T * ( S / double(partition.sector_size) ) );
+ N = Utils::round( N * ( S / double(partition.sector_size) ) );
+
partition .set_sector_usage( T, N ) ;
partition.fs_block_size = S;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]