[gparted] Add Partition object resizing method Partition*::resize() (#774818)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add Partition object resizing method Partition*::resize() (#774818)
- Date: Sat, 14 Jan 2017 15:54:11 +0000 (UTC)
commit 08e4ba4ecab2325be6542ff60530408bc245e493
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Dec 4 20:44:46 2016 +0000
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
include/Partition.h | 1 +
include/PartitionLUKS.h | 1 +
src/Partition.cc | 14 ++++++++++++++
src/PartitionLUKS.cc | 14 ++++++++++++++
4 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index eb70724..b9b1414 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -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,
diff --git a/include/PartitionLUKS.h b/include/PartitionLUKS.h
index 7dd7654..7acc86b 100644
--- a/include/PartitionLUKS.h
+++ b/include/PartitionLUKS.h
@@ -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();
diff --git a/src/Partition.cc b/src/Partition.cc
index 93d0dbb..723e823 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -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,
diff --git a/src/PartitionLUKS.cc b/src/PartitionLUKS.cc
index e927676..3ac6756 100644
--- a/src/PartitionLUKS.cc
+++ b/src/PartitionLUKS.cc
@@ -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 )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]