]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/analyze/analyze-cat-config.c
sd-boot+bootctl: invert order of entries w/o sort-key
[thirdparty/systemd.git] / src / analyze / analyze-cat-config.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "analyze.h"
4 #include "analyze-cat-config.h"
5 #include "conf-files.h"
6 #include "def.h"
7 #include "nulstr-util.h"
8 #include "path-util.h"
9 #include "pretty-print.h"
10 #include "strv.h"
11
12 int verb_cat_config(int argc, char *argv[], void *userdata) {
13 char **arg, **list;
14 int r;
15
16 pager_open(arg_pager_flags);
17
18 list = strv_skip(argv, 1);
19 STRV_FOREACH(arg, list) {
20 const char *t = NULL;
21
22 if (arg != list)
23 print_separator();
24
25 if (path_is_absolute(*arg)) {
26 const char *dir;
27
28 NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
29 t = path_startswith(*arg, dir);
30 if (t)
31 break;
32 }
33
34 if (!t)
35 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
36 "Path %s does not start with any known prefix.", *arg);
37 } else
38 t = *arg;
39
40 r = conf_files_cat(arg_root, t);
41 if (r < 0)
42 return r;
43 }
44
45 return 0;
46 }