diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-04-16 17:35:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-04-16 18:59:08 +0200 |
commit | c3175a7f40a2d2fabc3a2de63033a6810d45221a (patch) | |
tree | 60f589e8b66241145a03b7c65890cec649510f5d /src/cgls/cgls.c | |
parent | c7b5eb98e8eeafe63a079ee3c51e9670872437ae (diff) |
cgls: don't show empty cgroups by default
Diffstat (limited to 'src/cgls/cgls.c')
-rw-r--r-- | src/cgls/cgls.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index fd02d52c23..4bec6a827e 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -31,16 +31,20 @@ #include "log.h" #include "util.h" #include "pager.h" +#include "build.h" static bool arg_no_pager = false; static bool arg_kernel_threads = false; +static bool arg_all = false; static void help(void) { printf("%s [OPTIONS...] [CGROUP...]\n\n" "Recursively show control group contents.\n\n" " -h --help Show this help\n" + " --version Show package version\n" " --no-pager Do not pipe output into a pager\n" + " -a --all Show all groups, including empty\n" " -k Include kernel threads in output\n", program_invocation_short_name); } @@ -48,12 +52,15 @@ static void help(void) { static int parse_argv(int argc, char *argv[]) { enum { - ARG_NO_PAGER = 0x100 + ARG_NO_PAGER = 0x100, + ARG_VERSION }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, ARG_VERSION }, { "no-pager", no_argument, NULL, ARG_NO_PAGER }, + { "all", no_argument, NULL, 'a' }, { NULL, 0, NULL, 0 } }; @@ -62,7 +69,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 1); assert(argv); - while ((c = getopt_long(argc, argv, "hk", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hka", options, NULL)) >= 0) { switch (c) { @@ -70,10 +77,20 @@ static int parse_argv(int argc, char *argv[]) { help(); return 0; + case ARG_VERSION: + puts(PACKAGE_STRING); + puts(DISTRIBUTION); + puts(SYSTEMD_FEATURES); + return 0; + case ARG_NO_PAGER: arg_no_pager = true; break; + case 'a': + arg_all = true; + break; + case 'k': arg_kernel_threads = true; break; @@ -114,7 +131,7 @@ int main(int argc, char *argv[]) { int q; printf("%s:\n", argv[i]); - q = show_cgroup_by_path(argv[i], NULL, 0, arg_kernel_threads); + q = show_cgroup_by_path(argv[i], NULL, 0, arg_kernel_threads, arg_all); if (q < 0) r = q; } @@ -130,7 +147,7 @@ int main(int argc, char *argv[]) { if (path_startswith(p, "/sys/fs/cgroup")) { printf("Working Directory %s:\n", p); - r = show_cgroup_by_path(p, NULL, 0, arg_kernel_threads); + r = show_cgroup_by_path(p, NULL, 0, arg_kernel_threads, arg_all); } else { char *root = NULL; const char *t = NULL; @@ -145,7 +162,7 @@ int main(int argc, char *argv[]) { t = root[0] ? root : "/"; } - r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0, arg_kernel_threads); + r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0, arg_kernel_threads, arg_all); free(root); } |