The parted.Device object now offers functions to translate
between cylinders and sectors.
---
autopart.py | 10 +++++-----
bootloader.py | 3 +--
iw/partition_dialog_gui.py | 9 ++++-----
iw/partition_gui.py | 6 ++----
partIntfHelpers.py | 6 ++----
partedUtils.py | 18 ------------------
6 files changed, 14 insertions(+), 38 deletions(-)
diff --git a/autopart.py b/autopart.py
index a88fc13..3f9f48f 100644
--- a/autopart.py
+++ b/autopart.py
@@ -132,8 +132,8 @@ def printNewRequestsCyl(diskset, newRequest):
part = partedUtils.get_partition_by_name(diskset.disks,
req.device)
## print(req)
-## print("Start Cyl:%s End Cyl: %s" %
(partedUtils.start_sector_to_cyl(part.geom.dev, part.geom.start),
-##
partedUtils.end_sector_to_cyl(part.geom.dev, part.geom.end)))
+## print("Start Cyl:%s End Cyl: %s" %
(part.geom.dev.startSectorToCylinder(part.geom.start),
+##
part.geom.dev.endSectorToCylinder(part.geom.end),))
def printFreespaceitem(part):
return partedUtils.get_partition_name(part), part.geom.start,
part.geom.end, part.getSize(unit="MB")
@@ -221,14 +221,14 @@ def fitConstrained(diskset, requests,
primOnly=0, newParts = None):
if not disk: # this shouldn't happen
raise PartitioningError, "Selected to put partition
on non-existent disk!"
- startSec = partedUtils.start_cyl_to_sector(disk.dev,
request.start)
+ startSec = disk.dev.startCylinderToSector(request.start)
if request.end:
endCyl = request.end
elif request.size:
- endCyl = partedUtils.end_sector_to_cyl(disk.dev,
((1024L * 1024L * request.size) / disk.dev.sector_size) + startSec)
+ endCyl = disk.dev.endSectorToCylinder(((1024L * 1024L
* request.size) / disk.dev.sector_size) + startSec)
- endSec = partedUtils.end_cyl_to_sector(disk.dev, endCyl)
+ endSec = disk.dev.endCylinderToSector(endCyl)
if endSec > disk.dev.length:
raise PartitioningError, "Unable to create partition
which extends beyond the end of the disk."
diff --git a/bootloader.py b/bootloader.py
index dcc9899..c88b8ed 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -131,8 +131,7 @@ def bootloaderSetupChoices(anaconda):
bootDev = anaconda.id.fsset.getEntryByMountPoint("/boot")
part =
partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
bootDev.device.getDevice())
- if part and partedUtils.end_sector_to_cyl(part.geom.dev,
- part.geom.end) >=
1024:
+ if part and part.geom.dev.endSectorToCylinder(part.geom.end) >=
1024:
anaconda.id.bootloader.above1024 = 1
diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py
index 0539682..d3e7d58 100644
--- a/iw/partition_dialog_gui.py
+++ b/iw/partition_dialog_gui.py
@@ -52,9 +52,8 @@ class PartitionEditor:
def cylspinchangedCB(self, widget, data):
(dev, startcylspin, endcylspin, bycyl_sizelabel) = data
- startsec = start_cyl_to_sector(dev,
- startcylspin.get_value_as_int())
- endsec = end_cyl_to_sector(dev, endcylspin.get_value_as_int())
+ startsec =
dev.startCylinderToSector(startcylspin.get_value_as_int())
+ endsec = dev.endCylinderToSector(endcylspin.get_value_as_int())
cursize = (endsec - startsec)/2048
bycyl_sizelabel.set_text("%s" % (int(cursize)))
@@ -414,8 +413,8 @@ class PartitionEditor:
(dev, self.startcylspin,
self.endcylspin, bycyl_sizelabel))
- startsec = start_cyl_to_sector(dev,
origrequest.start)
- endsec = end_cyl_to_sector(dev, origrequest.end)
+ startsec =
dev.startCylinderToSector(origrequest.start)
+ endsec = dev.endCylinderToSector(origrequest.end)
cursize = (endsec - startsec)/2048
bycyl_sizelabel.set_text("%s" % (int(cursize)))
else:
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 4b43751..7e1aadd 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -941,10 +941,8 @@ class PartitionWindow(InstallWindow):
self.tree[iter]['Label'] = ""
self.tree[iter]['Type'] = ptype
- self.tree[iter]['Start'] =
str(start_sector_to_cyl(disk.dev,
-
part.geom.start))
- self.tree[iter]['End'] =
str(end_sector_to_cyl(disk.dev,
-
part.geom.end))
+ self.tree[iter]['Start'] =
str(disk.dev.startSectorToCylinder(part.geom.start))
+ self.tree[iter]['End'] =
str(disk.dev.endSectorToCylinder(part.geom.end))
size = part.getSize(unit="MB")
if size < 1.0:
sizestr = "< 1"
diff --git a/partIntfHelpers.py b/partIntfHelpers.py
index d133992..dfebc33 100644
--- a/partIntfHelpers.py
+++ b/partIntfHelpers.py
@@ -343,10 +343,8 @@ def doEditPartitionByRequest(intf, requestlist,
part):
return (None, None)
elif part.type & parted.PARTITION_FREESPACE:
request =
partRequests.PartitionSpec(fsset.fileSystemTypeGetDefault(),
- start = partedUtils.start_sector_to_cyl(part.geom.dev,
-
part.geom.start),
- end = partedUtils.end_sector_to_cyl(part.geom.dev,
- part.geom.end),
+ start =
part.geom.dev.startSectorToCylinder(part.geom.start),
+ end = part.geom.dev.endSectorToCylinder(part.geom.end),
drive = [ part.geometry.device.path[5:] ])
return ("NEW", request)
diff --git a/partedUtils.py b/partedUtils.py
index cd32c18..97c766d 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -48,24 +48,6 @@ log = logging.getLogger("anaconda")
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
-def start_sector_to_cyl(device, sector):
- """Return the closest cylinder (round down) to sector on
device."""
- return int(math.floor((float(sector)
- / (device.heads * device.sectors)) + 1))
-
-def end_sector_to_cyl(device, sector):
- """Return the closest cylinder (round up) to sector on device."""
- return int(math.ceil(float((sector + 1))
- / (device.heads * device.sectors)))
-
-def start_cyl_to_sector(device, cyl):
- "Return the sector corresponding to cylinder as a starting
cylinder."
- return long((cyl - 1) * (device.heads * device.sectors))
-
-def end_cyl_to_sector(device, cyl):
- "Return the sector corresponding to cylinder as a ending
cylinder."
- return long(((cyl) * (device.heads * device.sectors)) - 1)
-
def getPartSize(partition):
"""Return the size of partition in sectors."""
return partition.geom.length
--
1.6.1.3
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list