summaryrefslogtreecommitdiffstats
path: root/src/analyze
diff options
context:
space:
mode:
Diffstat (limited to 'src/analyze')
-rw-r--r--src/analyze/analyze-fdstore.c2
-rw-r--r--src/analyze/analyze-inspect-elf.c26
-rw-r--r--src/analyze/analyze-plot.c8
-rw-r--r--src/analyze/analyze-security.c4
-rw-r--r--src/analyze/analyze.c6
5 files changed, 20 insertions, 26 deletions
diff --git a/src/analyze/analyze-fdstore.c b/src/analyze/analyze-fdstore.c
index 4cf015ab44..e7e273e218 100644
--- a/src/analyze/analyze-fdstore.c
+++ b/src/analyze/analyze-fdstore.c
@@ -81,7 +81,7 @@ static int dump_fdstore(sd_bus *bus, const char *arg) {
if (r < 0)
return r;
- if (FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF) && table_isempty(table))
+ if (table_isempty(table) && !sd_json_format_enabled(arg_json_format_flags))
log_info("No file descriptors in fdstore of '%s'.", unit);
else {
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */true);
diff --git a/src/analyze/analyze-inspect-elf.c b/src/analyze/analyze-inspect-elf.c
index 1ae7304163..0f78729c3a 100644
--- a/src/analyze/analyze-inspect-elf.c
+++ b/src/analyze/analyze-inspect-elf.c
@@ -4,6 +4,7 @@
#include "analyze.h"
#include "analyze-inspect-elf.h"
+#include "chase.h"
#include "elf-util.h"
#include "errno-util.h"
#include "fd-util.h"
@@ -19,23 +20,13 @@ static int analyze_elf(char **filenames, sd_json_format_flags_t json_flags) {
STRV_FOREACH(filename, filenames) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *package_metadata = NULL;
_cleanup_(table_unrefp) Table *t = NULL;
- _cleanup_free_ char *abspath = NULL, *path = NULL, *stacktrace = NULL;
+ _cleanup_free_ char *abspath = NULL, *stacktrace = NULL;
_cleanup_close_ int fd = -EBADF;
bool coredump = false;
- r = path_make_absolute_cwd(*filename, &abspath);
- if (r < 0)
- return log_error_errno(r, "Could not make an absolute path out of \"%s\": %m", *filename);
-
- path = path_join(empty_to_root(arg_root), abspath);
- if (!path)
- return log_oom();
-
- path_simplify(path);
-
- fd = RET_NERRNO(open(path, O_RDONLY|O_CLOEXEC));
+ fd = chase_and_open(*filename, arg_root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, &abspath);
if (fd < 0)
- return log_error_errno(fd, "Could not open \"%s\": %m", path);
+ return log_error_errno(fd, "Could not open \"%s\": %m", *filename);
r = parse_elf_object(fd, abspath, arg_root, /* fork_disable_dump= */false, &stacktrace, &package_metadata);
if (r < 0)
@@ -65,7 +56,7 @@ static int analyze_elf(char **filenames, sd_json_format_flags_t json_flags) {
* metadata is parsed recursively in core files, so there might be
* multiple modules. */
if (STR_IN_SET(module_name, "elfType", "elfArchitecture")) {
- if (streq(module_name, "elfType") && streq("coredump", sd_json_variant_string(module_json)))
+ if (streq(module_name, "elfType") && streq(sd_json_variant_string(module_json), "coredump"))
coredump = true;
r = table_add_many(
@@ -118,12 +109,13 @@ static int analyze_elf(char **filenames, sd_json_format_flags_t json_flags) {
return table_log_add_error(r);
}
- if (json_flags & SD_JSON_FORMAT_OFF) {
+ if (sd_json_format_enabled(json_flags))
+ sd_json_variant_dump(package_metadata, json_flags, stdout, NULL);
+ else {
r = table_print(t, NULL);
if (r < 0)
return table_log_print_error(r);
- } else
- sd_json_variant_dump(package_metadata, json_flags, stdout, NULL);
+ }
}
return 0;
diff --git a/src/analyze/analyze-plot.c b/src/analyze/analyze-plot.c
index 78aeff1b62..c50343d71c 100644
--- a/src/analyze/analyze-plot.c
+++ b/src/analyze/analyze-plot.c
@@ -168,7 +168,9 @@ static void plot_tooltip(const UnitTimes *ut) {
assert(ut->name);
svg("%s:\n", ut->name);
-
+ svg("Activating: %"PRI_USEC".%.3"PRI_USEC"\n", ut->activating / USEC_PER_SEC, ut->activating % USEC_PER_SEC);
+ svg("Activated: %"PRI_USEC".%.3"PRI_USEC"\n", ut->activated / USEC_PER_SEC, ut->activated % USEC_PER_SEC);
+
UnitDependency i;
FOREACH_ARGUMENT(i, UNIT_AFTER, UNIT_BEFORE, UNIT_REQUIRES, UNIT_REQUISITE, UNIT_WANTS, UNIT_CONFLICTS, UNIT_UPHOLDS)
if (!strv_isempty(ut->deps[i])) {
@@ -417,7 +419,7 @@ static int show_table(Table *table, const char *word) {
if (!table_isempty(table)) {
table_set_header(table, arg_legend);
- if (!FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF))
+ if (sd_json_format_enabled(arg_json_format_flags))
r = table_print_json(table, NULL, arg_json_format_flags | SD_JSON_FORMAT_COLOR_AUTO);
else
r = table_print(table, NULL);
@@ -494,7 +496,7 @@ int verb_plot(int argc, char *argv[], void *userdata) {
typesafe_qsort(times, n, compare_unit_start);
- if (!FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF) || arg_table)
+ if (sd_json_format_enabled(arg_json_format_flags) || arg_table)
r = produce_plot_as_text(times, boot);
else
r = produce_plot_as_svg(times, host, boot, pretty_times);
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
index 874fff14b4..aefd4f6122 100644
--- a/src/analyze/analyze-security.c
+++ b/src/analyze/analyze-security.c
@@ -1872,7 +1872,7 @@ static int assess(const SecurityInfo *info,
return log_error_errno(r, "Failed to update cell in table: %m");
}
- if (json_format_flags & SD_JSON_FORMAT_OFF) {
+ if (!sd_json_format_enabled(json_format_flags)) {
r = table_hide_column_from_display(details_table, (size_t) 2);
if (r < 0)
return log_error_errno(r, "Failed to set columns to display: %m");
@@ -1891,7 +1891,7 @@ static int assess(const SecurityInfo *info,
assert(i < ELEMENTSOF(badness_table));
- if (details_table && (json_format_flags & SD_JSON_FORMAT_OFF)) {
+ if (details_table && !sd_json_format_enabled(json_format_flags)) {
_cleanup_free_ char *clickable = NULL;
const char *name;
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 5aba273ca6..0db3547a49 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -592,7 +592,7 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Option --offline= requires one or more units to perform a security review.");
- if (arg_json_format_flags != SD_JSON_FORMAT_OFF && !STRPTR_IN_SET(argv[optind], "security", "inspect-elf", "plot", "fdstore", "pcrs", "architectures", "capability", "exit-status"))
+ if (sd_json_format_enabled(arg_json_format_flags) && !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, architectures, capability, exit-status right now.");
@@ -631,13 +631,13 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No conditions can be passed if --unit= is used.");
if ((!arg_legend && !STRPTR_IN_SET(argv[optind], "plot", "architectures")) ||
- (streq_ptr(argv[optind], "plot") && !arg_legend && !arg_table && FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF)))
+ (streq_ptr(argv[optind], "plot") && !arg_legend && !arg_table && !sd_json_format_enabled(arg_json_format_flags)))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --no-legend is only supported for plot with either --table or --json=.");
if (arg_table && !streq_ptr(argv[optind], "plot"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --table is only supported for plot right now.");
- if (arg_table && !FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF))
+ if (arg_table && sd_json_format_enabled(arg_json_format_flags))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--table and --json= are mutually exclusive.");
if (arg_capability != CAPABILITY_LITERAL && !streq_ptr(argv[optind], "capability"))