Stop using member variables T & N in linux_swap, luks & lvm2_pv classes (!119)
Closes !119 - Tidy-ups for file system interface classes
This commit is contained in:
parent
ef3e1d1cce
commit
c7faeeeead
|
@ -79,7 +79,7 @@ void linux_swap::set_used_sectors( Partition & partition )
|
|||
{
|
||||
if ( partition .busy )
|
||||
{
|
||||
N = -1;
|
||||
long long used_kib = -1;
|
||||
std::string line ;
|
||||
std::ifstream input( "/proc/swaps" ) ;
|
||||
if ( input )
|
||||
|
@ -90,7 +90,7 @@ void linux_swap::set_used_sectors( Partition & partition )
|
|||
Glib::ustring filename = Utils::regexp_label( line, "^([[:graph:]]+)" );
|
||||
if ( bs_path == BlockSpecial( filename ) )
|
||||
{
|
||||
sscanf( line.c_str(), "%*s %*s %*d %lld", &N );
|
||||
sscanf(line.c_str(), "%*s %*s %*d %lld", &used_kib);
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
@ -100,14 +100,14 @@ void linux_swap::set_used_sectors( Partition & partition )
|
|||
{
|
||||
partition.push_back_message( "open(\"/proc/swaps\", O_RDONLY): " + Glib::strerror( errno ) );
|
||||
}
|
||||
if ( N > -1 )
|
||||
if (used_kib > -1)
|
||||
{
|
||||
// Ignore swap space reported size to ignore 1 page format
|
||||
// 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.
|
||||
Sector fs_size = partition.get_sector_length();
|
||||
Sector fs_used = N * KIBIBYTE / partition.sector_size;
|
||||
Sector fs_used = used_kib * KIBIBYTE / partition.sector_size;
|
||||
Sector fs_free = fs_size - fs_used;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ void luks::set_used_sectors( Partition & partition )
|
|||
if ( mapping.name.empty() )
|
||||
{
|
||||
// Inactive LUKS partition
|
||||
T = partition.get_sector_length();
|
||||
partition.set_sector_usage( T, 0 );
|
||||
Sector fs_size = partition.get_sector_length();
|
||||
partition.set_sector_usage(fs_size, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -81,14 +81,15 @@ bool lvm2_pv::is_busy( const Glib::ustring & path )
|
|||
return LVM2_PV_Info::has_active_lvs( path );
|
||||
}
|
||||
|
||||
|
||||
void lvm2_pv::set_used_sectors( Partition & partition )
|
||||
{
|
||||
T = (Sector) LVM2_PV_Info::get_size_bytes( partition.get_path() );
|
||||
N = (Sector) LVM2_PV_Info::get_free_bytes( partition.get_path() );
|
||||
if ( T > -1 && N > -1 )
|
||||
Byte_Value size_bytes = LVM2_PV_Info::get_size_bytes(partition.get_path());
|
||||
Byte_Value free_bytes = LVM2_PV_Info::get_free_bytes(partition.get_path());
|
||||
if (size_bytes > -1 && free_bytes > -1)
|
||||
{
|
||||
Sector fs_size = T / partition.sector_size;
|
||||
Sector fs_free = N / partition.sector_size;
|
||||
Sector fs_size = size_bytes / partition.sector_size;
|
||||
Sector fs_free = free_bytes / partition.sector_size;
|
||||
partition.set_sector_usage(fs_size, fs_free);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue