Stop using floating point calculation in most FS set_used_sectors() methods (!119)
Replace floating point calculation to convert size and space figures from file system block sized units to sectors with an integer calculation. Do this for the same reasons discussed in commit "Stop using floating point calculations in FS resize() methods" earlier in this patchset. This will limit the largest file system that GParted can read the usage of to 8 EiB - 1 bytes. There is still a floating point calculation in btrfs::set_used_sectors() which is being left because that is apportioning used space figure between multiple devices. Closes !119 - Tidy-ups for file system interface classes
This commit is contained in:
parent
10e9f14306
commit
92dfbac0d1
|
@ -212,10 +212,9 @@ void ext2::set_used_sectors( Partition & partition )
|
|||
|
||||
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 ) ;
|
||||
Sector fs_size = T * S / partition.sector_size;
|
||||
Sector fs_free = N * S / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
partition.fs_block_size = S;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,19 +106,21 @@ void linux_swap::set_used_sectors( Partition & partition )
|
|||
// overhead. Instead use partition size as sectors_fs_size so
|
||||
// reported used figure for active swap space starts from 0
|
||||
// upwards, matching what 'swapon -s' reports.
|
||||
T = partition.get_sector_length();
|
||||
N = Utils::round( N * ( KIBIBYTE / double(partition .sector_size) ) ) ;
|
||||
partition .set_sector_usage( T, T - N ) ;
|
||||
Sector fs_size = partition.get_sector_length();
|
||||
Sector fs_used = N * KIBIBYTE / partition.sector_size;
|
||||
Sector fs_free = fs_size - fs_used;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//By definition inactive swap space is 100% free
|
||||
Sector size = partition .get_sector_length() ;
|
||||
partition .set_sector_usage( size, size ) ;
|
||||
// By definition inactive swap space is 100% free.
|
||||
Sector fs_size = partition.get_sector_length();
|
||||
partition.set_sector_usage(fs_size, fs_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void linux_swap::read_label( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "swaplabel " + Glib::shell_quote( partition.get_path() ), output, error, true ) )
|
||||
|
|
|
@ -127,8 +127,8 @@ void luks::set_used_sectors( Partition & partition )
|
|||
else
|
||||
{
|
||||
// Active LUKS partition
|
||||
T = Utils::round( ( mapping.offset + mapping.length ) / double(partition.sector_size) );
|
||||
partition.set_sector_usage( T, 0 );
|
||||
Sector fs_size = (mapping.offset + mapping.length) / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,9 +87,9 @@ void lvm2_pv::set_used_sectors( Partition & partition )
|
|||
N = (Sector) LVM2_PV_Info::get_free_bytes( partition.get_path() );
|
||||
if ( T > -1 && N > -1 )
|
||||
{
|
||||
T = Utils::round( T / double(partition .sector_size) ) ;
|
||||
N = Utils::round( N / double(partition .sector_size) ) ;
|
||||
partition .set_sector_usage( T, N ) ;
|
||||
Sector fs_size = T / partition.sector_size;
|
||||
Sector fs_free = N / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> error_messages = LVM2_PV_Info::get_error_messages( partition.get_path() );
|
||||
|
|
|
@ -103,9 +103,9 @@ void nilfs2::set_used_sectors( Partition & partition )
|
|||
|
||||
if ( T > -1 && N > -1 && S > -1 )
|
||||
{
|
||||
T = Utils::round( T / double(partition .sector_size) ) ;
|
||||
N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
|
||||
partition .set_sector_usage( T, N ) ;
|
||||
Sector fs_size = T / partition.sector_size;
|
||||
Sector fs_free = N * S / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
partition.fs_block_size = S;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,9 @@ void reiser4::set_used_sectors( Partition & partition )
|
|||
|
||||
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 ) ;
|
||||
Sector fs_size = T * S / partition.sector_size;
|
||||
Sector fs_free = N * S / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
partition.fs_block_size = S;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,9 +103,9 @@ void reiserfs::set_used_sectors( Partition & partition )
|
|||
|
||||
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 ) ;
|
||||
Sector fs_size = T * S / partition.sector_size;
|
||||
Sector fs_free = N * S / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
partition.fs_block_size = S;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,9 +122,9 @@ void xfs::set_used_sectors( Partition & partition )
|
|||
|
||||
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 ) ;
|
||||
Sector fs_size = T * S / partition.sector_size;
|
||||
Sector fs_free = N * S / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
partition.fs_block_size = S;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue