FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 12-14-2009, 09:07 PM
David Lehman
 
Default Add an alignment property to DiskLabel.

---
storage/formats/disklabel.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index d277323..8917efd 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -62,6 +62,7 @@ class DiskLabel(DeviceFormat):
self._partedDevice = None
self._partedDisk = None
self._origPartedDisk = None
+ self._alignment = None

if self.partedDevice:
# set up the parted objects and raise exception on failure
@@ -278,5 +279,36 @@ class DiskLabel(DeviceFormat):
parts = []
return parts

+ @property
+ def alignment(self):
+ """ Alignment requirements for this device. """
+ if not self._alignment:
+ try:
+ disklabel_alignment = self.partedDisk.partitionAlignment
+ except _ped.CreateException:
+ disklabel_alignment = parted.Alignment(offset=0, grainSize=1)
+
+ try:
+ optimum_device_alignment = self.partedDevice.optimumAlignment
+ except _ped.CreateException:
+ optimum_device_alignment = None
+
+ try:
+ minimum_device_alignment = self.partedDevice.minimumAlignment
+ except _ped.CreateException:
+ minimum_device_alignment = None
+
+ try:
+ a = optimum_device_alignment.intersect(disklabel_align ment)
+ except (ArithmeticError, AttributeError):
+ try:
+ a = minimum_device_alignment.intersect(disklabel_align ment)
+ except (ArithmeticError, AttributeError):
+ a = disklabel_alignment
+
+ self._alignment = a
+
+ return self._alignment
+
register_device_format(DiskLabel)

--
1.6.2.5

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

Thread Tools




All times are GMT. The time now is 08:32 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org