Skip to content

Fall back from FICLONE on permission errors and ENOTTY - #60

Draft
zaniebot wants to merge 1 commit into
mainfrom
fix/pathlib-ficlone-fallback
Draft

zaniebot wants to merge 1 commit into
mainfrom
fix/pathlib-ficlone-fallback

Conversation

@zaniebot

@zaniebot zaniebot commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Path.copy() can fail on a readable file when the build exposes fcntl.FICLONE but the process cannot use it. Android’s SELinux policy denied the ioctl with EACCES, prompting CPython to hide the constant on Android (see python#122522). DVC encountered ENOTTY from the same ioctl on an ext4 filesystem (see treeverse/dvc#6980) and added a fallback (see treeverse/dvc-objects#120).

A seccomp policy can also deny the ioctl with EPERM while allowing an ordinary copy. Try the next copy method when the clone ioctl fails with EACCES, EPERM, or ENOTTY. This extends the per-operation fallback in Path.copy() (see python#122897) and matches GNU cp --reflink=auto for these errors (see https://github.com/coreutils/coreutils/blob/3a1595e2afe6e91fc534884a385e7e57d1a54c4d/src/copy.c#L675-L690). An I/O failure such as EIO still propagates.

`Path.copy()` can raise `PermissionError` when a sandbox denies the `FICLONE` ioctl, even when an ordinary copy is permitted. A file that does not support the ioctl can also return `ENOTTY`. Try the next copy method when `FICLONE` fails with `EPERM`, `EACCES`, or `ENOTTY`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant