cgroups: properly disable certain cgroups
Costa Tsaousis (ktsaou) committed
May 1, 2016 at 23:15 UTC
0c6a0d55fa4146414f4a8c79adbfde0f3a36328f
1 file changed
+13
-8
src/sys_fs_cgroup.c
+13
-8
@@ -803,20 +803,25 @@ void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(co
803
804
if(de->d_type == DT_DIR) {
805
if(enabled == -1) {
806
+ const char *r = relative_path;
807
+ if(*r == '\0') r = "/";
808
+ else if (*r == '/') r++;
809
+
810
// we check for this option here
811
// so that the config will not have settings
812
// for leaf directories
813
char option[FILENAME_MAX + 1];
810
- snprintf(option, FILENAME_MAX, "search for cgroups under %s", (*relative_path == '\0')?"/":relative_path);
814
+ snprintf(option, FILENAME_MAX, "search for cgroups under %s", r);
815
+ option[FILENAME_MAX] = '\0';
816
817
int def = 1;
813
- size_t len = strlen(this);
814
- if((len > 5 && !strncmp(&this[len - 5], ".user", 5)) ||
815
- !strcmp(this, "system.slice") ||
816
- !strcmp(this, "user.slice") ||
817
- !strcmp(this, "system") ||
818
- !strcmp(this, "user") ||
819
- !strcmp(this, "systemd"))
818
+ size_t len = strlen(r);
819
+ if((len > 5 && !strncmp(&r[len - 5], ".user", 5)) ||
820
+ !strcmp(r, "system.slice") ||
821
+ !strcmp(r, "user.slice") ||
822
+ !strcmp(r, "system") ||
823
+ !strcmp(r, "user") ||
824
+ !strcmp(r, "systemd"))
825
def = 0;
826
827
enabled = config_get_boolean("plugin:cgroups", option, def);