mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
cgls: add -x and -c options
-x is short for --xattrs=yes and -c is short for --cgroup-id=yes.
This commit is contained in:
parent
5346bb499f
commit
ec38ec55ee
@ -106,17 +106,20 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
<term><option>-x</option></term>
|
||||||
<term><option>--xattr=</option></term>
|
<term><option>--xattr=</option></term>
|
||||||
|
|
||||||
<listitem><para>Controls whether to include information about extended attributes of the listed
|
<listitem><para>Controls whether to include information about extended attributes of the listed
|
||||||
control groups in the output. Expects a boolean value. Defaults to no.</para></listitem>
|
control groups in the output. With the long option, expects a boolean value. Defaults to no.
|
||||||
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
<term><option>-c</option></term>
|
||||||
<term><option>--cgroup-id=</option></term>
|
<term><option>--cgroup-id=</option></term>
|
||||||
|
|
||||||
<listitem><para>Controls whether to include the numeric ID of the listed control groups in the
|
<listitem><para>Controls whether to include the numeric ID of the listed control groups in the
|
||||||
output. Expects a boolean value. Defaults to no.</para></listitem>
|
output. With the long option, expects a boolean value. Defaults to no.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
|
@ -54,11 +54,11 @@ static int help(void) {
|
|||||||
" -a --all Show all groups, including empty\n"
|
" -a --all Show all groups, including empty\n"
|
||||||
" -u --unit Show the subtrees of specified system units\n"
|
" -u --unit Show the subtrees of specified system units\n"
|
||||||
" --user-unit Show the subtrees of specified user units\n"
|
" --user-unit Show the subtrees of specified user units\n"
|
||||||
" --xattr=BOOL Show cgroup extended attributes\n"
|
" -x --xattr=BOOL Show cgroup extended attributes\n"
|
||||||
" --cgroup-id=BOOL Show cgroup ID\n"
|
" -c --cgroup-id=BOOL Show cgroup ID\n"
|
||||||
" -l --full Do not ellipsize output\n"
|
" -l --full Do not ellipsize output\n"
|
||||||
" -k Include kernel threads in 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",
|
"\nSee the %s for details.\n",
|
||||||
program_invocation_short_name,
|
program_invocation_short_name,
|
||||||
link);
|
link);
|
||||||
@ -72,8 +72,6 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
ARG_NO_PAGER = 0x100,
|
ARG_NO_PAGER = 0x100,
|
||||||
ARG_VERSION,
|
ARG_VERSION,
|
||||||
ARG_USER_UNIT,
|
ARG_USER_UNIT,
|
||||||
ARG_XATTR,
|
|
||||||
ARG_CGROUP_ID,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
@ -85,8 +83,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
{ "machine", required_argument, NULL, 'M' },
|
{ "machine", required_argument, NULL, 'M' },
|
||||||
{ "unit", optional_argument, NULL, 'u' },
|
{ "unit", optional_argument, NULL, 'u' },
|
||||||
{ "user-unit", optional_argument, NULL, ARG_USER_UNIT },
|
{ "user-unit", optional_argument, NULL, ARG_USER_UNIT },
|
||||||
{ "xattr", required_argument, NULL, ARG_XATTR },
|
{ "xattr", required_argument, NULL, 'x' },
|
||||||
{ "cgroup-id", required_argument, NULL, ARG_CGROUP_ID },
|
{ "cgroup-id", required_argument, NULL, 'c' },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,7 +93,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
assert(argc >= 1);
|
assert(argc >= 1);
|
||||||
assert(argv);
|
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) {
|
switch (c) {
|
||||||
|
|
||||||
@ -143,18 +141,24 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
arg_machine = optarg;
|
arg_machine = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_XATTR:
|
case 'x':
|
||||||
r = parse_boolean(optarg);
|
if (optarg) {
|
||||||
if (r < 0)
|
r = parse_boolean(optarg);
|
||||||
return log_error_errno(r, "Failed to parse --xattr= value: %s", 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);
|
SET_FLAG(arg_output_flags, OUTPUT_CGROUP_XATTRS, r);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_CGROUP_ID:
|
case 'c':
|
||||||
r = parse_boolean(optarg);
|
if (optarg) {
|
||||||
if (r < 0)
|
r = parse_boolean(optarg);
|
||||||
return log_error_errno(r, "Failed to parse --cgroup-id= value: %s", 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);
|
SET_FLAG(arg_output_flags, OUTPUT_CGROUP_ID, r);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user