Add the missing parts to make cgconfigparser able to mount named
hierarchies. It must add 'none' option to mount opts for mount without real
controller and with 'name=xxx' only, the rest (surprisingly) works out of the
box, only quoting needs special care.

Following cgconfig.conf is usable with the patch:
mount {
        "name=test" = /cgroup/test;

        "name=testwithcpu" = /cgroup/cpu;
        cpu = /cgroup/cpu;
}

group foo {
        "name=test" { }
        "name=testwithcpu" { }
        cpu { cpu.shares = 1024; }
}

Signed-off-by: Jan Safranek <[email protected]>
---

 src/config.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/config.c b/src/config.c
index 5c4598c..f1873ea 100644
--- a/src/config.c
+++ b/src/config.c
@@ -390,6 +390,39 @@ void cgroup_config_cleanup_namespace_table(void)
                        sizeof(struct cg_mount_table_s) * CG_CONTROLLER_MAX);
 }
 
+/**
+ * Add necessary options for mount. Currently only 'none' option is added
+ * for mounts with only 'name=xxx' and without real controller.
+ */
+static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount)
+{
+       char *save = NULL;
+       char *opts = strdup(mount->name);
+       char *token;
+       int name_only = 1;
+
+       if (opts == NULL)
+               return ECGFAIL;
+
+       token = strtok_r(opts, ",", &save);
+       while (token != NULL) {
+               if (strncmp(token, "name=", 5) != 0) {
+                       name_only = 0;
+                       break;
+               }
+               token = strtok_r(NULL, ",", &save);
+       }
+
+       free(opts);
+       if (name_only) {
+               strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
+               strncat(mount->name, "none",
+                               FILENAME_MAX - strlen(mount->name) - 1);
+       }
+
+       return 0;
+}
+
 /*
  * Start mounting the mount table.
  */
@@ -419,6 +452,10 @@ static int cgroup_config_mount_fs(void)
                        return ECGOTHER;
                }
 
+               ret = cgroup_config_ajdust_mount_options(curr);
+               if (ret)
+                       return ret;
+
                ret = mount(CGROUP_FILESYSTEM, curr->mount.path,
                                CGROUP_FILESYSTEM, 0, curr->name);
 


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to