[gparted] Avoid end partition overlap when resizing extended partition (#678831)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Avoid end partition overlap when resizing extended partition (#678831)
- Date: Sat, 30 Jun 2012 16:52:47 +0000 (UTC)
commit 6a6607e1c69728b2fd55faf7927db5c979628514
Author: Curtis Gedak <gedakc gmail com>
Date: Sat Jun 30 10:35:08 2012 -0600
Avoid end partition overlap when resizing extended partition (#678831)
When resizing an extended partition, a problem can occur with MiB
alignment wherein the requested end sector could be less than the end
sector of the last logical partition. This would be an invalid
geometry because all the logical partitions must be wholly contained
within the extended partition.
Check for this situation and if found then set requested end for
the extended partition to the end of the last logical partition.
Closes Bug #678831 - Partition End Overlap when Resizing Extended
Partition
src/GParted_Core.cc | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index b5b7423..a664d2b 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -566,6 +566,26 @@ bool GParted_Core::snap_to_mebibyte( const Device & device, Partition & partitio
}
}
+ //If this is an extended partition then check to see if the end of the
+ // extended partition encompasses the end of the last logical partition.
+ if ( partition .type == TYPE_EXTENDED )
+ {
+ //If there is logical partition that has an end sector beyond the
+ // end of the extended partition, then set the extended partition
+ // end sector to be the same as the end of the logical partition.
+ for ( unsigned int t = 0; t < partition .logicals .size(); t++ )
+ {
+ if ( ( partition .logicals[ t ] .type == TYPE_LOGICAL )
+ && ( ( partition .logicals[ t ] .sector_end )
+ > ( partition .sector_end )
+ )
+ )
+ {
+ partition .sector_end = partition .logicals[ t ] .sector_end ;
+ }
+ }
+ }
+
//If this is a GPT partition table and the partition ends less than 34 sectors
// from the end of the device, then reserve at least a mebibyte for the
// backup partition table
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]