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, ...@@ -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 /* Given a handler's cgroup data, return the struct hierarchy for the controller
* @c, or NULL if there is none. * @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; int i;
if (!ops->hierarchies) errno = ENOENT;
if (!ops->hierarchies) {
TRACE("There are no useable cgroup controllers");
return NULL; return NULL;
}
for (i = 0; ops->hierarchies[i]; i++) { for (i = 0; ops->hierarchies[i]; i++) {
if (!c) { if (!controller) {
/* This is the empty unified hierarchy. */ /* This is the empty unified hierarchy. */
if (ops->hierarchies[i]->controllers && if (ops->hierarchies[i]->controllers &&
!ops->hierarchies[i]->controllers[0]) !ops->hierarchies[i]->controllers[0])
...@@ -196,10 +200,15 @@ struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c) ...@@ -196,10 +200,15 @@ struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c)
continue; continue;
} }
if (string_in_list(ops->hierarchies[i]->controllers, c)) if (string_in_list(ops->hierarchies[i]->controllers, controller))
return ops->hierarchies[i]; 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; return NULL;
} }
......
...@@ -99,6 +99,7 @@ struct cgroup_ops { ...@@ -99,6 +99,7 @@ struct cgroup_ops {
* hierarchy wins. * hierarchy wins.
*/ */
struct hierarchy **hierarchies; struct hierarchy **hierarchies;
/* Pointer to the unified hierarchy. Do not free! */
struct hierarchy *unified; struct hierarchy *unified;
/* /*
......
...@@ -654,7 +654,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, ...@@ -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 * lxc_unfreeze() would do another cmd (GET_CGROUP) which would
* deadlock us. * deadlock us.
*/ */
if (cgroup_ops->get_cgroup(cgroup_ops, "freezer") == NULL) if (!cgroup_ops->get_cgroup(cgroup_ops, "freezer"))
return 0; return 0;
if (cgroup_ops->unfreeze(cgroup_ops)) 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