cgfsng: set errno to ENOENT on get_hierarchy()

parent d80ec04e
......@@ -179,15 +179,19 @@ static void must_append_controller(char **klist, char **nlist, char ***clist,
/* Given a handler's cgroup data, return the struct hierarchy for the controller
* @c, or NULL if there is none.
*/
struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c)
struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *controller)
{
int i;
if (!ops->hierarchies)
errno = ENOENT;
if (!ops->hierarchies) {
TRACE("There are no useable cgroup controllers");
return NULL;
}
for (i = 0; ops->hierarchies[i]; i++) {
if (!c) {
if (!controller) {
/* This is the empty unified hierarchy. */
if (ops->hierarchies[i]->controllers &&
!ops->hierarchies[i]->controllers[0])
......@@ -196,10 +200,15 @@ struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c)
continue;
}
if (string_in_list(ops->hierarchies[i]->controllers, c))
if (string_in_list(ops->hierarchies[i]->controllers, controller))
return ops->hierarchies[i];
}
if (controller)
WARN("There is no useable %s controller", controller);
else
WARN("There is no empty unified cgroup hierarchy");
return NULL;
}
......
......@@ -99,6 +99,7 @@ struct cgroup_ops {
* hierarchy wins.
*/
struct hierarchy **hierarchies;
/* Pointer to the unified hierarchy. Do not free! */
struct hierarchy *unified;
/*
......
......@@ -654,7 +654,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
* lxc_unfreeze() would do another cmd (GET_CGROUP) which would
* deadlock us.
*/
if (cgroup_ops->get_cgroup(cgroup_ops, "freezer") == NULL)
if (!cgroup_ops->get_cgroup(cgroup_ops, "freezer"))
return 0;
if (cgroup_ops->unfreeze(cgroup_ops))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment