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 > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 11-28-2007, 10:05 PM
Jeremy Katz
 
Default Add method for finding the available size that a partition can expand into

---
partedUtils.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/partedUtils.py b/partedUtils.py
index ae095e6..aa28940 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -96,6 +96,24 @@ def getDeviceSizeMB(dev):
return (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024)
* dev.sector_size)

+def getMaxAvailPartSizeMB(part):
+ """Return the maximum size this partition can grow to by looking
+ at contiguous freespace partitions."""
+
+ disk = part.disk
+ maxlen = part.geom.length
+
+ # let's look at the next partition(s) and if they're freespace,
+ # they can add to our maximum size.
+ np = disk.next_partition(part)
+ while np:
+ if np.type & parted.PARTITION_FREESPACE:
+ maxlen += np.geom.length
+ else:
+ break
+ np = disk.next_partition(np)
+ return math.floor(maxlen * part.geom.dev.sector_size / 1024.0 / 1024.0)
+
def get_partition_by_name(disks, partname):
"""Return the parted part object associated with partname.

--
1.5.3.4

_______________________________________________
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 06:54 PM.

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