[PATCH 3/7] Add properties to return free space in an existing filesystem or disklabel.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/storage/formats/disklabel.py |    5 +++++
 pyanaconda/storage/formats/fs.py        |   10 ++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/storage/formats/disklabel.py b/pyanaconda/storage/formats/disklabel.py
index 734f13e..dbae626 100644
--- a/pyanaconda/storage/formats/disklabel.py
+++ b/pyanaconda/storage/formats/disklabel.py
@@ -367,5 +367,10 @@ class DiskLabel(DeviceFormat):
 
         return self._endAlignment
 
+    @property
+    def free(self):
+        return sum([f.getSize()
+                        for f in self.partedDisk.getFreeSpacePartitions()])
+
 register_device_format(DiskLabel)
 
diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index bb2dddc..3909dc4 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -308,6 +308,16 @@ class FS(DeviceFormat):
             size = self._size
         return float(size)
 
+    @property
+    def free(self):
+        free = 0
+        if self.exists:
+            if self.currentSize and self.minSize and \
+               self.currentSize != self.minSize:
+                free = int(self.currentSize - self.minSize)     # truncate
+
+        return free
+
     def _getFormatOptions(self, options=None):
         argv = []
         if options and isinstance(options, list):
-- 
1.7.6

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


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux