summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2010-01-07 16:24:34 +0530
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2010-01-07 21:09:08 +0530
commite1cc4cb97e00a1878541cc78bc3e5103a266da2e (patch)
tree1919a9f6b6e1143b2a01825f373b8a32bafe1f8f /src/config.c
parente2104d8c20d068dcd927ac4c99b7ddb390eb4f10 (diff)
downloadlibcg-e1cc4cb97e00a1878541cc78bc3e5103a266da2e.tar.gz
libcg-e1cc4cb97e00a1878541cc78bc3e5103a266da2e.tar.xz
libcg-e1cc4cb97e00a1878541cc78bc3e5103a266da2e.zip
libcgroup: Introduce the new namespace keyword
This patch introduces a new keywork NAMESPACE which allow cgroups to be created starting from a certain point as mentioned by the administrator. This is provided via the configuration file. Newer APIs will use this feature. Changes from v1: 1. Attempted to fix the indentation 2. Change a variable name Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 130fac1..7435795 100644
--- a/src/config.c
+++ b/src/config.c
@@ -59,8 +59,11 @@ extern int yyparse(void);
* cgroup_table_index -> Where in the cgroup_table we are.
*/
static struct cg_mount_table_s config_mount_table[CG_CONTROLLER_MAX];
+static struct cg_mount_table_s config_namespace_table[CG_CONTROLLER_MAX];
static int config_table_index;
+static int namespace_table_index;
static pthread_rwlock_t config_table_lock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t namespace_table_lock = PTHREAD_RWLOCK_INITIALIZER;
static struct cgroup config_cgroup_table[MAX_CGROUPS];
int cgroup_table_index;
@@ -352,6 +355,36 @@ void cgroup_config_cleanup_mount_table(void)
}
/*
+ * The moment we have found the controller's information
+ * insert it into the config_mount_table.
+ */
+int cgroup_config_insert_into_namespace_table(char *name, char *nspath)
+{
+ if (namespace_table_index >= CG_CONTROLLER_MAX)
+ return 0;
+
+ pthread_rwlock_wrlock(&namespace_table_lock);
+
+ strcpy(config_namespace_table[namespace_table_index].name, name);
+ strcpy(config_namespace_table[namespace_table_index].path, nspath);
+ namespace_table_index++;
+
+ pthread_rwlock_unlock(&namespace_table_lock);
+ free(name);
+ free(nspath);
+ return 1;
+}
+
+/*
+ * Cleanup all the data from the config_mount_table
+ */
+void cgroup_config_cleanup_namespace_table(void)
+{
+ memset(&config_namespace_table, 0,
+ sizeof(struct cg_mount_table_s) * CG_CONTROLLER_MAX);
+}
+
+/*
* Start mounting the mount table.
*/
int cgroup_config_mount_fs()