]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cat: don’t treat copy_file_range EFBIG as fatal
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 13 Jan 2026 17:35:12 +0000 (09:35 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 13 Jan 2026 18:12:39 +0000 (10:12 -0800)
* src/cat.c (copy_cat):
* src/copy-file-data.c (sparse_copy):
Don’t treat EFBIG as a reportable error from copy_file_range.
If the input is at EOF and the output position is 2**63 - 1,
copy_file_range (ifd, NULL, ofd, NULL, 2146435072, 0)
incorrectly fails with EFBIG.  Problem observed on Ubuntu 25.10
x86-64 with Linux kernel 6.17.0-8-generic #8-Ubuntu.
I am too lazy to report this kernel bug or add a coreutils test case.

src/cat.c
src/copy-file-data.c

index e4a7c19830d49b7b049cc6bba2ef1d2e86a8b213..b3996f40bcaed47e4f1b265007f0bb183a65aed2 100644 (file)
--- a/src/cat.c
+++ b/src/cat.c
@@ -523,7 +523,7 @@ copy_cat (void)
       case -1:
         if (errno == ENOSYS || is_ENOTSUP (errno) || errno == EINVAL
             || errno == EBADF || errno == EXDEV || errno == ETXTBSY
-            || errno == EPERM)
+            || errno == EPERM || errno == EFBIG)
           return 0;
         error (0, errno, "%s", quotef (infile));
         return -1;
index 0872c1a50c950868f24974663ae91bdfe0a5c11c..a48d06b79d03b2a5807622ca6f7b9da4fd04cc6f 100644 (file)
@@ -146,6 +146,14 @@ sparse_copy (int src_fd, int dest_fd, char **abuf, idx_t buf_size,
           }
         if (n_copied < 0)
           {
+            /* Don’t treat EFBIG as a reportable error from copy_file_range.
+               If the input is at EOF and the output position is 2**63 - 1,
+               copy_file_range (ifd, NULL, ofd, NULL, 2146435072, 0)
+               incorrectly fails with EFBIG.  Problem observed on Ubuntu 25.10
+               x86-64 with Linux kernel 6.17.0-8-generic #8-Ubuntu.  */
+            if (errno == EFBIG)
+              break;
+
             debug->offload = COPY_DEBUG_UNSUPPORTED;
 
             /* Consider operation unsupported only if no data copied.