From: Christian Brauner Date: Tue, 3 Dec 2019 00:24:55 +0000 (+0100) Subject: cgroups: add DEFAULT_MOUNTPOINT #define X-Git-Tag: lxc-4.0.0~88^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dca9587a61b792fa7bc4bdeb3e3c29059018e637;p=thirdparty%2Flxc.git cgroups: add DEFAULT_MOUNTPOINT #define Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 306530097..e3f435d1f 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -742,8 +742,8 @@ static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line, /* Note, if we change how mountinfo works, then our caller will need to * verify /sys/fs/cgroup/ in this field. */ - if (strncmp(p, "/sys/fs/cgroup/", 15) != 0) { - ERROR("Found hierarchy not under /sys/fs/cgroup: \"%s\"", p); + if (strncmp(p, DEFAULT_CGROUP_MOUNTPOINT "/", 15) != 0) { + ERROR("Found hierarchy not under " DEFAULT_CGROUP_MOUNTPOINT ": \"%s\"", p); return NULL; } @@ -844,7 +844,7 @@ static char *cg_hybrid_get_mountpoint(char *line) p++; } - if (strncmp(p, "/sys/fs/cgroup/", 15) != 0) + if (strncmp(p, DEFAULT_CGROUP_MOUNTPOINT "/", 15) != 0) return NULL; p2 = strchr(p + 15, ' '); @@ -1811,7 +1811,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, else if (type == LXC_AUTO_CGROUP_FULL_NOSPEC) type = LXC_AUTO_CGROUP_FULL_MIXED; - cgroup_root = must_make_path(root, "/sys/fs/cgroup", NULL); + cgroup_root = must_make_path(root, DEFAULT_CGROUP_MOUNTPOINT, NULL); if (ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED) { if (has_cgns && wants_force_mount) { /* If cgroup namespaces are supported but the container @@ -2953,7 +2953,7 @@ static int cg_is_pure_unified(void) int ret; struct statfs fs; - ret = statfs("/sys/fs/cgroup", &fs); + ret = statfs(DEFAULT_CGROUP_MOUNTPOINT, &fs); if (ret < 0) return -ENOMEDIUM; @@ -3019,7 +3019,7 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative, * further down the hierarchy. If not it is up to the user to delegate * them to us. */ - mountpoint = must_copy_string("/sys/fs/cgroup"); + mountpoint = must_copy_string(DEFAULT_CGROUP_MOUNTPOINT); subtree_path = must_make_path(mountpoint, base_cgroup, "cgroup.subtree_control", NULL); delegatable = cg_unified_get_controllers(subtree_path); diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h index a3eb46b9d..6c875b2a6 100644 --- a/src/lxc/cgroups/cgroup.h +++ b/src/lxc/cgroups/cgroup.h @@ -28,6 +28,7 @@ #include #include +#define DEFAULT_CGROUP_MOUNTPOINT "/sys/fs/cgroup" #define PAYLOAD_CGROUP "lxc.payload" #define MONITOR_CGROUP "lxc.monitor" #define PIVOT_CGROUP "lxc.pivot" @@ -92,6 +93,8 @@ struct hierarchy { char *container_full_path; char *monitor_full_path; int version; + + /* cgroup2 only */ int bpf_device_controller:1; };