From 248f59e202c545b8fffbc73bc869f0a7e31e00a3 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Mon, 17 May 2010 18:54:48 +0200 Subject: [PATCH] libcgroup: Add support for named hierarchies. This feature has been available in the kernel for sometime, but was missed by libcgroup. Add support for named hierarchies. The controller is identified as name= and used in such fashion. Signed-off-by: Dhaval Giani --- src/api.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/api.c b/src/api.c index 2d4cd21e..53c94300 100644 --- a/src/api.c +++ b/src/api.c @@ -759,6 +759,39 @@ int cgroup_init(void) ent->mnt_opts, found_mnt); found_mnt++; } + + /* + * Doesn't match the controller. + * Check if it is a named hierarchy. + */ + mntopt = hasmntopt(ent, "name"); + + if (mntopt) { + mntopt = strtok_r(mntopt, ",", &strtok_buffer); + /* + * Check if it is a duplicate + */ + duplicate = 0; + for (j = 0; j < found_mnt; j++) { + if (strncmp(mntopt, cg_mount_table[j].name, + FILENAME_MAX) == 0) { + duplicate = 1; + break; + } + } + + if (duplicate) { + cgroup_dbg("controller %s is already mounted on %s\n", + mntopt, cg_mount_table[j].path); + continue; + } + + strcpy(cg_mount_table[found_mnt].name, mntopt); + strcpy(cg_mount_table[found_mnt].path, ent->mnt_dir); + cgroup_dbg("Found cgroup option %s, count %d\n", + ent->mnt_opts, found_mnt); + found_mnt++; + } } free(temp_ent); -- 2.47.2