diff options
author | Igor Tsiglyar <i.tsiglyar@yadro.com> | 2023-07-03 15:51:32 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-07-04 19:47:54 +0200 |
commit | 9f6e0bd417fa287dd1e7b541bfe0c60f04cc29e4 (patch) | |
tree | ce95d5c707fc15b744ac09be662edef5fa4a1a9f /src/journal-remote | |
parent | hwdb : add support for Archos 101 Cesium Educ to 60-sensor.hwdb (diff) | |
download | systemd-9f6e0bd417fa287dd1e7b541bfe0c60f04cc29e4.tar.xz systemd-9f6e0bd417fa287dd1e7b541bfe0c60f04cc29e4.zip |
journal-remote: upload journals from namespace
Diffstat (limited to 'src/journal-remote')
-rw-r--r-- | src/journal-remote/journal-upload.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 32da75e598..22f318f314 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -50,7 +50,9 @@ static char **arg_file = NULL; static const char *arg_cursor = NULL; static bool arg_after_cursor = false; static int arg_journal_type = 0; +static int arg_namespace_flags = 0; static const char *arg_machine = NULL; +static const char *arg_namespace = NULL; static bool arg_merge = false; static int arg_follow = -1; static const char *arg_save_state = NULL; @@ -557,6 +559,7 @@ static int help(void) { " --user Use the user journal for the current user\n" " -m --merge Use all available journals\n" " -M --machine=CONTAINER Operate on local container\n" + " --namespace=NAMESPACE Use journal files from namespace\n" " -D --directory=PATH Use journal files from directory\n" " --file=PATH Use this journal file\n" " --cursor=CURSOR Start at the specified cursor\n" @@ -584,6 +587,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_AFTER_CURSOR, ARG_FOLLOW, ARG_SAVE_STATE, + ARG_NAMESPACE, }; static const struct option options[] = { @@ -597,6 +601,7 @@ static int parse_argv(int argc, char *argv[]) { { "user", no_argument, NULL, ARG_USER }, { "merge", no_argument, NULL, 'm' }, { "machine", required_argument, NULL, 'M' }, + { "namespace", required_argument, NULL, ARG_NAMESPACE }, { "directory", required_argument, NULL, 'D' }, { "file", required_argument, NULL, ARG_FILE }, { "cursor", required_argument, NULL, ARG_CURSOR }, @@ -673,6 +678,23 @@ static int parse_argv(int argc, char *argv[]) { arg_machine = optarg; break; + case ARG_NAMESPACE: + if (streq(optarg, "*")) { + arg_namespace_flags = SD_JOURNAL_ALL_NAMESPACES; + arg_namespace = NULL; + } else if (startswith(optarg, "+")) { + arg_namespace_flags = SD_JOURNAL_INCLUDE_DEFAULT_NAMESPACE; + arg_namespace = optarg + 1; + } else if (isempty(optarg)) { + arg_namespace_flags = 0; + arg_namespace = NULL; + } else { + arg_namespace_flags = 0; + arg_namespace = optarg; + } + + break; + case 'D': if (arg_directory) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), @@ -757,7 +779,10 @@ static int open_journal(sd_journal **j) { /* FIXME: replace with D-Bus call OpenMachineRootDirectory() so that things also work with raw disk images */ r = sd_journal_open_container(j, arg_machine, 0); #pragma GCC diagnostic pop - } else + } else if (arg_namespace) + r = sd_journal_open_namespace(j, arg_namespace, (arg_merge ? 0 : SD_JOURNAL_LOCAL_ONLY) | + arg_namespace_flags | arg_journal_type); + else r = sd_journal_open(j, (arg_merge ? 0 : SD_JOURNAL_LOCAL_ONLY) | arg_journal_type); if (r < 0) log_error_errno(r, "Failed to open %s: %m", |