Skip to content

Commit

Permalink
sd-journal: do not archive journal file that contains no entry
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwata committed Feb 14, 2024
1 parent 788f238 commit 49b643e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libsystemd/sd-journal/journal-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4344,6 +4344,11 @@ int journal_file_archive(JournalFile *f, char **ret_previous_path) {
if (!endswith(f->path, ".journal"))
return -EINVAL;

if (le64toh(f->header->head_entry_seqnum) == 0)
/* We may asynchronously copy file later e.g. on btrfs. During copying, if
* journal_directory_vacuum() is called, a broken archive file may be created. */
return -ENODATA;

if (asprintf(&p, "%.*s@" SD_ID128_FORMAT_STR "-%016"PRIx64"-%016"PRIx64".journal",
(int) strlen(f->path) - 8, f->path,
SD_ID128_FORMAT_VAL(f->header->seqnum_id),
Expand Down

0 comments on commit 49b643e

Please sign in to comment.