ECGNONEMPTY error code is returned by cgroup_delete_cgroup_ext when it should remove only empty groups, but the group(s) were not empty.
It's not a real error, it's just an indication that some groups were not removed - it's perfectly valid use case. Signed-off-by: Jan Safranek <jsafr...@redhat.com> --- include/libcgroup/error.h | 2 ++ src/api.c | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/libcgroup/error.h b/include/libcgroup/error.h index a78473a..91b5c1c 100644 --- a/include/libcgroup/error.h +++ b/include/libcgroup/error.h @@ -75,6 +75,8 @@ enum { ECGMOUNTNAMESPACE, ECGROUPUNSUPP, ECGCANTSETVALUE, + /** Removing of a group failed because it was not empty. */ + ECGNONEMPTY, }; /** diff --git a/src/api.c b/src/api.c index e2d56ef..20ebf84 100644 --- a/src/api.c +++ b/src/api.c @@ -118,6 +118,7 @@ const char const *cgroup_strerror_codes[] = { "Either mount or namespace keyword has to be specified in the configuration file", "This kernel does not support this feature", "Value setting does not succeed", + "Failed to remove a non-empty group", }; static const char const *cgroup_ignored_tasks_files[] = { "tasks", NULL }; @@ -1924,12 +1925,13 @@ static int cg_delete_cgroup_controller(char *cgroup_name, char *controller, return ECGROUPSUBSYSNOTMOUNTED; ret = rmdir(path); - if (ret != 0 && errno != ENOENT) { - last_errno = errno; - return ECGOTHER; - } + if (ret == 0 || errno == ENOENT) + return 0; + if (errno == EBUSY) + return ECGNONEMPTY; - return 0; + last_errno = errno; + return ECGOTHER; } /** @@ -2130,8 +2132,15 @@ int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags) * the group from all of them. */ if (ret != 0 && first_error == 0) { - first_errno = last_errno; - first_error = ret; + /* + * ECGNONEMPTY is more or less not an error, but an + * indication that something was not removed. + * Therefore it should be replaced by any other error. + */ + if (ret != ECGNONEMPTY || first_error == ECGNONEMPTY) { + first_errno = last_errno; + first_error = ret; + } } } ------------------------------------------------------------------------------ Cloud Services Checklist: Pricing and Packaging Optimization This white paper is intended to serve as a reference, checklist and point of discussion for anyone considering optimizing the pricing and packaging model of a cloud services business. Read Now! http://www.accelacomm.com/jaw/sfnl/114/51491232/ _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel