File disktest_freespace.patch of Package autotest
--- tests/disktest/disktest.py
+++ tests/disktest/disktest.py
@@ -1,7 +1,10 @@
-import os, sys, subprocess
+import os, sys, subprocess, statfs
from autotest_lib.client.bin import test, autotest_utils
from autotest_lib.client.common_lib import utils, error
+def freespace(path):
+ s = os.statvfs(path)
+ return s[statvfs.F_BAVAIL] * long(s[statvfs.F_BSIZE])
class disktest(test.test):
version = 1
@@ -27,6 +30,9 @@
def execute(self, disks = ["/abuild", gigabytes = 10,
chunk_mb = autotest_utils.memtotal() / 1024):
os.chdir(self.srcdir)
+
+ gigabytes=freespace("/") / 1024 / 1024 / 1024
+ print "resizing to %s GB" % gigabytes
if not disks:
disks = [self.tmpdir]