116 lines
3.9 KiB
Diff
116 lines
3.9 KiB
Diff
diff -Nuar mudur-4.4.0.orig/bin/mudur_cgroupfs.py mudur-4.4.0/bin/mudur_cgroupfs.py
|
|
--- mudur-4.4.0.orig/bin/mudur_cgroupfs.py 1970-01-01 02:00:00.000000000 +0200
|
|
+++ mudur-4.4.0/bin/mudur_cgroupfs.py 2015-05-13 22:58:43.264005210 +0300
|
|
@@ -0,0 +1,81 @@
|
|
+# -*- coding : utf-8 -*-
|
|
+import os, sys
|
|
+
|
|
+def mountpoint(path):
|
|
+ status = os.system("mountpoint -q %s" % path)
|
|
+ if status == 0:
|
|
+ return True
|
|
+ else:
|
|
+ return False
|
|
+
|
|
+class Controller:
|
|
+ def __init__(self, subsysname, hierarchy, num_cgroups, enabled ):
|
|
+ self.subsysname = subsysname
|
|
+ self.hierarchy = hierarchy
|
|
+ self.num_cgroups = num_cgroups
|
|
+ self.enabled = enabled
|
|
+
|
|
+ def mount(self):
|
|
+ if self.enabled == 1:
|
|
+ os.chdir("/sys/fs/cgroup")
|
|
+ if mountpoint(self.subsysname) == False:
|
|
+ s = self.subsysname
|
|
+ status = os.system("mkdir -p %s; mount -n -t cgroup -o %s cgroup %s" % (s, s,s))
|
|
+ if status == 0:
|
|
+ return True
|
|
+ else:
|
|
+ return False
|
|
+
|
|
+
|
|
+class Cgroupfs:
|
|
+ def __init__(self):
|
|
+ self.controllers = {}
|
|
+ if self.check_fstab == True:
|
|
+ print("cgroupfs in fstab, exiting.")
|
|
+ sys.exit(-1)
|
|
+
|
|
+ if self.kernel_support() == False:
|
|
+ print("No kernel support for cgroupfs, exiting.")
|
|
+ sys.exit(-2)
|
|
+
|
|
+ if self.check_sysfs() == False:
|
|
+ print("/sys/fs/cgroups directory not found, exiting")
|
|
+ sys.exit(-3)
|
|
+
|
|
+ self.mount_cgroup()
|
|
+ self.find_controllers()
|
|
+ for cname, c in self.controllers.items():
|
|
+ c.mount()
|
|
+
|
|
+ def check_fstab(self):
|
|
+ found = False
|
|
+ for line in open("/etc/fstab").readlines():
|
|
+ if line[0] == "#":
|
|
+ continue
|
|
+ else:
|
|
+ if line.find("cgroup"):
|
|
+ found = True
|
|
+ return found
|
|
+
|
|
+ def kernel_support(self):
|
|
+ return os.path.isfile("/proc/cgroups")
|
|
+
|
|
+ def check_sysfs(self):
|
|
+ return os.path.isdir("/sys/fs/cgroup")
|
|
+
|
|
+ def mount_cgroup(self):
|
|
+ if mountpoint("/sys/fs/cgroup") == False:
|
|
+ cmd = " mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup"
|
|
+ return os.system(cmd)
|
|
+
|
|
+ def find_controllers(self):
|
|
+ for line in open("/proc/cgroups").readlines():
|
|
+ line = line.strip()
|
|
+ if line[0] == "#":
|
|
+ continue
|
|
+ else:
|
|
+ subsysname, hierarchy, num_cgroups, enabled = line.split()
|
|
+ enb = int(enabled)
|
|
+ hie = int(hierarchy)
|
|
+ numc= int(num_cgroups)
|
|
+ self.controllers[subsysname] = Controller(subsysname, hie, numc, enb)
|
|
diff -Nuar mudur-4.4.0.orig/bin/mudur.py mudur-4.4.0/bin/mudur.py
|
|
--- mudur-4.4.0.orig/bin/mudur.py 2015-05-13 22:57:33.660007190 +0300
|
|
+++ mudur-4.4.0/bin/mudur.py 2015-05-13 22:59:17.161004246 +0300
|
|
@@ -22,6 +22,7 @@
|
|
import signal
|
|
import gettext
|
|
import subprocess
|
|
+from mudur_cgroupfs import Cgroupfs
|
|
|
|
########
|
|
# i18n #
|
|
@@ -1025,6 +1026,7 @@
|
|
break
|
|
df.close()
|
|
run_full("/bin/mount", "-t", "tmpfs", "-o", "nodev,nosuid,size=10%,mode=755", "tmpfs", "/run")
|
|
+ c = Cgroupfs()
|
|
|
|
def mount_remote_filesystems():
|
|
"""Mounts remote filesystems."""
|
|
diff -Nuar mudur-4.4.0.orig/setup.py mudur-4.4.0/setup.py
|
|
--- mudur-4.4.0.orig/setup.py 2014-03-07 23:15:31.000000000 +0200
|
|
+++ mudur-4.4.0/setup.py 2015-05-13 23:05:23.092993840 +0300
|
|
@@ -77,6 +77,7 @@
|
|
|
|
install_file("bin/mudur.py", prefix, "sbin/mudur.py")
|
|
install_file("bin/mudur_tmpfiles.py", prefix, "sbin/mudur_tmpfiles.py")
|
|
+ install_file("bin/mudur_cgroupfs.py", prefix, "sbin/mudur_cgroupfs.py")
|
|
install_file("bin/update-environment.py", prefix, "sbin/update-environment")
|
|
install_file("bin/update-fstab.py", prefix, "sbin/update-fstab")
|
|
install_file("bin/compat.py", prefix, "etc/init.d/compat.py")
|