return 1;
}
+/*
+ * TODO: This call just sets the name of the template. It will
+ * always be called in the end, because the parser will
+ * work bottom up.
+ */
+int template_config_insert_cgroup(char *cg_name)
+{
+ return 1;
+}
+
/*
* This function sets the various controller's control
* files. It will always append values for cgroup_table_index
return 0;
}
+/* TODO: This function sets the various controller's control
+ * files. It will always append values for config_template_table_index
+ * entry in the config_template_table. The index is incremented in
+ * temlate_config_insert_cgroup
+ */
+int template_config_parse_controller_options(char *controller,
+ struct cgroup_dictionary *values)
+{
+ return 1;
+}
+
/*
* Sets the tasks file's uid and gid
*/
return 0;
}
+/*
+ * TODO: Sets the tasks file's uid and gid for templates
+ */
+int template_config_group_task_perm(char *perm_type, char *value)
+{
+ return 1;
+}
+
/*
* Set the control file's uid/gid
*/
return 0;
}
+/*
+ * TODO: Set the control file's uid and gid for templates
+ */
+int template_config_group_admin_perm(char *perm_type, char *value)
+{
+ return 1;
+}
+
/*
* The moment we have found the controller's information
* insert it into the config_mount_table.
int cgroup_config_insert_cgroup(char *cg_name);
int cgroup_config_parse_controller_options(char *controller,
struct cgroup_dictionary *values);
+int template_config_insert_cgroup(char *cg_name);
+int template_config_parse_controller_options(char *controller,
+ struct cgroup_dictionary *values);
+int template_config_group_task_perm(char *perm_type, char *value);
+int template_config_group_admin_perm(char *perm_type, char *value);
int cgroup_config_group_task_perm(char *perm_type, char *value);
int cgroup_config_group_admin_perm(char *perm_type, char *value);
int cgroup_config_insert_into_mount_table(char *name, char *mount_point);
%}
-%token ID MOUNT GROUP PERM TASK ADMIN NAMESPACE DEFAULT
+%token ID MOUNT GROUP PERM TASK ADMIN NAMESPACE DEFAULT TEMPLATE
%union {
char *name;
%type <val> admin_conf task_conf task_or_admin group_conf group start
%type <val> namespace namespace_conf default default_conf
%type <values> namevalue_conf
+%type <val> template template_conf
+%type <val> template_task_or_admin template_task_namevalue_conf
+%type <val> template_admin_namevalue_conf
%start start
%%
{
$$ = $1;
}
+ | start template
+ {
+ $$ = $1;
+ }
|
{
$$ = 1;
}
;
+template : TEMPLATE ID '{' template_conf '}'
+ {
+ $$ = $4;
+ if ($$) {
+ $$ = template_config_insert_cgroup($2);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGOTHER;
+ return $$;
+ }
+ } else {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ ;
+
+
+template_conf
+ : ID '{' namevalue_conf '}'
+ {
+ $$ = template_config_parse_controller_options($1, $3);
+ cgroup_dictionary_free($3);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ | template_conf ID '{' namevalue_conf '}'
+ {
+ $$ = template_config_parse_controller_options($2, $4);
+ cgroup_dictionary_free($4);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ | PERM '{' template_task_or_admin '}'
+ {
+ $$ = $3;
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ ;
+
+template_task_or_admin
+ : TASK '{' template_task_namevalue_conf '}' admin_conf
+ {
+ $$ = $3 && $5;
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ | ADMIN '{' template_admin_namevalue_conf '}' task_conf
+ {
+ $$ = $3 && $5;
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ ;
+
+
namevalue_conf
: ID '=' ID ';'
{
}
;
+template_task_namevalue_conf
+ : ID '=' ID ';'
+ {
+ $$ = template_config_group_task_perm($1, $3);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ | task_namevalue_conf ID '=' ID ';'
+ {
+ $$ = $1 && template_config_group_task_perm($2, $4);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ ;
+
+template_admin_namevalue_conf
+ : ID '=' ID ';'
+ {
+ $$ = template_config_group_admin_perm($1, $3);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ | admin_namevalue_conf ID '=' ID ';'
+ {
+ $$ = $1 && template_config_group_admin_perm($2, $4);
+ if (!$$) {
+ fprintf(stderr, "parsing failed at line number %d\n",
+ line_no);
+ $$ = ECGCONFIGPARSEFAIL;
+ return $$;
+ }
+ }
+ ;
+
+
task_or_admin
: TASK '{' task_namevalue_conf '}' admin_conf
{