From 173c27d970bd29594d0485f66474af5f5be37201 Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Mon, 11 Jul 2005 19:08:45 +0000 Subject: [PATCH] Added set_dlimit and get_dlimit to be used by NM to enforce disk limits. --- python/vserver.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/python/vserver.py b/python/vserver.py index 64cc681..2d72bd0 100644 --- a/python/vserver.py +++ b/python/vserver.py @@ -12,7 +12,7 @@ import mountimpl import linuxcaps import passfdimpl import utmp -import vserverimpl +import vserverimpl, vduimpl from util_vserver_vars import * @@ -81,6 +81,24 @@ class VServer: return os.chroot("%s/%s" % (VROOTDIR, self.name)) + def set_dlimit(self, blocktotal): + path = "%s/%s" % (VROOTDIR, self.name) + inodes, blockcount, size = vduimpl.vdu(path) + vserverimpl.setdlimit(path, self.ctx, blockcount>>1, blocktotal, inodes, -1, 2) + + def get_dlimit(self): + path = "%s/%s" % (VROOTDIR, self.name) + try: + blocksused, blocktotal, inodesused, inodestotal, reserved = \ + vserverimpl.getdlimit(path,self.ctx) + except OSError, ex: + if ex.errno == 3: + # get here if no vserver disk limit has been set for xid + # set blockused to -1 to indicate no limit + blocktotal = -1 + + return blocktotal + def open(self, filename, mode = "r", bufsize = -1): (sendsock, recvsock) = passfdimpl.socketpair() -- 2.43.0