MCPcopy Index your code
hub / github.com/python/cpython / _copy_file_range

Function _copy_file_range

Lib/pathlib/_os.py:66–81  ·  view source on GitHub ↗

Copy data from one regular mmap-like fd to another by using a high-performance copy_file_range(2) syscall that gives filesystems an opportunity to implement the use of reflinks or server-side copy. This should work on Linux >= 4.5 only.

(source_fd, target_fd)

Source from the content-addressed store, hash-verified

64
65if hasattr(os, 'copy_file_range'):
66 def _copy_file_range(source_fd, target_fd):
67 """
68 Copy data from one regular mmap-like fd to another by using a
69 high-performance copy_file_range(2) syscall that gives filesystems
70 an opportunity to implement the use of reflinks or server-side
71 copy.
72 This should work on Linux >= 4.5 only.
73 """
74 blocksize = _get_copy_blocksize(source_fd)
75 offset = 0
76 while True:
77 sent = os.copy_file_range(source_fd, target_fd, blocksize,
78 offset_dst=offset)
79 if sent == 0:
80 break # EOF
81 offset += sent
82else:
83 _copy_file_range = None
84

Callers 1

copyfileobjFunction · 0.85

Calls 1

_get_copy_blocksizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…