to avoid to use the LXCPATH/<name>/nsgroup

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
 src/lxc/cgroup.c  |    2 +-
 src/lxc/cgroup.h  |    1 +
 src/lxc/freezer.c |   12 ++++++++----
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
index c3f74c1..499b0d1 100644
--- a/src/lxc/cgroup.c
+++ b/src/lxc/cgroup.c
@@ -155,7 +155,7 @@ int lxc_unlink_nsgroup(const char *name)
 	return unlink(nsgroup);
 }

-static int lxc_cgroup_path_get(char **path, const char *name)
+int lxc_cgroup_path_get(char **path, const char *name)
 {
 	char cgroup[MAXPATHLEN];

diff --git a/src/lxc/cgroup.h b/src/lxc/cgroup.h
index 6863247..cc125b2 100644
--- a/src/lxc/cgroup.h
+++ b/src/lxc/cgroup.h
@@ -30,5 +30,6 @@ int lxc_get_cgroup_mount(const char *mtab, char *mnt);
 int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler);
 int lxc_link_nsgroup(const char *name, const char *nsgroup);
 int lxc_unlink_nsgroup(const char *name);
+int lxc_cgroup_path_get(char **path, const char *name);

 #endif
diff --git a/src/lxc/freezer.c b/src/lxc/freezer.c
index 0c0f405..f4b4018 100644
--- a/src/lxc/freezer.c
+++ b/src/lxc/freezer.c
@@ -39,11 +39,15 @@ lxc_log_define(lxc_freezer, lxc);

 static int freeze_unfreeze(const char *name, int freeze)
 {
+	char *nsgroup;
 	char freezer[MAXPATHLEN], *f;
-	int fd, ret = -1;
+	int fd, ret;
 	
-	snprintf(freezer, MAXPATHLEN, 
-		 LXCPATH "/%s/nsgroup/freezer.state", name);
+	ret = lxc_cgroup_path_get(&nsgroup, name);
+	if (ret)
+		return -1;
+
+	snprintf(freezer, MAXPATHLEN, "%s/freezer.state", nsgroup);

 	fd = open(freezer, O_WRONLY);
 	if (fd < 0) {
@@ -69,7 +73,7 @@ static int freeze_unfreeze(const char *name, int freeze)
 	if (ret) 
 		SYSERROR("failed to write to '%s'", freezer);

-	return 0;
+	return ret;
 }

 int lxc_freeze(const char *name)
-- 
1.6.3.3

-- 

--===============1435666201==
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

_______________________________________________
Linux mailing list
Linux@www.lab.toulouse-stg.fr.ibm.com
http://www.lab.toulouse-stg.fr.ibm.com/mailman/listinfo/linux

--===============1435666201==--




