The functionality was necessary because of cg_build_path function add useless 
"/" characters to the patch. This is fixed by the previous api patch.
Moreover other unix commands (du, grep) leave the format of path as it was 
added in input (with all typed "/" characters). Thus lscgroup should not remove 
"/" which were added in command line.


Example
old version:
$ lscgroup memory://abc///
memory:/abc///
memory:/abc///gh
memory:/abc///def
$ lscgroup
cpuset:/
cpuset:/3



new version:
$ lscgroup memory://abc///
memory://abc///
memory://abc///gh
memory://abc///def
$ lscgroup
cpuset:/
cpuset:/3



Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
---

 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/src/tools/lscgroup.c b/src/tools/lscgroup.c
index c16f193..3b74aad 100644
--- a/src/tools/lscgroup.c
+++ b/src/tools/lscgroup.c
@@ -87,20 +87,25 @@ static int display_controller_data(char *input_path, char 
*controller, char *nam
        int ret;
        void *handle;
        struct cgroup_file_info info;
+       char cgroup_dir_path[FILENAME_MAX];
        char input_dir_path[FILENAME_MAX];
        int lvl;
        int len;
 
-       strncpy(input_dir_path, input_path, FILENAME_MAX);
-       /* remove problematic  '/' characters from input path */
-       trim_filepath(input_dir_path);
-
-       ret = cgroup_walk_tree_begin(controller, input_dir_path, 0,
+       ret = cgroup_walk_tree_begin(controller, input_path, 0,
                &handle, &info, &lvl);
        if (ret != 0)
                return ret;
 
-       len  = strlen(info.full_path) - strlen(input_dir_path) - 1;
+       strncpy(cgroup_dir_path, info.full_path, FILENAME_MAX);
+       /* remove problematic  '/' characters from cgroup directory path*/
+       trim_filepath(cgroup_dir_path);
+
+       strncpy(input_dir_path, input_path, FILENAME_MAX);
+
+       /* remove problematic  '/' characters from input directory path*/
+       trim_filepath(input_dir_path);
+       len  = strlen(cgroup_dir_path) - strlen(input_dir_path);
        print_info(&info, name, len);
        while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) == 0)
                print_info(&info, name, len);


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to