This commit adds support for wildcards in the cgrules ignore rule destination field. Note that wildcards are only supported at the end of the string. A '*' anywhere other than the last character will be treaded literally.
Wildcarding at the end of the destination allows the user to specify a rule as follows: <user> <controller> <destination> <options> * memory IgnoreCgroup* ignore Any processes in IgnoreCgroup, IgnoreCgroup1, IgnoreCgroup/foo, etc. will match this rule and will be ignored by libcgroup. ---- Expressing the rule as "<dir>/*" allows the user to match all processes within a child cgroup but not the parent cgroup. For example, given the following rule: <user> <controller> <destination> <options> * memory MyCgroup/* ignore Processes in MyCgroup/foo or MyCgroup/bar will match the above rule (and thus be ignored), but processes in MyCgroup will not match the rule and will continue to be subject to other libcgroup rules. ---- To match processes running in the root cgroup, the following syntax can be used: <user> <controller> <destination> <options> * memory /* ignore Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- src/api.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api.c b/src/api.c index 24ae48d35911..a3726dd4ef68 100644 --- a/src/api.c +++ b/src/api.c @@ -2870,6 +2870,19 @@ static int cgroup_find_matching_destination(char *cgroup_list[], if (cgroup_list[i] == NULL) break; + if (rule_dest[rule_strlen - 1] == '*') { + /* + * This rule has a wildcard at the end. Therefore + * we need to match strings up until that point + */ + if (strncmp(rule_dest, cgroup_list[i], + rule_strlen - 1) == 0) { + *matching_index = i; + ret = 0; + break; + } + } + if (rule_dest[rule_strlen - 1] == '/') { /* * Avoid a weird corner case where given a rule dest -- 1.8.3.1 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel