mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
analyze: add "architectures" verb that lists all known architectures
This commit is contained in:
parent
fb45185d98
commit
fb8cc599ed
|
@ -179,6 +179,12 @@
|
||||||
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
||||||
<arg choice="plain">srk</arg> ><arg choice="plain"><replaceable>FILE</replaceable></arg>
|
<arg choice="plain">srk</arg> ><arg choice="plain"><replaceable>FILE</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>systemd-analyze</command>
|
||||||
|
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
||||||
|
<arg choice="plain">architectures</arg>
|
||||||
|
<arg choice="opt" rep="repeat"><replaceable>NAME</replaceable></arg>
|
||||||
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
@ -941,6 +947,32 @@ NR NAME SHA256
|
||||||
<programlisting>systemd-analyze srk > srk.tpm2b_public</programlisting>
|
<programlisting>systemd-analyze srk > srk.tpm2b_public</programlisting>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
|
|
||||||
|
<refsect2>
|
||||||
|
<title><command>systemd-analyze architectures <optional><replaceable>NAME</replaceable>...</optional></command></title>
|
||||||
|
|
||||||
|
<para>Lists all known CPU architectures, and which ones are native. The listed architecture names are
|
||||||
|
those <varname>ConditionArchitecture=</varname> supports, see
|
||||||
|
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
|
||||||
|
details. If architecture names are specified only those specified are listed.</para>
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>Table output</title>
|
||||||
|
<programlisting>$ systemd-analyze architectures
|
||||||
|
NAME SUPPORT
|
||||||
|
alpha foreign
|
||||||
|
arc foreign
|
||||||
|
arc-be foreign
|
||||||
|
arm foreign
|
||||||
|
arm64 foreign
|
||||||
|
…
|
||||||
|
sparc foreign
|
||||||
|
sparc64 foreign
|
||||||
|
tilegx foreign
|
||||||
|
x86 secondary
|
||||||
|
x86-64 native</programlisting>
|
||||||
|
</example>
|
||||||
|
</refsect2>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|
|
@ -1321,6 +1321,10 @@
|
||||||
<literal>arc-be</literal>, or
|
<literal>arc-be</literal>, or
|
||||||
<literal>native</literal>.</para>
|
<literal>native</literal>.</para>
|
||||||
|
|
||||||
|
<para>Use
|
||||||
|
<citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||||
|
for the complete list of known architectures.</para>
|
||||||
|
|
||||||
<para>The architecture is determined from the information returned by
|
<para>The architecture is determined from the information returned by
|
||||||
<citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
|
<citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
|
||||||
and is thus subject to
|
and is thus subject to
|
||||||
|
|
88
src/analyze/analyze-architectures.c
Normal file
88
src/analyze/analyze-architectures.c
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include "analyze.h"
|
||||||
|
#include "analyze-architectures.h"
|
||||||
|
#include "format-table.h"
|
||||||
|
|
||||||
|
static int add_arch(Table *t, Architecture a) {
|
||||||
|
const char *c, *color;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(t);
|
||||||
|
|
||||||
|
if (a == native_architecture()) {
|
||||||
|
c = "native";
|
||||||
|
color = ANSI_HIGHLIGHT_GREEN;
|
||||||
|
} else if (a == uname_architecture()) {
|
||||||
|
c = "uname";
|
||||||
|
color = ANSI_HIGHLIGHT;
|
||||||
|
#ifdef ARCHITECTURE_SECONDARY
|
||||||
|
} else if (a == ARCHITECTURE_SECONDARY) {
|
||||||
|
c = "secondary";
|
||||||
|
color = NULL;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
c = "foreign";
|
||||||
|
color = ANSI_GREY;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = table_add_many(t,
|
||||||
|
TABLE_INT, (int) a,
|
||||||
|
TABLE_STRING, architecture_to_string(a),
|
||||||
|
TABLE_STRING, c,
|
||||||
|
TABLE_SET_COLOR, color);
|
||||||
|
if (r < 0)
|
||||||
|
return table_log_add_error(r);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int verb_architectures(int argc, char *argv[], void *userdata) {
|
||||||
|
_cleanup_(table_unrefp) Table *table = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
table = table_new("id", "name", "support");
|
||||||
|
if (!table)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
(void) table_hide_column_from_display(table, (size_t) 0);
|
||||||
|
|
||||||
|
if (strv_isempty(strv_skip(argv, 1)))
|
||||||
|
for (Architecture a = 0; a < _ARCHITECTURE_MAX; a++) {
|
||||||
|
r = add_arch(table, a);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
STRV_FOREACH(as, strv_skip(argv, 1)) {
|
||||||
|
Architecture a;
|
||||||
|
|
||||||
|
if (streq(*as, "native"))
|
||||||
|
a = native_architecture();
|
||||||
|
else if (streq(*as, "uname"))
|
||||||
|
a = uname_architecture();
|
||||||
|
else if (streq(*as, "secondary")) {
|
||||||
|
#ifdef ARCHITECTURE_SECONDARY
|
||||||
|
a = ARCHITECTURE_SECONDARY;
|
||||||
|
#else
|
||||||
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No secondary architecture.");
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
a = architecture_from_string(*as);
|
||||||
|
if (a < 0)
|
||||||
|
return log_error_errno(a, "Architecture \"%s\" not known.", *as);
|
||||||
|
|
||||||
|
r = add_arch(table, a);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) table_set_sort(table, (size_t) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to output table: %m");
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
4
src/analyze/analyze-architectures.h
Normal file
4
src/analyze/analyze-architectures.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int verb_architectures(int argc, char *argv[], void *userdata);
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "analyze.h"
|
#include "analyze.h"
|
||||||
|
#include "analyze-architectures.h"
|
||||||
#include "analyze-blame.h"
|
#include "analyze-blame.h"
|
||||||
#include "analyze-calendar.h"
|
#include "analyze-calendar.h"
|
||||||
#include "analyze-capability.h"
|
#include "analyze-capability.h"
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
#include "analyze-exit-status.h"
|
#include "analyze-exit-status.h"
|
||||||
#include "analyze-fdstore.h"
|
#include "analyze-fdstore.h"
|
||||||
#include "analyze-filesystems.h"
|
#include "analyze-filesystems.h"
|
||||||
|
#include "analyze-image-policy.h"
|
||||||
#include "analyze-inspect-elf.h"
|
#include "analyze-inspect-elf.h"
|
||||||
#include "analyze-log-control.h"
|
#include "analyze-log-control.h"
|
||||||
#include "analyze-malloc.h"
|
#include "analyze-malloc.h"
|
||||||
|
@ -41,7 +43,6 @@
|
||||||
#include "analyze-unit-files.h"
|
#include "analyze-unit-files.h"
|
||||||
#include "analyze-unit-paths.h"
|
#include "analyze-unit-paths.h"
|
||||||
#include "analyze-verify.h"
|
#include "analyze-verify.h"
|
||||||
#include "analyze-image-policy.h"
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-locator.h"
|
#include "bus-locator.h"
|
||||||
|
@ -224,6 +225,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||||
" capability [CAP...] List capability definitions\n"
|
" capability [CAP...] List capability definitions\n"
|
||||||
" syscall-filter [NAME...] List syscalls in seccomp filters\n"
|
" syscall-filter [NAME...] List syscalls in seccomp filters\n"
|
||||||
" filesystems [NAME...] List known filesystems\n"
|
" filesystems [NAME...] List known filesystems\n"
|
||||||
|
" architectures [NAME...] List known architectures\n"
|
||||||
" condition CONDITION... Evaluate conditions and asserts\n"
|
" condition CONDITION... Evaluate conditions and asserts\n"
|
||||||
" compare-versions VERSION1 [OP] VERSION2\n"
|
" compare-versions VERSION1 [OP] VERSION2\n"
|
||||||
" Compare two version strings\n"
|
" Compare two version strings\n"
|
||||||
|
@ -556,9 +558,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
"Option --offline= is only supported for security right now.");
|
"Option --offline= is only supported for security right now.");
|
||||||
|
|
||||||
if (arg_json_format_flags != JSON_FORMAT_OFF && !STRPTR_IN_SET(argv[optind], "security", "inspect-elf", "plot", "fdstore", "pcrs"))
|
if (arg_json_format_flags != JSON_FORMAT_OFF && !STRPTR_IN_SET(argv[optind], "security", "inspect-elf", "plot", "fdstore", "pcrs", "architectures"))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
"Option --json= is only supported for security, inspect-elf, plot, fdstore, pcrs right now.");
|
"Option --json= is only supported for security, inspect-elf, plot, fdstore, pcrs, architectures right now.");
|
||||||
|
|
||||||
if (arg_threshold != 100 && !streq_ptr(argv[optind], "security"))
|
if (arg_threshold != 100 && !streq_ptr(argv[optind], "security"))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
|
@ -649,6 +651,7 @@ static int run(int argc, char *argv[]) {
|
||||||
{ "image-policy", 2, 2, 0, verb_image_policy },
|
{ "image-policy", 2, 2, 0, verb_image_policy },
|
||||||
{ "pcrs", VERB_ANY, VERB_ANY, 0, verb_pcrs },
|
{ "pcrs", VERB_ANY, VERB_ANY, 0, verb_pcrs },
|
||||||
{ "srk", VERB_ANY, 1, 0, verb_srk },
|
{ "srk", VERB_ANY, 1, 0, verb_srk },
|
||||||
|
{ "architectures", VERB_ANY, VERB_ANY, 0, verb_architectures },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
systemd_analyze_sources = files(
|
systemd_analyze_sources = files(
|
||||||
|
'analyze-architectures.c',
|
||||||
'analyze-blame.c',
|
'analyze-blame.c',
|
||||||
'analyze-calendar.c',
|
'analyze-calendar.c',
|
||||||
'analyze-capability.c',
|
'analyze-capability.c',
|
||||||
|
|
|
@ -866,6 +866,13 @@ systemd-analyze pcrs
|
||||||
systemd-analyze pcrs --json=pretty
|
systemd-analyze pcrs --json=pretty
|
||||||
systemd-analyze pcrs 14 7 0 ima
|
systemd-analyze pcrs 14 7 0 ima
|
||||||
|
|
||||||
|
systemd-analyze architectures
|
||||||
|
systemd-analyze architectures --json=pretty
|
||||||
|
systemd-analyze architectures x86
|
||||||
|
systemd-analyze architectures x86-64
|
||||||
|
systemd-analyze architectures native
|
||||||
|
systemd-analyze architectures uname
|
||||||
|
|
||||||
systemd-analyze log-level info
|
systemd-analyze log-level info
|
||||||
|
|
||||||
touch /testok
|
touch /testok
|
||||||
|
|
Loading…
Reference in a new issue