Fall back if copy_file_range fails with EINVAL
authorOlaf Leidinger <oleid@mescharet.de>
Mon, 24 Jan 2022 15:12:57 +0000 (16:12 +0100)
committerSimon McVittie <smcv@debian.org>
Thu, 10 Mar 2022 11:59:18 +0000 (11:59 +0000)
Although EINVAL usually indicates a programming error, ecryptfs (and
possibly other stacked filesystems) returns EINVAL for attempts to
copy_file_range() or sendfile() between files on that filesystem.

Bug: https://gitlab.gnome.org/GNOME/libglnx/-/issues/3
Bug: https://github.com/ostreedev/ostree/issues/2525
Bug: https://github.com/flatpak/flatpak/issues/4673
Bug-Debian: https://bugs.debian.org/1004467
Applied-upstream: libglnx commit:24231a956a4b849087fbf01173cdebb53e1bd60b
Applied-upstream: libostree 2022.2, commit:0ebf9d9f64647d0b8b95cda112c7854be6f58ed3

Gbp-Pq: Name Fall-back-if-copy_file_range-fails-with-EINVAL.patch

libglnx/glnx-fdio.c

index 422bc2dd5cb5ce15053826517338ead7a62a1f07..0bb26f4e40df181c25eb951f0f9b1b931798c156 100644 (file)
@@ -829,7 +829,7 @@ glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes)
                   have_cfr = 0;
                   try_cfr = false;
                 }
-              else if (G_IN_SET (errno, EXDEV, EOPNOTSUPP))
+              else if (G_IN_SET (errno, EXDEV, EINVAL, EOPNOTSUPP))
                 /* We won't try cfr again for this run, but let's be
                  * conservative and not mark it as available/unavailable until
                  * we know for sure.