[PATCH 4/7] S7904: add method for finding bytes free in path

Richard Maw richard.maw at codethink.co.uk
Tue Jun 4 17:52:44 BST 2013


This has no tests, as the ability to run them requires root privilidges
or a more recent kernel and user namespace support.
---
 morphlib/util.py |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/morphlib/util.py b/morphlib/util.py
index 6d15fcf..007c7f7 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -13,6 +13,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+import os
 import re
 
 import morphlib
@@ -219,3 +220,9 @@ def copyfileobj(inputfp, outputfp, blocksize=1024*1024):  # pragma: no cover
     elif sparse:
         outputfp.seek(-1, os.SEEK_CUR)
         outputfp.write("\x00")
+
+def get_bytes_free_in_path(path): # pragma: no cover
+    """Returns the bytes free in the filesystem that path is part of"""
+
+    fsinfo = os.statvfs(path)
+    return fsinfo.f_bavail * fsinfo.f_bsize
-- 
1.7.10.4




More information about the baserock-dev mailing list