Add Partition object resizing method Partition*::resize() (#774818)
Add a resize() method to both Partition and PartitionLUKS classes. They take a reference Partition object, and update the position, size and file system usage of *this Partition to match. This is ready for taking a partition returned from Resize/Move dialog and applying the change. Bug 774818 - Implement LUKS read-write actions NOT requiring a passphrase
This commit is contained in:
parent
30a0f4506c
commit
08e4ba4eca
|
@ -90,6 +90,7 @@ public:
|
|||
virtual Sector get_sectors_unused() const;
|
||||
virtual Sector get_sectors_unallocated() const;
|
||||
void get_usage_triple( int imax, int & i1, int & i2, int & i3 ) const ;
|
||||
virtual void resize( const Partition & new_size );
|
||||
|
||||
void Set_Unallocated( const Glib::ustring & device_path,
|
||||
bool whole_device,
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
virtual Sector get_sectors_used() const;
|
||||
virtual Sector get_sectors_unused() const;
|
||||
virtual Sector get_sectors_unallocated() const;
|
||||
virtual void resize( const Partition & new_size );
|
||||
virtual bool have_messages() const;
|
||||
virtual std::vector<Glib::ustring> get_messages() const;
|
||||
virtual void clear_messages();
|
||||
|
|
|
@ -163,6 +163,20 @@ Sector Partition::get_sectors_unallocated() const
|
|||
return sectors_unallocated ;
|
||||
}
|
||||
|
||||
// Update size, position and FS usage from new_size.
|
||||
void Partition::resize( const Partition & new_size )
|
||||
{
|
||||
sector_start = new_size.sector_start;
|
||||
sector_end = new_size.sector_end;
|
||||
alignment = new_size.alignment;
|
||||
free_space_before = new_size.free_space_before;
|
||||
strict_start = new_size.strict_start;
|
||||
|
||||
Sector fs_size = new_size.sectors_used + new_size.sectors_unused;
|
||||
Sector fs_unused = fs_size - new_size.sectors_used;
|
||||
set_sector_usage( fs_size, fs_unused );
|
||||
}
|
||||
|
||||
void Partition::Set_Unallocated( const Glib::ustring & device_path,
|
||||
bool whole_device,
|
||||
Sector sector_start,
|
||||
|
|
|
@ -196,6 +196,20 @@ Sector PartitionLUKS::get_sectors_unallocated() const
|
|||
return Partition::get_sectors_unallocated();
|
||||
}
|
||||
|
||||
// Update size, position and FS usage from new_size.
|
||||
void PartitionLUKS::resize( const Partition & new_size )
|
||||
{
|
||||
Partition::resize( new_size );
|
||||
// As per discussion in luks::set_used_sectors() LUKS itself is always 100% used.
|
||||
set_sector_usage( get_sector_length(), 0LL );
|
||||
|
||||
Sector mapping_size = get_sector_length() - header_size;
|
||||
encrypted.sector_end = mapping_size - 1LL;
|
||||
|
||||
Sector fs_unused = mapping_size - encrypted.sectors_used;
|
||||
encrypted.set_sector_usage( mapping_size, fs_unused );
|
||||
}
|
||||
|
||||
bool PartitionLUKS::have_messages() const
|
||||
{
|
||||
if ( busy )
|
||||
|
|
Loading…
Reference in New Issue