Add support for multiple controller mount to same point
(cherry picked from commit 3874189ca454292a222194033c3802978f0f9642)
This commit is contained in:
parent
2b37537bfa
commit
c236534ee1
@ -0,0 +1,73 @@
|
||||
From d9c7eee7cbae3de3b092fc317ff3e002e1a02bf9 Mon Sep 17 00:00:00 2001
|
||||
From: lipengyu <lipengyu@kylinos.cn>
|
||||
Date: Fri, 6 Dec 2024 14:38:39 +0800
|
||||
Subject: [PATCH] support-for-multiple-controller-nount-to-same-point
|
||||
|
||||
---
|
||||
src/config.c | 29 ++++++++++++++++++++++++++++-
|
||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/config.c b/src/config.c
|
||||
index 7678578..4d33b0d 100644
|
||||
--- a/src/config.c
|
||||
+++ b/src/config.c
|
||||
@@ -629,6 +629,22 @@ void cgroup_config_cleanup_namespace_table(void)
|
||||
memset(&config_namespace_table, 0, sizeof(struct cg_mount_table_s) * CG_CONTROLLER_MAX);
|
||||
}
|
||||
|
||||
+static int is_valid_controller(char *ctrl)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ static const char *ctrl_list[] = { "blkio", "cpu", "cpuacct", "cpuset", "devices",
|
||||
+ "freezer", "hugetlb", "memory", "misc", "net_cls",
|
||||
+ "net_prio", "perf_event", "pids", "rdma", NULL };
|
||||
+
|
||||
+ for (i = 0; ctrl_list[i]; i++) {
|
||||
+ if (strncmp(ctrl, ctrl_list[i], strlen(ctrl_list[i])) == 0)
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Add necessary options for mount. Currently only 'none' option is added
|
||||
* for mounts with only 'name=xxx' and without real controller.
|
||||
@@ -657,6 +673,9 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
||||
|
||||
strncpy(mount->name, controller, sizeof(mount->name));
|
||||
mount->name[sizeof(mount->name)-1] = '\0';
|
||||
+ free(controller);
|
||||
+ token = strtok_r(NULL, ",", &save);
|
||||
+ continue;
|
||||
}
|
||||
|
||||
if (strncmp(token, "nodev", strlen("nodev")) == 0)
|
||||
@@ -668,6 +687,15 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
||||
if (strncmp(token, "nosuid", strlen("nosuid")) == 0)
|
||||
*flags |= MS_NOSUID;
|
||||
|
||||
+ if (is_valid_controller(token)) {
|
||||
+ controller = strdup(token);
|
||||
+ if (controller == NULL)
|
||||
+ break;
|
||||
+ strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
|
||||
+ strncat(mount->name, controller, FILENAME_MAX - strlen(mount->name) - 1);
|
||||
+ free(controller);
|
||||
+ }
|
||||
+
|
||||
} else if (!name_only) {
|
||||
/*
|
||||
* We have controller + name=, do the right thing,
|
||||
@@ -679,7 +707,6 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
||||
token = strtok_r(NULL, ",", &save);
|
||||
}
|
||||
|
||||
- free(controller);
|
||||
free(opts);
|
||||
|
||||
if (name_only) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
Summary: Libcgroup is a library that abstracts the control group file system in Linux
|
||||
Name: libcgroup
|
||||
Version: 3.1.0
|
||||
Release: 5
|
||||
Release: 6
|
||||
License: LGPL-2.1-or-later
|
||||
URL: https://libcg.sourceforge.net/
|
||||
Source: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -15,6 +15,7 @@ Obsoletes: libcgroup-pam = %{version}-%{release}
|
||||
Obsoletes: libcgroup-tools < %{version}-%{release}
|
||||
|
||||
Patch0: config.patch
|
||||
Patch1: Add-support-for-multiple-controllers-on-same-mount-point.patch
|
||||
|
||||
BuildRequires: autoconf, automake, libtool
|
||||
BuildRequires: gcc,gcc-c++,byacc
|
||||
@ -104,6 +105,12 @@ getent group cgred >/dev/null || groupadd -r cgred
|
||||
%attr(0644, root, root) %{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Tue Nov 26 2024 lipengyu <lipengyu@kylinos.cn> - 3.1.0-6
|
||||
- Type:update
|
||||
- Id:NA
|
||||
- SUG:NA
|
||||
- DESC:Add support for multiple controller mount to same point
|
||||
|
||||
* Fri Oct 11 2024 Funda Wang <fundawang@yeah.net> - 3.1.0-5
|
||||
- apply patch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user