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:
parent
890d5a93a7
commit
93ccc79e3a
|
@ -205,6 +205,7 @@ private:
|
||||||
bool calculate_exact_geom( const Partition & partition_old,
|
bool calculate_exact_geom( const Partition & partition_old,
|
||||||
Partition & partition_new,
|
Partition & partition_new,
|
||||||
OperationDetail & operationdetail ) ;
|
OperationDetail & operationdetail ) ;
|
||||||
|
bool update_dmraid_entry( const Partition & partition_new, OperationDetail & operationdetail );
|
||||||
bool erase_filesystem_signatures( const Partition & partition, OperationDetail & operationdetail ) ;
|
bool erase_filesystem_signatures( const Partition & partition, OperationDetail & operationdetail ) ;
|
||||||
bool update_bootsector( const Partition & partition, OperationDetail & operationdetail ) ;
|
bool update_bootsector( const Partition & partition, OperationDetail & operationdetail ) ;
|
||||||
|
|
||||||
|
|
|
@ -2753,21 +2753,8 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
|
||||||
STATUS_NONE,
|
STATUS_NONE,
|
||||||
FONT_ITALIC ) ) ;
|
FONT_ITALIC ) ) ;
|
||||||
|
|
||||||
#ifndef USE_LIBPARTED_DMRAID
|
|
||||||
//update dev mapper entry if partition is dmraid.
|
//update dev mapper entry if partition is dmraid.
|
||||||
DMRaid dmraid ;
|
success = success && update_dmraid_entry( partition_new, operationdetail );
|
||||||
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
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3708,27 +3695,34 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
|
||||||
STATUS_NONE,
|
STATUS_NONE,
|
||||||
FONT_ITALIC ) ) ;
|
FONT_ITALIC ) ) ;
|
||||||
|
|
||||||
#ifndef USE_LIBPARTED_DMRAID
|
|
||||||
//Update dev mapper entry if partition is dmraid.
|
//Update dev mapper entry if partition is dmraid.
|
||||||
DMRaid dmraid ;
|
succes = succes && update_dmraid_entry( partition_new, operationdetail );
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
operationdetail.get_last_child().set_success_and_capture_errors( succes );
|
operationdetail.get_last_child().set_success_and_capture_errors( succes );
|
||||||
return 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 )
|
FileSystem * GParted_Core::get_filesystem_object( FILESYSTEM filesystem )
|
||||||
{
|
{
|
||||||
if ( FILESYSTEM_MAP .count( filesystem ) )
|
if ( FILESYSTEM_MAP .count( filesystem ) )
|
||||||
|
|
Loading…
Reference in New Issue