]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Got recursive chown to work. API needs more changes to be able to ignore
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Sat, 12 Apr 2008 05:17:30 +0000 (05:17 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Sat, 12 Apr 2008 05:17:30 +0000 (05:17 +0000)
ownership arguments.

 api.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@13 4f4bb910-9a46-0410-90c8-c897d4f1cd53

api.c

diff --git a/api.c b/api.c
index 8bf5607d573377582db2a2e8a79bce0f9c8c7e21..8dbeab99df74e5f32d0cd21c36a8f5a8b1a6aa8f 100644 (file)
--- a/api.c
+++ b/api.c
@@ -71,11 +71,11 @@ static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group)
 /*
  * TODO: Need to decide a better place to put this function.
  */
-static int cg_chown_recursive(const char *path, uid_t owner, gid_t group)
+static int cg_chown_recursive(char **path, uid_t owner, gid_t group)
 {
        int ret = 1;
-       dbg("path is %s\n", path);
-       FTS *fts = fts_open((char **)&path, FTS_PHYSICAL | FTS_NOCHDIR |
+       dbg("path is %s\n", *path);
+       FTS *fts = fts_open(path, FTS_PHYSICAL | FTS_NOCHDIR |
                                FTS_NOSTAT, NULL);
        while (1) {
                FTSENT *ent;
@@ -342,13 +342,15 @@ err:
  */
 int cg_create_cgroup(struct cgroup *cgroup)
 {
-       char *path, base[FILENAME_MAX];
+       char *fts_path[2], base[FILENAME_MAX], *path;
        int i;
        int error;
 
-       path = (char *)malloc(FILENAME_MAX);
-       if (!path)
+       fts_path[0] = (char *)malloc(FILENAME_MAX);
+       if (!fts_path[0])
                return ENOMEM;
+       fts_path[1] = NULL;
+       path = fts_path[0];
 
        cg_build_path(cgroup->name, path);
        error = cg_create_control_group(path);
@@ -357,7 +359,7 @@ int cg_create_cgroup(struct cgroup *cgroup)
 
        strcpy(base, path);
 
-       cg_chown_recursive(path, cgroup->control_uid, cgroup->control_gid);
+       cg_chown_recursive(fts_path, cgroup->control_uid, cgroup->control_gid);
 
        for (i = 0; i < CG_CONTROLLER_MAX && cgroup->controller[i];
                                                i++, strcpy(path, base)) {