cgfsng: cg_legacy_set_data()

parent 4a185bf6
...@@ -2660,13 +2660,13 @@ out: ...@@ -2660,13 +2660,13 @@ out:
return ret; return ret;
} }
/* /* Called from setup_limits - here we have the container's cgroup_data because
* Called from setup_limits - here we have the container's cgroup_data because * we created the cgroups.
* we created the cgroups
*/ */
static int cg_legacy_set_data(const char *filename, const char *value, static int cg_legacy_set_data(const char *filename, const char *value,
struct cgfsng_handler_data *d) struct cgfsng_handler_data *d)
{ {
size_t len;
char *fullpath, *p; char *fullpath, *p;
/* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */ /* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */
char converted_value[50]; char converted_value[50];
...@@ -2674,9 +2674,11 @@ static int cg_legacy_set_data(const char *filename, const char *value, ...@@ -2674,9 +2674,11 @@ static int cg_legacy_set_data(const char *filename, const char *value,
int ret = 0; int ret = 0;
char *controller = NULL; char *controller = NULL;
controller = alloca(strlen(filename) + 1); len = strlen(filename);
controller = alloca(len + 1);
strcpy(controller, filename); strcpy(controller, filename);
if ((p = strchr(controller, '.')) != NULL) p = strchr(controller, '.');
if (p)
*p = '\0'; *p = '\0';
if (strcmp("devices.allow", filename) == 0 && value[0] == '/') { if (strcmp("devices.allow", filename) == 0 && value[0] == '/') {
...@@ -2684,7 +2686,6 @@ static int cg_legacy_set_data(const char *filename, const char *value, ...@@ -2684,7 +2686,6 @@ static int cg_legacy_set_data(const char *filename, const char *value,
if (ret < 0) if (ret < 0)
return ret; return ret;
value = converted_value; value = converted_value;
} }
h = get_hierarchy(controller); h = get_hierarchy(controller);
...@@ -2694,7 +2695,7 @@ static int cg_legacy_set_data(const char *filename, const char *value, ...@@ -2694,7 +2695,7 @@ static int cg_legacy_set_data(const char *filename, const char *value,
"driver or not enabled on the cgroup hierarchy", "driver or not enabled on the cgroup hierarchy",
controller); controller);
errno = ENOENT; errno = ENOENT;
return -1; return -ENOENT;
} }
fullpath = must_make_path(h->fullcgpath, filename, NULL); fullpath = must_make_path(h->fullcgpath, filename, NULL);
......
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