MCPcopy Create free account
hub / github.com/RustPython/RustPython / _copy_file_range

Function _copy_file_range

Lib/pathlib/_os.py:67–82  ·  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

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

Callers 1

copyfileobjFunction · 0.85

Calls 1

_get_copy_blocksizeFunction · 0.85

Tested by

no test coverage detected