diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-10-08 11:03:40 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2009-10-08 19:52:33 +0200 |
commit | 7f87971928c6876c558f63f335c556f5434f7d33 (patch) | |
tree | 2c4beadcb93fa645007e6e08b2bd260470c3a32b | |
parent | 3167fc05623ab5707f67397981337caf26314ead (diff) | |
download | anaconda-7f87971928c6876c558f63f335c556f5434f7d33.tar.gz anaconda-7f87971928c6876c558f63f335c556f5434f7d33.tar.xz anaconda-7f87971928c6876c558f63f335c556f5434f7d33.zip |
Reset parted flags in createFormat not destroyFormat
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.
-rw-r--r-- | storage/deviceaction.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/storage/deviceaction.py b/storage/deviceaction.py index a01ee4148..1f8d5a74b 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() |