From: Dhaval Giani Date: Mon, 17 May 2010 16:54:48 +0000 (+0200) Subject: libcgroup: Add support for named hierarchies. X-Git-Tag: v0.36~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=248f59e202c545b8fffbc73bc869f0a7e31e00a3;p=thirdparty%2Flibcgroup.git 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 --- 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);