Extract common code into update_dmraid_entry() (#791875)

Extract common code which updates a DMRaid device mapper entry into a
sub-function.  This will also be needed when adding rollback of a
partition change on failure.

Bug 791875 - Rollback specific failed partition change steps
This commit is contained in:
Mike Fleetwood 2017-12-28 12:08:25 +00:00 committed by Curtis Gedak
parent 890d5a93a7
commit 93ccc79e3a
2 changed files with 23 additions and 28 deletions

View File

@ -205,6 +205,7 @@ private:
bool calculate_exact_geom( const Partition & partition_old,
Partition & partition_new,
OperationDetail & operationdetail ) ;
bool update_dmraid_entry( const Partition & partition_new, OperationDetail & operationdetail );
bool erase_filesystem_signatures( const Partition & partition, OperationDetail & operationdetail ) ;
bool update_bootsector( const Partition & partition, OperationDetail & operationdetail ) ;

View File

@ -2753,21 +2753,8 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
STATUS_NONE,
FONT_ITALIC ) ) ;
#ifndef USE_LIBPARTED_DMRAID
//update dev mapper entry if partition is dmraid.
DMRaid dmraid ;
if ( success && dmraid.is_dmraid_device( partition_new.device_path ) )
{
PedDevice* lp_device = NULL ;
PedDisk* lp_disk = NULL ;
//Open disk handle before and close after to prevent application crash.
if ( get_device_and_disk( partition_new .device_path, lp_device, lp_disk ) )
{
success = dmraid.update_dev_map_entry( partition_new, operationdetail.get_last_child() );
destroy_device_and_disk( lp_device, lp_disk ) ;
}
}
#endif
success = success && update_dmraid_entry( partition_new, operationdetail );
}
else
{
@ -3708,27 +3695,34 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
STATUS_NONE,
FONT_ITALIC ) ) ;
#ifndef USE_LIBPARTED_DMRAID
//Update dev mapper entry if partition is dmraid.
DMRaid dmraid ;
if ( succes && dmraid .is_dmraid_device( partition_new .device_path ) )
{
PedDevice* lp_device = NULL ;
PedDisk* lp_disk = NULL ;
//Open disk handle before and close after to prevent application crash.
if ( get_device_and_disk( partition_new .device_path, lp_device, lp_disk ) )
{
succes = dmraid .update_dev_map_entry( partition_new, operationdetail .get_last_child() ) ;
destroy_device_and_disk( lp_device, lp_disk ) ;
}
}
#endif
succes = succes && update_dmraid_entry( partition_new, operationdetail );
}
operationdetail.get_last_child().set_success_and_capture_errors( succes );
return succes ;
}
bool GParted_Core::update_dmraid_entry( const Partition & partition, OperationDetail & operationdetail )
{
bool success = true;
#ifndef USE_LIBPARTED_DMRAID
DMRaid dmraid;
if ( dmraid.is_dmraid_device( partition.device_path ) )
{
PedDevice *lp_device = NULL;
PedDisk *lp_disk;
// Open disk handle before and close after to prevent application crash.
if ( get_device_and_disk( partition.device_path, lp_device, lp_disk ) )
{
success = dmraid.update_dev_map_entry( partition, operationdetail.get_last_child() );
destroy_device_and_disk( lp_device, lp_disk );
}
}
#endif
return success;
}
FileSystem * GParted_Core::get_filesystem_object( FILESYSTEM filesystem )
{
if ( FILESYSTEM_MAP .count( filesystem ) )