summaryrefslogtreecommitdiffstats
path: root/src/cgls
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-03-14 17:58:08 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-03-14 18:03:32 +0100
commitec38ec55ee138c80e56d448de110c47791040540 (patch)
treeb2cbf72a7df7685c966fab98b1fe08e6b25d0b3a /src/cgls
parentcgls: stop showing cgroup ids and xattrs by default (diff)
downloadsystemd-ec38ec55ee138c80e56d448de110c47791040540.tar.xz
systemd-ec38ec55ee138c80e56d448de110c47791040540.zip
cgls: add -x and -c options
-x is short for --xattrs=yes and -c is short for --cgroup-id=yes.
Diffstat (limited to 'src/cgls')
-rw-r--r--src/cgls/cgls.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index a0c0d29116..32780c606a 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -54,11 +54,11 @@ static int help(void) {
" -a --all Show all groups, including empty\n"
" -u --unit Show the subtrees of specified system units\n"
" --user-unit Show the subtrees of specified user units\n"
- " --xattr=BOOL Show cgroup extended attributes\n"
- " --cgroup-id=BOOL Show cgroup ID\n"
+ " -x --xattr=BOOL Show cgroup extended attributes\n"
+ " -c --cgroup-id=BOOL Show cgroup ID\n"
" -l --full Do not ellipsize output\n"
" -k Include kernel threads in output\n"
- " -M --machine= Show container\n"
+ " -M --machine=NAME Show container NAME\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
link);
@@ -72,8 +72,6 @@ static int parse_argv(int argc, char *argv[]) {
ARG_NO_PAGER = 0x100,
ARG_VERSION,
ARG_USER_UNIT,
- ARG_XATTR,
- ARG_CGROUP_ID,
};
static const struct option options[] = {
@@ -85,8 +83,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "machine", required_argument, NULL, 'M' },
{ "unit", optional_argument, NULL, 'u' },
{ "user-unit", optional_argument, NULL, ARG_USER_UNIT },
- { "xattr", required_argument, NULL, ARG_XATTR },
- { "cgroup-id", required_argument, NULL, ARG_CGROUP_ID },
+ { "xattr", required_argument, NULL, 'x' },
+ { "cgroup-id", required_argument, NULL, 'c' },
{}
};
@@ -95,7 +93,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
assert(argv);
- while ((c = getopt_long(argc, argv, "-hkalM:u::", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "-hkalM:u::xc", options, NULL)) >= 0)
switch (c) {
@@ -143,18 +141,24 @@ static int parse_argv(int argc, char *argv[]) {
arg_machine = optarg;
break;
- case ARG_XATTR:
- r = parse_boolean(optarg);
- if (r < 0)
- return log_error_errno(r, "Failed to parse --xattr= value: %s", optarg);
+ case 'x':
+ if (optarg) {
+ r = parse_boolean(optarg);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse --xattr= value: %s", optarg);
+ } else
+ r = true;
SET_FLAG(arg_output_flags, OUTPUT_CGROUP_XATTRS, r);
break;
- case ARG_CGROUP_ID:
- r = parse_boolean(optarg);
- if (r < 0)
- return log_error_errno(r, "Failed to parse --cgroup-id= value: %s", optarg);
+ case 'c':
+ if (optarg) {
+ r = parse_boolean(optarg);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse --cgroup-id= value: %s", optarg);
+ } else
+ r = true;
SET_FLAG(arg_output_flags, OUTPUT_CGROUP_ID, r);
break;