Re: [PATCH 1/2] Reset parted flags in createFormat not destroyFormat

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

 



If I understand it correctly, this makes sense and actually fixes one of my older bugs..

Martin

----- "Hans de Goede" <hdegoede@xxxxxxxxxx> 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).
> ---
>  storage/deviceaction.py |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/storage/deviceaction.py b/storage/deviceaction.py
> index c6952f3..15f46b7 100644
> --- a/storage/deviceaction.py
> +++ b/storage/deviceaction.py
> @@ -26,6 +26,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)
> @@ -263,9 +264,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,
> @@ -299,13 +308,6 @@ class ActionDestroyFormat(DeviceAction):
>          """ wipe the filesystem signature from the device """
>          if self.origFormat:
>              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()
> -- 
> 1.6.5.rc2
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
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