[gparted] Switch from whole_device flag to TYPE_UNPARTITIONED (#788308)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Switch from whole_device flag to TYPE_UNPARTITIONED (#788308)
- Date: Tue, 3 Oct 2017 16:35:58 +0000 (UTC)
commit ea269cc9294731a1d6a24610b8404441c14aca8b
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Fri Aug 19 17:19:55 2016 +0100
Switch from whole_device flag to TYPE_UNPARTITIONED (#788308)
Remove whole_device flag and replace with new partition type
TYPE_UNPARTITIONED. Minimally adapt the remaining code to compile and
run.
Bug 788308 - Remove whole_device partition flag
include/Partition.h | 3 ---
src/Dialog_Partition_New.cc | 4 +---
src/Dialog_Partition_Resize_Move.cc | 2 +-
src/Dialog_Rescue_Data.cc | 2 +-
src/GParted_Core.cc | 21 ++++++++++-----------
src/OperationFormat.cc | 2 +-
src/Partition.cc | 9 +--------
src/Win_GParted.cc | 22 +++++++++++++---------
8 files changed, 28 insertions(+), 37 deletions(-)
---
diff --git a/include/Partition.h b/include/Partition.h
index 433d771..44af7a8 100644
--- a/include/Partition.h
+++ b/include/Partition.h
@@ -76,7 +76,6 @@ public:
const Glib::ustring & partition,
int partition_number,
PartitionType type,
- bool whole_device,
FILESYSTEM filesystem,
Sector sector_start,
Sector sector_end,
@@ -94,7 +93,6 @@ public:
virtual void resize( const Partition & new_size );
void Set_Unallocated( const Glib::ustring & device_path,
- bool whole_device,
Sector sector_start,
Sector sector_end,
Byte_Value sector_size,
@@ -154,7 +152,6 @@ public:
Glib::ustring device_path ;
int partition_number;
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
- bool whole_device; // Is this a virtual partition spanning a whole unpartitioned disk device?
PartitionStatus status; //STAT_REAL, STAT_NEW, etc..
PartitionAlignment alignment; //ALIGN_CYLINDER, ALIGN_STRICT, etc
FILESYSTEM filesystem ;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index c2f5401..ccb5a1d 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -226,13 +226,12 @@ const Partition & Dialog_Partition_New::Get_New_Partition()
// Copy a final few values needed from the original unallocated partition before
// resetting the Partition object and populating it as the new partition.
Glib::ustring device_path = new_partition->device_path;
- bool whole_device = new_partition->whole_device;
Sector sector_size = new_partition->sector_size;
bool inside_extended = new_partition->inside_extended;
new_partition->Reset();
new_partition->Set( device_path,
String::ucompose( _("New Partition #%1"), new_count ),
- new_count, part_type, whole_device,
+ new_count, part_type,
FILESYSTEMS[optionmenu_filesystem.get_history()].filesystem,
new_start, new_end,
sector_size,
@@ -301,7 +300,6 @@ const Partition & Dialog_Partition_New::Get_New_Partition()
{
Partition * unallocated = new Partition();
unallocated->Set_Unallocated( new_partition->device_path,
- new_partition->whole_device,
new_partition->sector_start,
new_partition->sector_end,
new_partition->sector_size,
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index 2dea1f2..2ad8cea 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -90,7 +90,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & p
}
// See if we can allow the start of the file system to move
- if ( fs.move && ! new_partition->busy && ! new_partition->whole_device )
+ if ( fs.move && ! new_partition->busy && new_partition->type != TYPE_UNPARTITIONED )
{
set_title( String::ucompose( _("Resize/Move %1"), new_partition->get_path() ) );
frame_resizer_base ->set_fixed_start( false ) ;
diff --git a/src/Dialog_Rescue_Data.cc b/src/Dialog_Rescue_Data.cc
index 295ec5c..f46dfb4 100644
--- a/src/Dialog_Rescue_Data.cc
+++ b/src/Dialog_Rescue_Data.cc
@@ -431,7 +431,7 @@ void Dialog_Rescue_Data::read_partitions_from_buffer()
Partition * part = new Partition();
part->Set( dev_path, part_path, part_num,
- type, false, fs, sec_start, sec_end, sec_size, false, false );
+ type, fs, sec_start, sec_end, sec_size, false, false );
this->partitions.push_back_adopt( part );
}
}
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 3447f62..9d3f5c6 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1100,7 +1100,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
lp_partition->num,
( lp_partition->type == PED_PARTITION_NORMAL ) ?
TYPE_PRIMARY
:
TYPE_LOGICAL,
- false,
filesystem,
lp_partition->geom.start,
lp_partition->geom.end,
@@ -1124,7 +1123,6 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
partition_path,
lp_partition->num,
TYPE_EXTENDED,
- false,
FS_EXTENDED,
lp_partition->geom.start,
lp_partition->geom.end,
@@ -1557,7 +1555,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
if ( partitions .empty() )
{
Partition * partition_temp = new Partition();
- partition_temp->Set_Unallocated( device_path, false, start, end, sector_size, inside_extended
);
+ partition_temp->Set_Unallocated( device_path, start, end, sector_size, inside_extended );
partitions.push_back_adopt( partition_temp );
return ;
}
@@ -1567,7 +1565,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
{
Sector temp_end = partitions.front().sector_start - 1;
Partition * partition_temp = new Partition();
- partition_temp->Set_Unallocated( device_path, false, start, temp_end, sector_size,
inside_extended );
+ partition_temp->Set_Unallocated( device_path, start, temp_end, sector_size, inside_extended );
partitions.insert_adopt( partitions.begin(), partition_temp );
}
@@ -1583,7 +1581,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
Sector temp_start = partitions[t].sector_end + 1;
Sector temp_end = partitions[t+1].sector_start - 1;
Partition * partition_temp = new Partition();
- partition_temp->Set_Unallocated( device_path, false, temp_start, temp_end,
+ partition_temp->Set_Unallocated( device_path, temp_start, temp_end,
sector_size, inside_extended );
partitions.insert_adopt( partitions.begin() + ++t, partition_temp );
}
@@ -1594,7 +1592,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
{
Sector temp_start = partitions.back().sector_end + 1;
Partition * partition_temp = new Partition();
- partition_temp->Set_Unallocated( device_path, false, temp_start, end, sector_size,
inside_extended );
+ partition_temp->Set_Unallocated( device_path, temp_start, end, sector_size, inside_extended );
partitions.push_back_adopt( partition_temp );
}
}
@@ -2669,7 +2667,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
const Partition & partition_new,
OperationDetail & operationdetail )
{
- if ( partition_new.whole_device )
+ if ( partition_new.type == TYPE_UNPARTITIONED )
// Trying to resize/move a non-partitioned whole disk device is a
// successful non-operation.
return true;
@@ -3454,7 +3452,7 @@ bool GParted_Core::check_repair_maximize( const Partition & partition,
bool GParted_Core::set_partition_type( const Partition & partition, OperationDetail & operationdetail )
{
- if ( partition.whole_device )
+ if ( partition.type == TYPE_UNPARTITIONED )
// Trying to set the type of a partition on a non-partitioned whole disk
// device is a successful non-operation.
return true;
@@ -3560,7 +3558,7 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
PedDisk* lp_disk = NULL ;
if ( get_device( partition.device_path, lp_device ) )
{
- if ( partition.whole_device )
+ if ( partition.type == TYPE_UNPARTITIONED )
{
// Virtual partition spanning whole disk device
success = true;
@@ -3622,7 +3620,8 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
*/
String::ucompose( _("path: %1 (%2)"),
partition.get_path(),
- ( partition.whole_device ) ? _("device")
+ ( partition.type == TYPE_UNPARTITIONED )
+ ? _("device")
: _("partition")
) + "\n" +
String::ucompose( _("start: %1"), partition .sector_start ) +
"\n" +
String::ucompose( _("end: %1"), partition .sector_end ) +
"\n" +
@@ -3799,7 +3798,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition, Ope
char * buf = NULL ;
if ( get_device( partition.device_path, lp_device ) )
{
- if ( partition.whole_device )
+ if ( partition.type == TYPE_UNPARTITIONED )
{
// Virtual partition spanning whole disk device
overall_success = true;
diff --git a/src/OperationFormat.cc b/src/OperationFormat.cc
index 710893b..01b8aa7 100644
--- a/src/OperationFormat.cc
+++ b/src/OperationFormat.cc
@@ -45,7 +45,7 @@ void OperationFormat::apply_to_visual( PartitionVector & partitions )
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later
- if ( partition_original->whole_device && partition_new->filesystem == FS_CLEARED )
+ if ( partition_original->type == TYPE_UNPARTITIONED && partition_new->filesystem == FS_CLEARED )
{
// Make format to cleared whole disk device file system preview as
// unallocated device, matching what happens when implemented.
diff --git a/src/Partition.cc b/src/Partition.cc
index 6194985..d406599 100644
--- a/src/Partition.cc
+++ b/src/Partition.cc
@@ -40,7 +40,6 @@ void Partition::Reset()
messages .clear() ;
status = GParted::STAT_REAL ;
type = GParted::TYPE_UNALLOCATED ;
- whole_device = false;
alignment = ALIGN_STRICT ;
filesystem = GParted::FS_UNALLOCATED ;
have_filesystem_label = false;
@@ -62,7 +61,6 @@ void Partition::Set( const Glib::ustring & device_path,
const Glib::ustring & partition,
int partition_number,
PartitionType type,
- bool whole_device,
FILESYSTEM filesystem,
Sector sector_start,
Sector sector_end,
@@ -74,7 +72,6 @@ void Partition::Set( const Glib::ustring & device_path,
this->path = partition;
this ->partition_number = partition_number;
this ->type = type;
- this->whole_device = whole_device;
this ->filesystem = filesystem;
this ->sector_start = sector_start;
this ->sector_end = sector_end;
@@ -178,7 +175,6 @@ void Partition::resize( const Partition & new_size )
}
void Partition::Set_Unallocated( const Glib::ustring & device_path,
- bool whole_device,
Sector sector_start,
Sector sector_end,
Byte_Value sector_size,
@@ -190,7 +186,6 @@ void Partition::Set_Unallocated( const Glib::ustring & device_path,
Utils::get_filesystem_string( FS_UNALLOCATED ),
-1,
TYPE_UNALLOCATED,
- whole_device,
FS_UNALLOCATED,
sector_start,
sector_end,
@@ -223,9 +218,7 @@ void Partition::set_unpartitioned( const Glib::ustring & device_path,
( fstype == FS_UNALLOCATED ) ? Utils::get_filesystem_string( FS_UNALLOCATED )
: partition_path,
1,
- // FIXME: Replace with TYPE_UNPARTITIONED when whole_device member is removed
- ( fstype == FS_UNALLOCATED ) ? TYPE_UNALLOCATED : TYPE_PRIMARY,
- true,
+ TYPE_UNPARTITIONED,
fstype,
0LL,
length - 1LL,
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 24e46f6..8e8e047 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1134,7 +1134,6 @@ void Win_GParted::set_valid_operations()
// Allow partition flag management
if ( selected_partition_ptr->status == STAT_REAL &&
- ! selected_partition_ptr->whole_device &&
( selected_partition_ptr->type == TYPE_PRIMARY ||
selected_partition_ptr->type == TYPE_LOGICAL ||
selected_partition_ptr->type == TYPE_EXTENDED ) )
@@ -1243,14 +1242,18 @@ void Win_GParted::set_valid_operations()
return ;
}
- // PRIMARY and LOGICAL
- if ( selected_partition_ptr->type == TYPE_PRIMARY || selected_partition_ptr->type == TYPE_LOGICAL )
+ // PRIMARY, LOGICAL and UNPARTITIONED; partitions with supported file system.
+ if ( selected_partition_ptr->type == TYPE_PRIMARY ||
+ selected_partition_ptr->type == TYPE_LOGICAL ||
+ selected_partition_ptr->type == TYPE_UNPARTITIONED )
{
allow_format( true ) ;
// only allow deletion of partitions within a partition table
// Also exclude open LUKS mappings until open/close is supported
- if ( ! selected_partition_ptr->whole_device & ! selected_partition_ptr->busy )
+ if ( ( selected_partition_ptr->type == TYPE_PRIMARY ||
+ selected_partition_ptr->type == TYPE_LOGICAL ) &&
+ ! selected_partition_ptr->busy )
allow_delete( true );
// Resizing/moving always requires the ability to update the partition
@@ -1922,8 +1925,9 @@ void Win_GParted::activate_paste()
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid
display partition object
- // Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
- if ( selected_partition_ptr->whole_device && selected_partition_ptr->type == TYPE_UNALLOCATED )
+ // Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized")
+ if ( selected_partition_ptr->type == TYPE_UNPARTITIONED &&
+ selected_partition_ptr->filesystem == FS_UNALLOCATED )
{
show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
return ;
@@ -2079,8 +2083,9 @@ void Win_GParted::activate_new()
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid
display partition object
- // Unrecognised whole disk device (See GParted_Core::get_devices_threads(), "unrecognized")
- if ( selected_partition_ptr->whole_device && selected_partition_ptr->type == TYPE_UNALLOCATED )
+ // Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized")
+ if ( selected_partition_ptr->type == TYPE_UNPARTITIONED &&
+ selected_partition_ptr->filesystem == FS_UNALLOCATED )
{
show_disklabel_unrecognized( devices [current_device ] .get_path() ) ;
}
@@ -2331,7 +2336,6 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
filesystem_ptn.get_path(),
filesystem_ptn.partition_number,
filesystem_ptn.type,
- filesystem_ptn.whole_device,
new_fs,
filesystem_ptn.sector_start,
filesystem_ptn.sector_end,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]