[PATCH] add configuration option to specify tmpfs max size

Kalev Lember kalev at smartlink.ee
Tue Jun 1 20:48:47 UTC 2010


---
 etc/mock/site-defaults.cfg |    3 ++-
 py/mock.py                 |    4 +++-
 py/mock/plugins/tmpfs.py   |    9 +++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/etc/mock/site-defaults.cfg b/etc/mock/site-defaults.cfg
index 83d2ea7..5039123 100644
--- a/etc/mock/site-defaults.cfg
+++ b/etc/mock/site-defaults.cfg
@@ -75,7 +75,8 @@
 # config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/host/path', '/bind/mount/path/in/chroot/' ))
 #
 # config_opts['plugin_conf']['tmpfs_enable'] = False
-# config_opts['plugin_conf']['tmpfs_opts'] = {'required_ram_mb': 1024}
+# config_opts['plugin_conf']['tmpfs_opts']['required_ram_mb'] = 1024
+# config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '512m'
 
 #############################################################################
 #
diff --git a/py/mock.py b/py/mock.py
index 8f58031..06e3ac7 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -259,7 +259,9 @@ def setup_default_config_opts(config_opts, unprivUid):
                 # ('/another/host/path', '/another/bind/mount/path/in/chroot/'),
                 ]},
             'tmpfs_enable': False,
-            'tmpfs_opts': {'required_ram_mb': 900},
+            'tmpfs_opts': {
+                'required_ram_mb': 900,
+                'max_fs_size': None},
             }
 
     # dependent on guest OS
diff --git a/py/mock/plugins/tmpfs.py b/py/mock/plugins/tmpfs.py
index cf89bc1..1708275 100644
--- a/py/mock/plugins/tmpfs.py
+++ b/py/mock/plugins/tmpfs.py
@@ -33,6 +33,11 @@ class Tmpfs(object):
     def __init__(self, rootObj, conf):
         self.rootObj = rootObj
         self.conf = conf
+        self.maxSize = self.conf['max_fs_size']
+        if self.maxSize:
+            self.optArgs = ['-o', 'size=' + self.maxSize]
+        else:
+            self.optArgs = []
         rootObj.addHook("preinit",  self._tmpfsPreInitHook)
         rootObj.addHook("postbuild",  self._tmpfsPostBuildHook)
         rootObj.addHook("initfailed",  self._tmpfsPostBuildHook)
@@ -40,8 +45,8 @@ class Tmpfs(object):
     decorate(traceLog())
     def _tmpfsPreInitHook(self):
         getLog().info("mounting tmpfs.")
-        mountCmd = ["mount", "-n", "-t", "tmpfs", "mock_chroot_tmpfs", 
-                    self.rootObj.makeChrootPath()]
+        mountCmd = ["mount", "-n", "-t", "tmpfs"] + self.optArgs + \
+                   ["mock_chroot_tmpfs", self.rootObj.makeChrootPath()]
         mock.util.do(mountCmd, shell=False)
 
     decorate(traceLog())
-- 
1.7.0.1



More information about the buildsys mailing list