Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Desktop (http://www.linux-archive.org/gentoo-desktop/)
-   -   Ensure proper disklabel type on boot disk if CLEARPART_TYPE_ALL. (#570483, #530225) (http://www.linux-archive.org/gentoo-desktop/357134-ensure-proper-disklabel-type-boot-disk-if-clearpart_type_all-570483-530225-a.html)

David Lehman 04-15-2010 02:05 AM

Ensure proper disklabel type on boot disk if CLEARPART_TYPE_ALL. (#570483, #530225)
 
If the user specified "clearpart --all" or chose "Use All Space",
make sure that the boot disk gets initialized with a disklabel
whose type is appropriate for the platform's bootloader.
---
storage/partitioning.py | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 719e21f..20d7694 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -373,6 +373,45 @@ def clearPartitions(storage):
# now remove any empty extended partitions
removeEmptyExtendedPartitions(storage)

+ _platform = storage.anaconda.platform
+
+ # make sure that the the boot device has the correct disklabel type if
+ # we're going to completely clear it.
+ for disk in storage.partitioned:
+ if not storage.anaconda.bootloader.drivelist:
+ break
+
+ if disk.name != storage.anaconda.bootloader.drivelist[0]:
+ continue
+
+ if storage.clearPartType != CLEARPART_TYPE_ALL or
+ (storage.clearPartDisks and disk.name not in storage.clearPartDisks):
+ continue
+
+ # don't reinitialize the disklabel if the disk contains install media
+ if filter(lambda p: p.dependsOn(disk), storage.protectedDevices):
+ continue
+
+ nativeLabelType = _platform.diskLabelType(disk.partedDevice.type)
+ if disk.format.labelType == nativeLabelType:
+ continue
+
+ if part.disk.format.labelType == "mac":
+ # remove the magic apple partition
+ for part in storage.partitions:
+ if part.disk == disk:
+ log.debug("clearing %s" % part.name)
+ # We can't schedule the apple map partition for removal
+ # because parted will not allow us to remove it from the
+ # disk. Still, we need it out of the devicetree.
+ storage.devicetree._removeDevice(part, moddisk=False)
+
+ destroy_action = ActionDestroyFormat(disk)
+ newLabel = getFormat("disklabel", device=disk.path)
+ create_action = ActionCreateFormat(disk, format=newLabel)
+ storage.devicetree.registerAction(destroy_action)
+ storage.devicetree.registerAction(create_action)
+
def removeEmptyExtendedPartitions(storage):
for disk in storage.partitioned:
log.debug("checking whether disk %s has an empty extended" % disk.name)
--
1.6.6

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

David Cantrell 04-15-2010 02:23 PM

Ensure proper disklabel type on boot disk if CLEARPART_TYPE_ALL. (#570483, #530225)
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In the commit msg for rhel6-branch, can you do the rhbz references in the long
message as two Resolves: lines?

Resolves: rhbz#NUMBERx
RESOLVES: rhbz#NUMBERy

Thanks,

On Wed, 14 Apr 2010, David Lehman wrote:


If the user specified "clearpart --all" or chose "Use All Space",
make sure that the boot disk gets initialized with a disklabel
whose type is appropriate for the platform's bootloader.
---
storage/partitioning.py | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 719e21f..20d7694 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -373,6 +373,45 @@ def clearPartitions(storage):
# now remove any empty extended partitions
removeEmptyExtendedPartitions(storage)

+ _platform = storage.anaconda.platform
+
+ # make sure that the the boot device has the correct disklabel type if
+ # we're going to completely clear it.
+ for disk in storage.partitioned:
+ if not storage.anaconda.bootloader.drivelist:
+ break
+
+ if disk.name != storage.anaconda.bootloader.drivelist[0]:
+ continue
+
+ if storage.clearPartType != CLEARPART_TYPE_ALL or
+ (storage.clearPartDisks and disk.name not in storage.clearPartDisks):
+ continue
+
+ # don't reinitialize the disklabel if the disk contains install media
+ if filter(lambda p: p.dependsOn(disk), storage.protectedDevices):
+ continue
+
+ nativeLabelType = _platform.diskLabelType(disk.partedDevice.type)
+ if disk.format.labelType == nativeLabelType:
+ continue
+
+ if part.disk.format.labelType == "mac":
+ # remove the magic apple partition
+ for part in storage.partitions:
+ if part.disk == disk:
+ log.debug("clearing %s" % part.name)
+ # We can't schedule the apple map partition for removal
+ # because parted will not allow us to remove it from the
+ # disk. Still, we need it out of the devicetree.
+ storage.devicetree._removeDevice(part, moddisk=False)
+
+ destroy_action = ActionDestroyFormat(disk)
+ newLabel = getFormat("disklabel", device=disk.path)
+ create_action = ActionCreateFormat(disk, format=newLabel)
+ storage.devicetree.registerAction(destroy_action)
+ storage.devicetree.registerAction(create_action)
+
def removeEmptyExtendedPartitions(storage):
for disk in storage.partitioned:
log.debug("checking whether disk %s has an empty extended" % disk.name)



- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvHIVcACgkQ5hsjjIy1VklQSwCePYHO8+r/udoCikuvsGDl7wkr
iCYAn343ZnInDZs+2wvLs61Pv2h3X1Ly
=CiCW
-----END PGP SIGNATURE-----

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

David Lehman 04-15-2010 02:56 PM

Ensure proper disklabel type on boot disk if CLEARPART_TYPE_ALL. (#570483, #530225)
 
On Thu, 2010-04-15 at 10:39 +0200, Hans de Goede wrote:
> Hi,
>
> On 04/15/2010 04:05 AM, David Lehman wrote:
> > If the user specified "clearpart --all" or chose "Use All Space",
> > make sure that the boot disk gets initialized with a disklabel
> > whose type is appropriate for the platform's bootloader.
> > ---
> > storage/partitioning.py | 39 +++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 39 insertions(+), 0 deletions(-)
> >
> > diff --git a/storage/partitioning.py b/storage/partitioning.py
> > index 719e21f..20d7694 100644
> > --- a/storage/partitioning.py
> > +++ b/storage/partitioning.py
> > @@ -373,6 +373,45 @@ def clearPartitions(storage):
> > # now remove any empty extended partitions
> > removeEmptyExtendedPartitions(storage)
> >
> > + _platform = storage.anaconda.platform
> > +
> > + # make sure that the the boot device has the correct disklabel type if
> > + # we're going to completely clear it.
> > + for disk in storage.partitioned:
> > + if not storage.anaconda.bootloader.drivelist:
> > + break
> > +
> > + if disk.name != storage.anaconda.bootloader.drivelist[0]:
> > + continue
> > +
> > + if storage.clearPartType != CLEARPART_TYPE_ALL or
> > + (storage.clearPartDisks and disk.name not in storage.clearPartDisks):
> > + continue
> > +
> > + # don't reinitialize the disklabel if the disk contains install media
> > + if filter(lambda p: p.dependsOn(disk), storage.protectedDevices):
> > + continue
> > +
> > + nativeLabelType = _platform.diskLabelType(disk.partedDevice.type)
> > + if disk.format.labelType == nativeLabelType:
> > + continue
> > +
> > + if part.disk.format.labelType == "mac":
>
> part.disk.format.labelType should be disk.format.labelType

Wow, I must have gotten lucky when I tested with a mac disklabel. Fixed
in my local tree.

>
> > + # remove the magic apple partition
> > + for part in storage.partitions:
> > + if part.disk == disk:
> > + log.debug("clearing %s" % part.name)
> > + # We can't schedule the apple map partition for removal
> > + # because parted will not allow us to remove it from the
> > + # disk. Still, we need it out of the devicetree.
> > + storage.devicetree._removeDevice(part, moddisk=False)
>
> You're removing all partitions on the disk from the tree here, granted
> there shouldn't be any left other then the magic apple one, but maybe
> add a additional check ?

I was hesitant to do this, but we don't want to cover up other problems
so I've added a check that it's partition number 1 into that test.

Dave

>
> > +
> > + destroy_action = ActionDestroyFormat(disk)
> > + newLabel = getFormat("disklabel", device=disk.path)
> > + create_action = ActionCreateFormat(disk, format=newLabel)
> > + storage.devicetree.registerAction(destroy_action)
> > + storage.devicetree.registerAction(create_action)
> > +
> > def removeEmptyExtendedPartitions(storage):
> > for disk in storage.partitioned:
> > log.debug("checking whether disk %s has an empty extended" % disk.name)
>
> Other then the 2 above remarks, ack.
>
> Regards,
>
> Hans
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list


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


All times are GMT. The time now is 02:29 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.