summaryrefslogtreecommitdiffstats
path: root/src/shared/journal-file-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/shared/journal-file-util.c
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shared/journal-file-util.c')
-rw-r--r--src/shared/journal-file-util.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/shared/journal-file-util.c b/src/shared/journal-file-util.c
index bdceac4..8df165d 100644
--- a/src/shared/journal-file-util.c
+++ b/src/shared/journal-file-util.c
@@ -404,7 +404,7 @@ JournalFile* journal_file_offline_close(JournalFile *f) {
if (sd_event_source_get_enabled(f->post_change_timer, NULL) > 0)
journal_file_post_change(f);
- sd_event_source_disable_unref(f->post_change_timer);
+ f->post_change_timer = sd_event_source_disable_unref(f->post_change_timer);
journal_file_set_offline(f, true);
@@ -451,7 +451,7 @@ int journal_file_rotate(
set_clear_with_destructor(deferred_closes, journal_file_offline_close);
r = journal_file_open(
- /* fd= */ -1,
+ /* fd= */ -EBADF,
path,
(*f)->open_flags,
file_flags,
@@ -476,14 +476,13 @@ int journal_file_open_reliably(
uint64_t compress_threshold_bytes,
JournalMetrics *metrics,
MMapCache *mmap_cache,
- JournalFile *template,
JournalFile **ret) {
_cleanup_(journal_file_offline_closep) JournalFile *old_file = NULL;
int r;
r = journal_file_open(
- /* fd= */ -1,
+ /* fd= */ -EBADF,
fname,
open_flags,
file_flags,
@@ -491,7 +490,7 @@ int journal_file_open_reliably(
compress_threshold_bytes,
metrics,
mmap_cache,
- template,
+ /* template = */ NULL,
ret);
if (!IN_SET(r,
-EBADMSG, /* Corrupted */
@@ -517,23 +516,19 @@ int journal_file_open_reliably(
/* The file is corrupted. Rotate it away and try it again (but only once) */
log_warning_errno(r, "File %s corrupted or uncleanly shut down, renaming and replacing.", fname);
- if (!template) {
- /* The file is corrupted and no template is specified. Try opening it read-only as the
- * template before rotating to inherit its sequence number and ID. */
- r = journal_file_open(-1, fname,
- (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY,
- file_flags, 0, compress_threshold_bytes, NULL,
- mmap_cache, NULL, &old_file);
- if (r < 0)
- log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname);
- else
- template = old_file;
- }
+ /* The file is corrupted. Try opening it read-only as the template before rotating to inherit its
+ * sequence number and ID. */
+ r = journal_file_open(-EBADF, fname,
+ (open_flags & ~(O_ACCMODE|O_CREAT|O_EXCL)) | O_RDONLY,
+ file_flags, 0, compress_threshold_bytes, NULL,
+ mmap_cache, /* template = */ NULL, &old_file);
+ if (r < 0)
+ log_debug_errno(r, "Failed to continue sequence from file %s, ignoring: %m", fname);
r = journal_file_dispose(AT_FDCWD, fname);
if (r < 0)
return r;
- return journal_file_open(-1, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics,
- mmap_cache, template, ret);
+ return journal_file_open(-EBADF, fname, open_flags, file_flags, mode, compress_threshold_bytes, metrics,
+ mmap_cache, /* template = */ old_file, ret);
}