mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-08 06:36:28 +00:00
cgroups: cgfsng_get: handle unified hierarchy
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
c2aed66d0f
commit
0069cc619e
@ -2352,28 +2352,34 @@ static bool cgfsng_attach(const char *name, const char *lxcpath, pid_t pid)
|
|||||||
* Here we don't have a cgroup_data set up, so we ask the running
|
* Here we don't have a cgroup_data set up, so we ask the running
|
||||||
* container through the commands API for the cgroup path
|
* container through the commands API for the cgroup path
|
||||||
*/
|
*/
|
||||||
static int cgfsng_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
|
static int cgfsng_get(const char *filename, char *value, size_t len,
|
||||||
|
const char *name, const char *lxcpath)
|
||||||
{
|
{
|
||||||
char *subsystem, *p, *path;
|
|
||||||
struct hierarchy *h;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
size_t controller_len;
|
||||||
|
char *controller, *p, *path;
|
||||||
|
struct hierarchy *h;
|
||||||
|
|
||||||
subsystem = alloca(strlen(filename) + 1);
|
controller_len = strlen(filename);
|
||||||
strcpy(subsystem, filename);
|
controller = alloca(controller_len + 1);
|
||||||
if ((p = strchr(subsystem, '.')) != NULL)
|
strcpy(controller, filename);
|
||||||
|
p = strchr(controller, '.');
|
||||||
|
if (p)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
path = lxc_cmd_get_cgroup_path(name, lxcpath, subsystem);
|
path = lxc_cmd_get_cgroup_path(name, lxcpath, controller);
|
||||||
if (!path) /* not running */
|
/* not running */
|
||||||
|
if (!path)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
h = get_hierarchy(subsystem);
|
h = get_hierarchy(controller);
|
||||||
if (h) {
|
if (h) {
|
||||||
char *fullpath = build_full_cgpath_from_monitorpath(h, path, filename);
|
char *fullpath;
|
||||||
|
|
||||||
|
fullpath = build_full_cgpath_from_monitorpath(h, path, filename);
|
||||||
ret = lxc_read_from_file(fullpath, value, len);
|
ret = lxc_read_from_file(fullpath, value, len);
|
||||||
free(fullpath);
|
free(fullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user