diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
commit | efeb864cb547a2cbf96dc0053a8bdb4d9190b364 (patch) | |
tree | c0b83368f18be983fcc763200c4c24d633244588 /src/journal/journalctl-catalog.c | |
parent | Releasing progress-linux version 255.5-1~progress7.99u1. (diff) | |
download | systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.tar.xz systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/journal/journalctl-catalog.c')
-rw-r--r-- | src/journal/journalctl-catalog.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/journal/journalctl-catalog.c b/src/journal/journalctl-catalog.c new file mode 100644 index 0000000..116e152 --- /dev/null +++ b/src/journal/journalctl-catalog.c @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "catalog.h" +#include "journalctl.h" +#include "journalctl-catalog.h" +#include "path-util.h" + +int action_update_catalog(void) { + _cleanup_free_ char *database = NULL; + const char *e; + int r; + + assert(arg_action == ACTION_UPDATE_CATALOG); + + database = path_join(arg_root, secure_getenv("SYSTEMD_CATALOG") ?: CATALOG_DATABASE); + if (!database) + return log_oom(); + + e = secure_getenv("SYSTEMD_CATALOG_SOURCES"); + r = catalog_update(database, + arg_root, + e ? STRV_MAKE_CONST(e) : catalog_file_dirs); + if (r < 0) + return log_error_errno(r, "Failed to update catalog: %m"); + + return 0; +} + +int action_list_catalog(char **items) { + _cleanup_free_ char *database = NULL; + int r; + + assert(IN_SET(arg_action, ACTION_LIST_CATALOG, ACTION_DUMP_CATALOG)); + + database = path_join(arg_root, secure_getenv("SYSTEMD_CATALOG") ?: CATALOG_DATABASE); + if (!database) + return log_oom(); + + bool oneline = arg_action == ACTION_LIST_CATALOG; + + pager_open(arg_pager_flags); + + if (items) + r = catalog_list_items(stdout, database, oneline, items); + else + r = catalog_list(stdout, database, oneline); + if (r < 0) + return log_error_errno(r, "Failed to list catalog: %m"); + + return 0; +} |