Skip to content

feat: add macOS clonefile and copyfile platform copy stubs - #2974

Merged
oferchen merged 1 commit into
masterfrom
feat/platform-copy-macos
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/platform-copy-macos

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add platform_copy module to the fast_io crate with two macOS-specific copy primitives:
    • try_clonefile(src, dst) - uses clonefile(2) for APFS copy-on-write reflinks (instant, O(1) regardless of file size)
    • try_fcopyfile(src, dst) - uses fcopyfile(3) with COPYFILE_DATA for kernel-accelerated file copies (works across filesystems, on HFS+/NFS/SMB)
  • Non-macOS platforms return ErrorKind::Unsupported, enabling callers to build a fallback chain without cfg branching at every call site
  • Re-exports both functions from fast_io crate root for ergonomic access

Test plan

  • macOS tests: clonefile data copy, clonefile fails when dst exists, clonefile fails on missing source
  • macOS tests: fcopyfile data copy, fcopyfile overwrites destination, fcopyfile empty file, fcopyfile large file (1MB)
  • macOS parity test: fcopyfile vs std::fs::copy produce identical output
  • Non-macOS stub tests: both functions return ErrorKind::Unsupported
  • CI: verify Linux, Windows, macOS matrix all pass (stub paths on non-macOS, real paths on macOS)

@github-actions github-actions Bot added the enhancement New feature or request label Mar 22, 2026
Add platform_copy module to fast_io with two macOS-specific copy
primitives: try_clonefile (APFS CoW reflinks via clonefile(2)) and
try_fcopyfile (kernel-accelerated copy via fcopyfile(3)). Non-macOS
platforms return ErrorKind::Unsupported, enabling callers to build a
fallback chain without cfg branching at every call site.
@oferchen
oferchen force-pushed the feat/platform-copy-macos branch from fe2f550 to 6ef83ff Compare March 22, 2026 14:37
@oferchen
oferchen merged commit 30cc3bc into master Mar 22, 2026
4 of 9 checks passed
@oferchen
oferchen deleted the feat/platform-copy-macos branch March 22, 2026 14:37
oferchen added a commit that referenced this pull request May 1, 2026
Add platform_copy module to fast_io with two macOS-specific copy
primitives: try_clonefile (APFS CoW reflinks via clonefile(2)) and
try_fcopyfile (kernel-accelerated copy via fcopyfile(3)). Non-macOS
platforms return ErrorKind::Unsupported, enabling callers to build a
fallback chain without cfg branching at every call site.
oferchen added a commit that referenced this pull request May 5, 2026
Add platform_copy module to fast_io with two macOS-specific copy
primitives: try_clonefile (APFS CoW reflinks via clonefile(2)) and
try_fcopyfile (kernel-accelerated copy via fcopyfile(3)). Non-macOS
platforms return ErrorKind::Unsupported, enabling callers to build a
fallback chain without cfg branching at every call site.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant