Only set lvm partition flag on tables which support it (#746204)

Attempting to create a new partition on a pc98 partition table fails
with the following libparted error:

    The flag 'lvm' is not available for pc98 disk labels.

This has been broken since LVM2 Physical Volume read-write support was
first added in this commit:

    c3ab62591b
    Add creation of LVM2 PVs (#670171)

Fix by only clearing and setting the lvm partition flag when the type of
the partition table supports it.  When creating a partition to contain
an LVM2 PV and the lvm flag is not support add the following message to
the operation results to explain that setting the lvm partition flag was
skipped and why:

    Skip setting unsupported partition flag: lvm

Bug 746204 - Creating partitions on pc98 table fails with lvm flag not
             available
This commit is contained in:
Mike Fleetwood 2015-03-14 10:43:59 +00:00 committed by Curtis Gedak
parent c882666e3a
commit e9cc0b15a5

View file

@ -3187,13 +3187,16 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
if ( ! lp_fs_type )
lp_fs_type = ped_file_system_type_get( "ext2" );
bool supports_lvm_flag = ped_partition_is_flag_available( lp_partition, PED_PARTITION_LVM );
if ( lp_fs_type && partition.filesystem != FS_LVM2_PV )
{
// 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 ) )
if ( ( ! supports_lvm_flag ||
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"),
@ -3205,7 +3208,8 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
}
else if ( partition.filesystem == FS_LVM2_PV )
{
if ( ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 1 ) &&
if ( supports_lvm_flag &&
ped_partition_set_flag( lp_partition, PED_PARTITION_LVM, 1 ) &&
commit( lp_disk ) )
{
operationdetail.get_last_child().add_child(
@ -3215,6 +3219,15 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
FONT_ITALIC ) );
return_value = true;
}
else if ( ! supports_lvm_flag )
{
operationdetail.get_last_child().add_child(
OperationDetail( String::ucompose( _("Skip setting unsupported partition flag: %1"),
ped_partition_flag_get_name( PED_PARTITION_LVM ) ),
STATUS_NONE,
FONT_ITALIC ) );
return_value = true;
}
}
}