diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 9ca0961a..b207e4c1 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -3167,55 +3167,54 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet PedDisk* lp_disk = NULL ; if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) { - //Lookup libparted file system type using GParted's name, as most match - PedFileSystemType * fs_type = - ped_file_system_type_get( Utils::get_filesystem_string( partition .filesystem ) .c_str() ) ; - - //If not found, and FS is linux-swap, then try linux-swap(v1) - if ( ! fs_type && Utils::get_filesystem_string( partition .filesystem ) == "linux-swap" ) - fs_type = ped_file_system_type_get( "linux-swap(v1)" ) ; - - //If not found, and FS is linux-swap, then try linux-swap(new) - if ( ! fs_type && Utils::get_filesystem_string( partition .filesystem ) == "linux-swap" ) - fs_type = ped_file_system_type_get( "linux-swap(new)" ) ; - - //default is Linux (83) - if ( ! fs_type ) - fs_type = ped_file_system_type_get( "ext2" ) ; - - if ( fs_type && partition .filesystem != FS_LVM2_PV ) + PedPartition* lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition.get_sector() ); + if ( lp_partition ) { - PedPartition* lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; + Glib::ustring fs_type = Utils::get_filesystem_string( partition.filesystem ); - //Also clear any libparted LVM flag so that it doesn't override the file system type - if ( lp_partition && - ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 0 ) && - ped_partition_set_system( lp_partition, fs_type ) && - commit( lp_disk ) ) + // Lookup libparted file system type using GParted's name, as most match + PedFileSystemType * lp_fs_type = ped_file_system_type_get( fs_type.c_str() ); + + // If not found, and FS is linux-swap, then try linux-swap(v1) + if ( ! lp_fs_type && fs_type == "linux-swap" ) + lp_fs_type = ped_file_system_type_get( "linux-swap(v1)" ); + + // If not found, and FS is linux-swap, then try linux-swap(new) + if ( ! lp_fs_type && fs_type == "linux-swap" ) + lp_fs_type = ped_file_system_type_get( "linux-swap(new)" ); + + // default is Linux (83) + if ( ! lp_fs_type ) + lp_fs_type = ped_file_system_type_get( "ext2" ); + + if ( lp_fs_type && partition.filesystem != FS_LVM2_PV ) { - operationdetail .get_last_child() .add_child( - OperationDetail( String::ucompose( _("new partition type: %1"), - lp_partition ->fs_type ->name ), - STATUS_NONE, - FONT_ITALIC ) ) ; - - return_value = true ; + // Also clear any libparted LVM flag so that it doesn't + // override the file system type + if ( ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 0 ) && + ped_partition_set_system( lp_partition, lp_fs_type ) && + commit( lp_disk ) ) + { + operationdetail.get_last_child().add_child( + OperationDetail( String::ucompose( _("new partition type: %1"), + lp_partition->fs_type->name ), + STATUS_NONE, + FONT_ITALIC ) ); + return_value = true; + } } - } - else if ( partition .filesystem == FS_LVM2_PV ) - { - PedPartition* lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; - - if ( lp_partition && - ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 1 ) && - commit( lp_disk ) ) + else if ( partition.filesystem == FS_LVM2_PV ) { - operationdetail .get_last_child() .add_child( - OperationDetail( String::ucompose( _("new partition flag: %1"), - ped_partition_flag_get_name( PED_PARTITION_LVM ) ), - STATUS_NONE, - FONT_ITALIC ) ) ; - return_value = true ; + if ( ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 1 ) && + commit( lp_disk ) ) + { + operationdetail.get_last_child().add_child( + OperationDetail( String::ucompose( _("new partition flag: %1"), + ped_partition_flag_get_name( PED_PARTITION_LVM ) ), + STATUS_NONE, + FONT_ITALIC ) ); + return_value = true; + } } }