]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
lscgroup: Fixed too many '/' characters on output
authorJan Safranek <jsafrane@redhat.com>
Mon, 21 Nov 2011 12:55:46 +0000 (13:55 +0100)
committerJan Safranek <jsafrane@redhat.com>
Tue, 22 Nov 2011 12:44:24 +0000 (13:44 +0100)
Fix the calculation of path prefixes and prevent addtional slashes in
libcgroup output.

I.e. instead of:
$ lscgroup cpu:/
cpu:///
cpu:///system

show:
$ lscgroup cpu:/
cpu:/
cpu:/system

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Balbir Singh <bsingharora@gmail.com>
src/tools/lscgroup.c

index 0b3e502f9b2436312196fb53e9013549f553bbb4..6ebf8d4fb8ab038e5f0b6f0f376d57ea8a2596a6 100644 (file)
@@ -97,15 +97,11 @@ static int display_controller_data(char *input_path, char *controller, char *nam
        if (ret != 0)
                return ret;
 
-       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 path*/
-       trim_filepath(cgroup_dir_path);
+       trim_filepath(input_dir_path);
 
-       len  = strlen(cgroup_dir_path) - strlen(input_dir_path) + 1;
+       len  = strlen(info.full_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);