Skip to content

Commit a37453f

Browse files
committed
sd-journal: do not archive journal file that contains no entry
Fixes systemd#24150 and systemd#31222.
1 parent 8f223dc commit a37453f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libsystemd/sd-journal/journal-file.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,6 +4344,11 @@ int journal_file_archive(JournalFile *f, char **ret_previous_path) {
43444344
if (!endswith(f->path, ".journal"))
43454345
return -EINVAL;
43464346

4347+
if (le64toh(f->header->head_entry_seqnum) == 0)
4348+
/* We may asynchronously copy file later e.g. on btrfs. During copying, if
4349+
* journal_directory_vacuum() is called, a broken archive file may be created. */
4350+
return -ENODATA;
4351+
43474352
if (asprintf(&p, "%.*s@" SD_ID128_FORMAT_STR "-%016"PRIx64"-%016"PRIx64".journal",
43484353
(int) strlen(f->path) - 8, f->path,
43494354
SD_ID128_FORMAT_VAL(f->header->seqnum_id),

0 commit comments

Comments
 (0)