summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-01-02 20:28:08 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-02-11 18:42:36 +0100
commitf7f062bf9f194dc14a4ffc6e7fff9d8bfdea2147 (patch)
tree32fce8736d50d97566cb71cc5828488629069944 /src/shared
parentsd-journal: introduce SD_JOURNAL_ASSUME_IMMUTABLE flag (diff)
downloadsystemd-f7f062bf9f194dc14a4ffc6e7fff9d8bfdea2147.tar.xz
systemd-f7f062bf9f194dc14a4ffc6e7fff9d8bfdea2147.zip
tree-wide: set SD_JOURNAL_ASSUME_IMMUTABLE where appropriate
Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/journal-util.c4
-rw-r--r--src/shared/journal-util.h2
-rw-r--r--src/shared/logs-show.c5
3 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/journal-util.c b/src/shared/journal-util.c
index d73d7c47d0..ab70f4da0d 100644
--- a/src/shared/journal-util.c
+++ b/src/shared/journal-util.c
@@ -145,7 +145,7 @@ int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_use
return r;
}
-int journal_open_machine(sd_journal **ret, const char *machine) {
+int journal_open_machine(sd_journal **ret, const char *machine, int flags) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
@@ -178,7 +178,7 @@ int journal_open_machine(sd_journal **ret, const char *machine) {
if (machine_fd < 0)
return log_error_errno(errno, "Failed to duplicate file descriptor: %m");
- r = sd_journal_open_directory_fd(&j, machine_fd, SD_JOURNAL_OS_ROOT | SD_JOURNAL_TAKE_DIRECTORY_FD);
+ r = sd_journal_open_directory_fd(&j, machine_fd, SD_JOURNAL_OS_ROOT | SD_JOURNAL_TAKE_DIRECTORY_FD | flags);
if (r < 0)
return log_error_errno(r, "Failed to open journal in machine '%s': %m", machine);
diff --git a/src/shared/journal-util.h b/src/shared/journal-util.h
index afad249c90..5bd8e340b2 100644
--- a/src/shared/journal-util.h
+++ b/src/shared/journal-util.h
@@ -8,4 +8,4 @@
int journal_access_blocked(sd_journal *j);
int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users);
-int journal_open_machine(sd_journal **ret, const char *machine);
+int journal_open_machine(sd_journal **ret, const char *machine, int flags);
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 1f0279cde3..18780ad30a 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -1801,7 +1801,10 @@ int show_journal_by_unit(
if (how_many <= 0)
return 0;
- r = sd_journal_open_namespace(&j, log_namespace, journal_open_flags | SD_JOURNAL_INCLUDE_DEFAULT_NAMESPACE);
+ r = sd_journal_open_namespace(&j, log_namespace,
+ journal_open_flags |
+ SD_JOURNAL_INCLUDE_DEFAULT_NAMESPACE |
+ SD_JOURNAL_ASSUME_IMMUTABLE);
if (r < 0)
return log_error_errno(r, "Failed to open journal: %m");