]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: when copying journal file to undo NOCOW flag, go via fd
authorLennart Poettering <lennart@poettering.net>
Wed, 2 Feb 2022 14:21:27 +0000 (15:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Feb 2022 10:34:24 +0000 (11:34 +0100)
We have the journal file open already, hence reference it via the fd
insted of the file name. After all, some other tool might have
renamed/deleted it already.

Let's not actually reuse the fd though, since we want a separate file
offset for the copying, hence just make it simply and reopen via
/proc/self/fd/.

Follow-up for d71ece3f0b85c7a3decc50143b68ac07fc5831ae

src/journal/managed-journal-file.c

index 8880329fa5ed25d619df8b30c114ff53c4eeac70..5b5555315dc501bcaa849f595225bf0dc5e1e571 100644 (file)
@@ -192,7 +192,7 @@ static void managed_journal_file_set_offline_internal(ManagedJournalFile *f) {
 
                                 log_debug_errno(r, "Failed to re-enable copy-on-write for %s: %m, rewriting file", f->file->path);
 
-                                r = copy_file_atomic(f->file->path, f->file->path, f->file->mode, 0, FS_NOCOW_FL, COPY_REPLACE | COPY_FSYNC | COPY_HOLES);
+                                r = copy_file_atomic(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode, 0, FS_NOCOW_FL, COPY_REPLACE | COPY_FSYNC | COPY_HOLES);
                                 if (r < 0) {
                                         log_debug_errno(r, "Failed to rewrite %s: %m", f->file->path);
                                         continue;