Add and use Partition::set_unpartitioned() method (#788308)
PATCHSET OVERVIEW: When unpartitioned drive read-write support was added this commit added a whole_device flag: 5098744f Add whole_device flag to the partition object (#743181) Using a whole_device flags now seems not the correct way to model unpartitioned drives. GParted models an uninitialised drive as: .path = _("uninitialized") .type = TYPE_UNALLOCATED .whole_device = true .filesystem = FS_UNALLOCATED and a whole drive file system, using ext4 for example, as: .path = "/dev/sdb" .type = TYPE_PRIMARY .whole_device = true .filesystem = FS_EXT4 No partitioning changed yet the type of the partition in the model changed between TYPE_UNALLOCATED and TYPE_PRIMARY depending on whether the whole drive contains a recognised file system or not. The partition object describing a file system within a LUKS encryption mapping is another case of the model not matching reality. .path = /dev/mapper/crypt_sdb1_crypt .type = TYPE_PRIMARY .whole_device = true .filesystem = FS_EXT4 There is no partition table within the encryption mapping, the file system fills it, but GParted records it as a primary partition. Make TYPE_UNALLOCATED and TYPE_PRIMARY be reserved for representing unallocated space and primary partitions within a partitioned disk drive and introduce new TYPE_UNPARTITIONED for all cases of an unpartitioned whole disk drive. The GParted UI does differentiate between an unallocated whole disk device and anything else by requiring a partition table to be created first, even if that is just the loop partition table. That determination can simply look for the partition object containing file system type FS_UNALLOCATED instead. THIS PATCH: Create set_unpartitioned() helper method to set a partition object to represent a whole disk drive and use everywhere such an object is modelled. This matches what existing methods Set_Unallocated() and indeed Set() do for unallocated space and any type of partition respectively. For now the partition type is still set to either TYPE_UNALLOCATED or TYPE_PRIMARY so the rest of the code base remains the same. TYPE_UNPARTITIONED will be introduced later. Bug 788308 - Remove whole_device partition flag
parent
70df61b9
Please register or sign in to comment