Re: [PATCH f12-branch] Reset parted flags in createFormat not destroyFormat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good. I had plans to do this in the initial implementation but it
got lost in the melee.

Dave

On Thu, 2009-10-08 at 12:19 +0200, Hans de Goede wrote:
> We were resetting the parted flags for re-use of existing partitions in
> destroyFormat, but this assumes that the existing partition actually has
> a type in the partition table matching its current formatting, this has 2
> problems:
> 1: If the partition has a type which needs to have flags reset to become
>    the correct type for the new format (for example swap -> ext2), but it
>    is not formatted, the flags wont get reset
> 2: If the partition has a type which does not match the formatting (for
>    example type linux raid, formatting ext2), the flags won't get reset
> 
> This patch moves the resetting of the flags to the creation of the new
> format, and resets all flags except for the one for the to be created
> format (and boot and lba which are special).
> 
> For the F-12 branch this also has the benefit that the resetting of the flags
> happens at all, as there the resetting was happening on a deep copy of the
> device (and thus the label) and never actually got written to the disk.
> ---
>  storage/deviceaction.py |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)



> 
> diff --git a/storage/deviceaction.py b/storage/deviceaction.py
> index a01ee41..1f8d5a7 100644
> --- a/storage/deviceaction.py
> +++ b/storage/deviceaction.py
> @@ -28,6 +28,7 @@ from udev import *
>  from devices import StorageDevice, PartitionDevice
>  from formats import getFormat
>  from errors import *
> +from parted import partitionFlag, PARTITION_BOOT, PARTITION_LBA
>  
>  import gettext
>  _ = lambda x: gettext.ldgettext("anaconda", x)
> @@ -265,9 +266,17 @@ class ActionCreateFormat(DeviceAction):
>          self.device.setup()
>  
>          if isinstance(self.device, PartitionDevice):
> +            # Flags which are truely flags, not types, so we shouldn't reset
> +            reallyFlags = [ PARTITION_BOOT, PARTITION_LBA ]
> +            for flag in partitionFlag.keys():
> +                if flag in reallyFlags or flag == self.format.partedFlag:
> +                    continue
> +                self.device.unsetFlag(flag)
> +
>              if self.format.partedFlag is not None:
>                  self.device.setFlag(self.format.partedFlag)
> -                self.device.disk.format.commitToDisk()
> +
> +            self.device.disk.format.commitToDisk()
>  
>          self.device.format.create(intf=intf,
>                                    device=self.device.path,
> @@ -310,13 +319,6 @@ class ActionDestroyFormat(DeviceAction):
>              # since then (most notably, formats removed by this very
>              # class' constructor)
>              self._device.setup()
> -
> -            if isinstance(self._device, PartitionDevice) and \
> -               self.origFormat.partedFlag is not None:
> -                # unset partition flags and commit
> -                self._device.unsetFlag(self.origFormat.partedFlag)
> -                self._device.disk.format.commitToDisk()
> -
>              self.origFormat.destroy()
>              udev_settle()
>              self._device.teardown()

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux