Verified Commit 51ce917d authored by Michal Hrusecky's avatar Michal Hrusecky 🦎

procd: Try new style of cgroups

parent 66d5ba56
From a0376b192655bd06c18e54095282bac5ba5c6570 Mon Sep 17 00:00:00 2001
From: Michal Hrusecky <Michal@Hrusecky.net>
Date: Wed, 1 May 2019 21:45:31 +0200
Subject: [PATCH] procd: New style of cgroups
---
package/system/procd/Makefile | 2 +-
.../new-style-of-cgroup-hiearchy.patch | 57 +++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 package/system/procd/patches/new-style-of-cgroup-hiearchy.patch
diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile
index 5971e0293d..3cea5b803e 100644
--- a/package/system/procd/Makefile
+++ b/package/system/procd/Makefile
@@ -15,7 +15,7 @@ PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
PKG_SOURCE_DATE:=2018-03-28
PKG_SOURCE_VERSION:=dfb68f8556df63878add145ad9c656381bc20656
PKG_MIRROR_HASH:=8d2c70fb0264a6548e39acc5ab1c44cec50fc550c4f931760b0796f8893c9b7f
-CMAKE_INSTALL:=1
+CMAKE_INSTALL:=2
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=
diff --git a/package/system/procd/patches/new-style-of-cgroup-hiearchy.patch b/package/system/procd/patches/new-style-of-cgroup-hiearchy.patch
new file mode 100644
index 0000000000..1d7430269d
--- /dev/null
+++ b/package/system/procd/patches/new-style-of-cgroup-hiearchy.patch
@@ -0,0 +1,57 @@
+Index: procd-2018-03-28-dfb68f85/initd/early.c
+===================================================================
+--- procd-2018-03-28-dfb68f85.orig/initd/early.c
++++ procd-2018-03-28-dfb68f85/initd/early.c
+@@ -52,14 +52,51 @@ early_console(const char *dev)
+ }
+
+ static void
++mount_cgroups()
++{
++ int fd = open("/proc/cgroups", O_RDONLY|O_CLOEXEC);
++ char buff[1024];
++ char cgroup_buff[1124];
++ ssize_t sz = 0;
++ ssize_t i,j = 0;
++ if(fd <= 0)
++ return;
++ sz = read(fd, buff, 1023);
++ if(sz <=0 ) {
++ close(fd);
++ return;
++ }
++ buff[sz] = 0;
++ if(mount("tmpfs", "/sys/fs/cgroup", "tmpfs", MS_NOATIME | MS_NOSUID, "size=512K"))
++ sz = 0;
++ for(i=0; i<sz; i++) {
++ if((buff[i]) == '\n') {
++ i++;
++ j=i;
++ while(i < sz && buff[i] != '\t') i++;
++ if(i > j && i < sz) {
++ buff[i]=0;
++ snprintf(cgroup_buff, 1123, "/sys/fs/cgroup/%s", buff+j);
++ if(mkdir(cgroup_buff, 0755)) {
++ continue;
++ }
++ mount(buff+j, cgroup_buff, "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID, buff+j);
++ }
++ }
++ }
++ close(fd);
++ return;
++}
++
++static void
+ early_mounts(void)
+ {
+ unsigned int oldumask = umask(0);
+
+ mount("proc", "/proc", "proc", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0);
+ mount("sysfs", "/sys", "sysfs", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0);
+- mount("cgroup", "/sys/fs/cgroup", "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID, 0);
+ mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOSUID, "mode=0755,size=512K");
++ mount_cgroups();
+ ignore(symlink("/tmp/shm", "/dev/shm"));
+ mkdir("/dev/pts", 0755);
+ mount("devpts", "/dev/pts", "devpts", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=600");
--
2.21.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment