summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/systemd-analyze.xml32
-rw-r--r--man/systemd.unit.xml4
-rw-r--r--src/analyze/analyze-architectures.c88
-rw-r--r--src/analyze/analyze-architectures.h4
-rw-r--r--src/analyze/analyze-capability.c6
-rw-r--r--src/analyze/analyze-exit-status.c6
-rw-r--r--src/analyze/analyze.c9
-rw-r--r--src/analyze/meson.build1
-rwxr-xr-xtest/units/testsuite-65.sh7
9 files changed, 146 insertions, 11 deletions
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 2f2873452a..ad6ba5c090 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -179,6 +179,12 @@
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain">srk</arg> &gt;<arg choice="plain"><replaceable>FILE</replaceable></arg>
</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>
<refsect1>
@@ -941,6 +947,32 @@ NR NAME SHA256
<programlisting>systemd-analyze srk &gt; srk.tpm2b_public</programlisting>
</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>
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 190d4c1d2f..7fed74a227 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1321,6 +1321,10 @@
<literal>arc-be</literal>, or
<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
<citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
and is thus subject to
diff --git a/src/analyze/analyze-architectures.c b/src/analyze/analyze-architectures.c
new file mode 100644
index 0000000000..2d155d57c1
--- /dev/null
+++ b/src/analyze/analyze-architectures.c
@@ -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;
+}
diff --git a/src/analyze/analyze-architectures.h b/src/analyze/analyze-architectures.h
new file mode 100644
index 0000000000..06b9473784
--- /dev/null
+++ b/src/analyze/analyze-architectures.h
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+int verb_architectures(int argc, char *argv[], void *userdata);
diff --git a/src/analyze/analyze-capability.c b/src/analyze/analyze-capability.c
index 8072175a84..7cdc0e3d92 100644
--- a/src/analyze/analyze-capability.c
+++ b/src/analyze/analyze-capability.c
@@ -46,11 +46,9 @@ int verb_capabilities(int argc, char *argv[], void *userdata) {
(void) table_set_sort(table, (size_t) 1);
}
- pager_open(arg_pager_flags);
-
- r = table_print(table, NULL);
+ r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0)
- return r;
+ return log_error_errno(r, "Failed to output table: %m");
return EXIT_SUCCESS;
}
diff --git a/src/analyze/analyze-exit-status.c b/src/analyze/analyze-exit-status.c
index 3a8d3f4b2a..1032f1a4b7 100644
--- a/src/analyze/analyze-exit-status.c
+++ b/src/analyze/analyze-exit-status.c
@@ -46,11 +46,9 @@ int verb_exit_status(int argc, char *argv[], void *userdata) {
return table_log_add_error(r);
}
- pager_open(arg_pager_flags);
-
- r = table_print(table, NULL);
+ r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0)
- return r;
+ return log_error_errno(r, "Failed to output table: %m");
return EXIT_SUCCESS;
}
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index d2be144f4f..005846fdee 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -13,6 +13,7 @@
#include "alloc-util.h"
#include "analyze.h"
+#include "analyze-architectures.h"
#include "analyze-blame.h"
#include "analyze-calendar.h"
#include "analyze-capability.h"
@@ -25,6 +26,7 @@
#include "analyze-exit-status.h"
#include "analyze-fdstore.h"
#include "analyze-filesystems.h"
+#include "analyze-image-policy.h"
#include "analyze-inspect-elf.h"
#include "analyze-log-control.h"
#include "analyze-malloc.h"
@@ -41,7 +43,6 @@
#include "analyze-unit-files.h"
#include "analyze-unit-paths.h"
#include "analyze-verify.h"
-#include "analyze-image-policy.h"
#include "build.h"
#include "bus-error.h"
#include "bus-locator.h"
@@ -224,6 +225,7 @@ static int help(int argc, char *argv[], void *userdata) {
" capability [CAP...] List capability definitions\n"
" syscall-filter [NAME...] List syscalls in seccomp filters\n"
" filesystems [NAME...] List known filesystems\n"
+ " architectures [NAME...] List known architectures\n"
" condition CONDITION... Evaluate conditions and asserts\n"
" compare-versions VERSION1 [OP] VERSION2\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),
"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", "capability", "exit-status"))
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, capability, exit-status right now.");
if (arg_threshold != 100 && !streq_ptr(argv[optind], "security"))
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 },
{ "pcrs", VERB_ANY, VERB_ANY, 0, verb_pcrs },
{ "srk", VERB_ANY, 1, 0, verb_srk },
+ { "architectures", VERB_ANY, VERB_ANY, 0, verb_architectures },
{}
};
diff --git a/src/analyze/meson.build b/src/analyze/meson.build
index a50544730b..f150ed7613 100644
--- a/src/analyze/meson.build
+++ b/src/analyze/meson.build
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
systemd_analyze_sources = files(
+ 'analyze-architectures.c',
'analyze-blame.c',
'analyze-calendar.c',
'analyze-capability.c',
diff --git a/test/units/testsuite-65.sh b/test/units/testsuite-65.sh
index ae8cd98a4e..265a07f01d 100755
--- a/test/units/testsuite-65.sh
+++ b/test/units/testsuite-65.sh
@@ -866,6 +866,13 @@ systemd-analyze pcrs
systemd-analyze pcrs --json=pretty
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
touch /testok