Skip to content

Commit 2dece90

Browse files
authored
gh-93180: Update os.copy_file_range() documentation (#93182)
1 parent 2c3fe5e commit 2dece90

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Doc/library/os.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,18 +798,32 @@ as internal buffering of data.
798798
Copy *count* bytes from file descriptor *src*, starting from offset
799799
*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.
800800
If *offset_src* is None, then *src* is read from the current position;
801-
respectively for *offset_dst*. The files pointed by *src* and *dst*
801+
respectively for *offset_dst*.
802+
803+
In Linux kernel older than 5.3, the files pointed by *src* and *dst*
802804
must reside in the same filesystem, otherwise an :exc:`OSError` is
803805
raised with :attr:`~OSError.errno` set to :data:`errno.EXDEV`.
804806

805807
This copy is done without the additional cost of transferring data
806808
from the kernel to user space and then back into the kernel. Additionally,
807-
some filesystems could implement extra optimizations. The copy is done as if
808-
both files are opened as binary.
809+
some filesystems could implement extra optimizations, such as the use of
810+
reflinks (i.e., two or more inodes that share pointers to the same
811+
copy-on-write disk blocks; supported file systems include btrfs and XFS)
812+
and server-side copy (in the case of NFS).
813+
814+
The function copies bytes between two file descriptors. Text options, like
815+
the encoding and the line ending, are ignored.
809816

810817
The return value is the amount of bytes copied. This could be less than the
811818
amount requested.
812819

820+
.. note::
821+
822+
On Linux, :func:`os.copy_file_range` should not be used for copying a
823+
range of a pseudo file from a special filesystem like procfs and sysfs.
824+
It will always copy no bytes and return 0 as if the file was empty
825+
because of a known Linux kernel issue.
826+
813827
.. availability:: Linux kernel >= 4.5 or glibc >= 2.27.
814828

815829
.. versionadded:: 3.8

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy