[blivet:master 16/21] Add TmpFS._getExistingSize() method.

mulhern amulhern at redhat.com
Thu Jan 15 18:39:43 UTC 2015


Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/formats/fs.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index bd0f081..c1bc3ed 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -1577,6 +1577,31 @@ class TmpFS(NoDevFS):
         """
         pass
 
+    def _getExistingSize(self, info=None):
+        """ Get current size of tmpfs filesystem using df.
+
+            :param NoneType info: a dummy parameter
+            :rtype: Size
+            :returns: the current size of the filesystem, 0 if not found.
+        """
+        if not self.status:
+            return Size(0)
+
+        df = ["df", self._mountpoint, "--output=size"]
+        try:
+            (ret, out) = util.run_program_and_capture_output(df)
+        except OSError:
+            return Size(0)
+
+        if ret:
+            return Size(0)
+
+        lines = out.split()
+        if len(lines) != 2 or lines[0] != "1K-blocks":
+            return Size(0)
+
+        return Size("%s KiB" % lines[1])
+
     @property
     def mountable(self):
         return True
-- 
1.9.3



More information about the anaconda-patches mailing list