]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Adds option to lssubsys tool for unmount controllers in hierrachy
authorIvana Hutarova Varekova <varekova@redhat.com>
Fri, 13 Aug 2010 13:00:54 +0000 (15:00 +0200)
committerJan Safranek <jsafrane@redhat.com>
Thu, 19 Aug 2010 10:29:03 +0000 (12:29 +0200)
This patch adds option new option "-i" to lssubsys tool. This option displays for mount controllers
the number of hierarchie in which they are:

SEMANTIC:
lssubsys  [-m|--mount-points] [-i|--hierarchies] [-a|--all]

-i, --hierrachies
              Display attached hierarchy number, if the subsystem is in a hierrachy.
If the option -m is used too, then the hierarchy number is shown only for not mounted hierarchies.

EXAMPLE:
        $ lssubsys -ami
        ns
        cpuset 5
        cpu,devices 6
        cpuacct /cgroup/cpuacct
        memory /cgroup/memory
        freezer /cgroup/freezer
        net_cls /cgroup/net_cls

        $ lssubsys -ai
        ns
        cpuset 5
        cpu,devices 6
        cpuacct 7
        memory 8
        freezer 9
        net_cls 4

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/tools/lssubsys.c

index e48daa6cfe5cd463c657df8e8852d305f5087632..f1225be0bfdb69a3745891734744934810dc7c7a 100644 (file)
@@ -22,7 +22,8 @@
 enum flag{
     FL_MOUNT = 1,      /* show the mount points */
     FL_LIST = 2,
-    FL_ALL = 4         /* show all subsystems - not mounted too */
+    FL_ALL = 4,                /* show all subsystems - not mounted too */
+    FL_HIERARCHY = 8   /* show info about hierarchies */
 };
 
 typedef char cont_name_t[FILENAME_MAX];
@@ -46,6 +47,8 @@ static void usage(int status, const char *program_name)
                fprintf(stdout, "  -a, --all            "\
                        "Display information about all controllers "\
                        "(including not mounted ones) \n");
+               fprintf(stdout, "  -i, --hierarchies    Display information "\
+                       "about hierarchies\n");
        }
 }
 
@@ -246,7 +249,10 @@ next:
        }
 
        cgroup_get_all_controller_end(&handle);
-       printf("\n");
+       if (flags & FL_HIERARCHY)
+               printf(" %d\n", hierarchy);
+       else
+               printf("\n");
 
        if (ret == ECGEOF)
                ret = 0;
@@ -323,6 +329,7 @@ int main(int argc, char *argv[])
                {"help", 0, 0, 'h'},
                {"mount-points", 0, 0, 'm'},
                {"all", 0, 0, 'a'},
+               {"hierarchies", 0, 0, 'i'},
                {0, 0, 0, 0}
        };
 
@@ -330,7 +337,7 @@ int main(int argc, char *argv[])
                cont_name[i][0] = '\0';
 
        /* parse arguments */
-       while ((c = getopt_long(argc, argv, "mha", options, NULL)) > 0) {
+       while ((c = getopt_long(argc, argv, "mhai", options, NULL)) > 0) {
                switch (c) {
                case 'h':
                        usage(0, argv[0]);
@@ -341,6 +348,9 @@ int main(int argc, char *argv[])
                case 'a':
                        flags |= FL_ALL;
                        break;
+               case 'i':
+                       flags |= FL_HIERARCHY;
+                       break;
                default:
                        usage(1, argv[0]);
                        return -1;