bool seal,
Set *deferred_closes) {
+ _cleanup_free_ char *path = NULL;
JournaldFile *new_file = NULL;
int r;
assert(f);
assert(*f);
- r = journal_file_archive((*f)->file);
+ r = journal_file_archive((*f)->file, &path);
if (r < 0)
return r;
r = journald_file_open(
-1,
- (*f)->file->path,
+ path,
(*f)->file->flags,
(*f)->file->mode,
compress,
TAKE_FD(fd); /* Donated to journald_file_open() */
- r = journal_file_archive(f->file);
+ r = journal_file_archive(f->file, NULL);
if (r < 0)
log_debug_errno(r, "Failed to archive journal file '%s', ignoring: %m", full);
return r;
}
-int journal_file_archive(JournalFile *f) {
+int journal_file_archive(JournalFile *f, char **ret_previous_path) {
_cleanup_free_ char *p = NULL;
assert(f);
/* Sync the rename to disk */
(void) fsync_directory_of_file(f->fd);
+ if (ret_previous_path)
+ *ret_previous_path = f->path;
+ else
+ free(f->path);
+
+ f->path = TAKE_PTR(p);
+
/* Set as archive so offlining commits w/state=STATE_ARCHIVED. Previously we would set old_file->header->state
* to STATE_ARCHIVED directly here, but journal_file_set_offline() short-circuits when state != STATE_ONLINE,
* which would result in the rotated journal never getting fsync() called before closing. Now we simply queue
void journal_file_dump(JournalFile *f);
void journal_file_print_header(JournalFile *f);
-int journal_file_archive(JournalFile *f);
+int journal_file_archive(JournalFile *f, char **ret_previous_path);
int journal_file_dispose(int dir_fd, const char *fname);