commit:     e1d855c4a371372211b080450a0ad9409625ef60
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 19 16:04:10 2025 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Aug 19 16:11:17 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e1d855c4

file_copy: borrow list of non-fatal cfr errors from coreutils

Bug: https://bugs.gentoo.org/961738
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 lib/portage/util/file_copy.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/portage/util/file_copy.py b/lib/portage/util/file_copy.py
index e3926d8ef6..078a526f19 100644
--- a/lib/portage/util/file_copy.py
+++ b/lib/portage/util/file_copy.py
@@ -19,6 +19,22 @@ FICLONE = getattr(fcntl, "FICLONE", 0x40049409)
 SEEK_DATA = getattr(os, "SEEK_DATA", 3)
 SEEK_HOLE = getattr(os, "SEEK_HOLE", 4)
 
+# Taken from coreutils
+_CFR_IGNORE = frozenset(
+    (
+        errno.ENOSYS,
+        errno.ENOTTY,
+        errno.EOPNOTSUPP,
+        errno.ENOTSUP,
+        errno.EINVAL,
+        errno.EBADF,
+        errno.EXDEV,
+        errno.ETXTBSY,
+        errno.EPERM,
+        errno.EACCES,
+    )
+)
+
 
 def _get_chunks(src):
     try:
@@ -102,7 +118,7 @@ def _fastcopy(src, dst):
                         continue
                     except OSError as e:
                         try_cfr = False
-                        if e.errno not in (errno.EXDEV, errno.ENOSYS, 
errno.EOPNOTSUPP):
+                        if e.errno not in _CFR_IGNORE:
                             logger.warning(
                                 "_do_copy_file_range failed unexpectedly",
                                 exc_info=sys.exc_info(),

Reply via email to