summaryrefslogtreecommitdiffstats
path: root/src/journal/journalctl-catalog.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /src/journal/journalctl-catalog.c
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/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.c51
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;
+}