From 4fd670e2be7fe2896fa4123bd173198ee9412a50 Mon Sep 17 00:00:00 2001 From: Phil Krylov Date: Sat, 15 Aug 2026 18:15:48 +0200 Subject: [PATCH] Ticket #5082: (copy_file_file): fix bad fd mode error in reget. Don't clear O_WRONLY flag when reopening the destination file in O_APPEND mode. Remove misleading duplicate O_WRONLY setting. Signed-off-by: Phil Krylov --- src/filemanager/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 398bfa85f..2037da539 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -2621,7 +2621,7 @@ copy_file_file (file_op_context_t *ctx, const char *src_path, const char *dst_pa // FICLONERANGE on Linux and copy_file_range(2) on FreeBSD support block-aligned ranges for // cloning, but for not in O_APPEND mode. Use O_WRONLY + mc_lseek instead as we don't care // about atomicity in our use cases. - open_flags |= mc_global.vfs.file_cloning ? O_WRONLY : O_APPEND; + open_flags |= mc_global.vfs.file_cloning ? 0 : O_APPEND; #else open_flags |= O_APPEND; #endif @@ -2674,7 +2674,7 @@ copy_file_file (file_op_context_t *ctx, const char *src_path, const char *dst_pa ctx->do_append = TRUE; mc_close (dest_desc); dst_status = DEST_NONE; - open_flags = (open_flags & ~O_WRONLY) | O_APPEND; + open_flags |= O_APPEND; goto open_dest; } }