[anaconda:master 3/4] Be more restrictive displaying btrfs device type.
David Lehman
dlehman at redhat.com
Thu Oct 2 20:05:12 UTC 2014
On 09/30/2014 07:06 PM, mulhern wrote:
> Do not allow selection unless btrfs filesystem type is supported.
>
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
> pyanaconda/ui/gui/spokes/custom.py | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
> index e19d920..f46c6f6 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -1275,6 +1275,25 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
> device.originalFormat.type not in self._fs_types:
> self._fsCombo.append_text(device.originalFormat.name)
>
> + def _btrfs_in_typecombo(self, device):
> + """ Whether BTRFS should appear in device type combo box.
> +
> + :param device: the device being displayed
> + :type device: :class:`blivet.devices.StorageDevice`
> + :rtype: bool
> + :returns: True if BTRFS should appear, otherwise False
> + """
> + device = device.raw_device
Shouldn't matter since it is impossible to encrypt a btrfs volume or
subvolume -- you can only encrypt the member devices. Shouldn't hurt,
either, I guess.
> +
> + # The device is btrfs, so btrfs must be shown.
> + if device.type == "btrfs":
> + return True
You probably want device.type.startswith("btrfs") since it could be any
of "btrfs", "btrfs volume", "btrfs subvolume", "btrfs snapshot". I think
you could also check device.format.type for "btrfs".
> +
> + # Return True if btrfs filesystem is both allowed and supported.
> + fmt = getFormat("btrfs")
> + return fmt.supported and fmt.formattable and \
> + device.format.type not in PARTITION_ONLY_FORMAT_TYPES + ("swap",)
> +
Device existence doesn't factor in because of other logic, I assume.
> def _setup_device_type_combo(self, device, use_dev, device_name):
> # these device types should always be listed
> should_appear = {"DEVICE_TYPE_PARTITION", "DEVICE_TYPE_LVM", "DEVICE_TYPE_LVM_THINP"}
> @@ -1283,8 +1302,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
> if (use_dev.type == "mdarray" or len(self._clearpartDevices) > 1):
> should_appear.add("DEVICE_TYPE_MD")
>
> - # if the format is swap the device type can't be btrfs
> - if use_dev.format.type not in PARTITION_ONLY_FORMAT_TYPES + ("swap",):
> + if self._btrfs_in_typecombo(device):
> should_appear.add("DEVICE_TYPE_BTRFS")
>
> # only include disk if the current device is a disk
>
Looks good otherwise.
David
More information about the anaconda-patches
mailing list