diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-04-12 05:17:30 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-04-12 05:17:30 +0000 |
commit | bbb65f3bbe504ad029577618708068a6ef9a9e57 (patch) | |
tree | c1b22070da7d50339cc354deaf5770130e633f1d /api.c | |
parent | 2be6ec85fb430e17afcf16b0ab84e4f966920472 (diff) | |
download | libcg-bbb65f3bbe504ad029577618708068a6ef9a9e57.tar.gz libcg-bbb65f3bbe504ad029577618708068a6ef9a9e57.tar.xz libcg-bbb65f3bbe504ad029577618708068a6ef9a9e57.zip |
Got recursive chown to work. API needs more changes to be able to ignore
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
Diffstat (limited to 'api.c')
-rw-r--r-- | api.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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)) { |