From: Lennart Poettering Date: Mon, 21 Feb 2022 12:47:38 +0000 (+0100) Subject: analyze: split out "unit-paths" verb X-Git-Tag: v251-rc1~249^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36258fbe74977642258667b1b611c8b95265cf1f;p=thirdparty%2Fsystemd.git analyze: split out "unit-paths" verb --- diff --git a/src/analyze/analyze-unit-paths.c b/src/analyze/analyze-unit-paths.c new file mode 100644 index 00000000000..f18a10ef34d --- /dev/null +++ b/src/analyze/analyze-unit-paths.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "analyze.h" +#include "analyze-unit-paths.h" +#include "path-lookup.h" +#include "strv.h" + +int dump_unit_paths(int argc, char *argv[], void *userdata) { + _cleanup_(lookup_paths_free) LookupPaths paths = {}; + int r; + char **p; + + r = lookup_paths_init(&paths, arg_scope, 0, NULL); + if (r < 0) + return log_error_errno(r, "lookup_paths_init() failed: %m"); + + STRV_FOREACH(p, paths.search_path) + puts(*p); + + return 0; +} diff --git a/src/analyze/analyze-unit-paths.h b/src/analyze/analyze-unit-paths.h new file mode 100644 index 00000000000..c3c5156e48a --- /dev/null +++ b/src/analyze/analyze-unit-paths.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +int dump_unit_paths(int argc, char *argv[], void *userdata); diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index b1eb51ce7d3..3f48b06037b 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -31,6 +31,7 @@ #include "analyze-time-data.h" #include "analyze-timespan.h" #include "analyze-timestamp.h" +#include "analyze-unit-paths.h" #include "analyze-verify.h" #include "bus-error.h" #include "bus-locator.h" @@ -482,21 +483,6 @@ static int do_unit_files(int argc, char *argv[], void *userdata) { return 0; } -static int dump_unit_paths(int argc, char *argv[], void *userdata) { - _cleanup_(lookup_paths_free) LookupPaths paths = {}; - int r; - char **p; - - r = lookup_paths_init(&paths, arg_scope, 0, NULL); - if (r < 0) - return log_error_errno(r, "lookup_paths_init() failed: %m"); - - STRV_FOREACH(p, paths.search_path) - puts(*p); - - return 0; -} - void time_parsing_hint(const char *p, bool calendar, bool timestamp, bool timespan) { if (calendar && calendar_spec_from_string(p, NULL) >= 0) log_notice("Hint: this expression is a valid calendar specification. " diff --git a/src/analyze/meson.build b/src/analyze/meson.build index 022b0749b7c..a2bbf5cbfdb 100644 --- a/src/analyze/meson.build +++ b/src/analyze/meson.build @@ -37,6 +37,8 @@ systemd_analyze_sources = files(''' analyze-timespan.h analyze-timestamp.c analyze-timestamp.h + analyze-unit-paths.c + analyze-unit-paths.h analyze-verify.c analyze-verify.h analyze.c