if (!s->system_journal)
return 0;
+ /* Offline and close the 'main' runtime journal file to allow the runtime journal to be opened with
+ * the SD_JOURNAL_ASSUME_IMMUTABLE flag in the below. */
+ s->runtime_journal = journal_file_offline_close(s->runtime_journal);
+
/* Reset current seqnum data to avoid unnecessary rotation when switching to system journal.
* See issue #30092. */
zero(*s->seqnum);
start = now(CLOCK_MONOTONIC);
- r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
+ r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY | SD_JOURNAL_ASSUME_IMMUTABLE);
if (r < 0)
return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to read runtime journal: %m");
/* First, close all runtime journals opened in the above. */
sd_journal_close(j);
- /* Offline and close the 'main' runtime journal file. */
- s->runtime_journal = journal_file_offline_close(s->runtime_journal);
-
/* Remove the runtime directory if the all entries are successfully flushed to /var/. */
if (r >= 0) {
(void) rm_rf(s->runtime_storage.path, REMOVE_ROOT);