]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
copy: do not refuse to copy a swap file
authorZorro Lang <zlang@redhat.com>
Mon, 26 Apr 2021 15:25:18 +0000 (17:25 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Apr 2021 01:00:58 +0000 (18:00 -0700)
* src/copy.c (sparse_copy): Fallback to read() if copy_file_range()
fails with ETXTBSY.  Otherwise it would be impossible to copy files
that are being used as swap.  This used to work before introducing
the support for copy_file_range() in coreutils.  (Bug#48036)

src/copy.c

index 9dbc694ebee0b977253e1ecfbee46a9fce8d1065..b7ec9747fa8b1336db503b7680fcf3973e288cce 100644 (file)
@@ -290,7 +290,7 @@ sparse_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
         if (n_copied < 0)
           {
             if (errno == ENOSYS || errno == EINVAL
-                || errno == EBADF || errno == EXDEV)
+                || errno == EBADF || errno == EXDEV || errno == ETXTBSY)
               break;
             if (errno == EINTR)
               n_copied = 0;