惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
爱范儿
爱范儿
月光博客
月光博客
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
T
Tailwind CSS Blog
美团技术团队
D
Docker
V
Visual Studio Blog
Martin Fowler
Martin Fowler
博客园 - 聂微东
The Cloudflare Blog

Michael Tsai

Michael Tsai - Blog - macOS 26.5.1 Michael Tsai - Blog - Taphouse 1.5 Michael Tsai - Blog - StopTheMadness Pro 26 Michael Tsai - Blog - Mac External Display Support Reference Michael Tsai - Blog - Bartender Pro Michael Tsai - Blog - ARC Overhead in Swift Sorting Michael Tsai - Blog - Iris 1.0 Michael Tsai - Blog - Halide Mark III Michael Tsai - Blog - !Camera Michael Tsai - Blog - Project Indigo Michael Tsai - Blog - Unpro Camera Michael Tsai - Blog - Iris Rejected From the App Store Michael Tsai - Blog - OpenAI Model’s Proof of Erdős Unit Distance Problem Michael Tsai - Blog - Apps for YouTube℠™®•! Michael Tsai - Blog - Google’s Intelligent Search Box Michael Tsai - Blog - Apple Asks Supreme Court to Review Epic Ruling Michael Tsai - Blog - Stats Visualization in Apple Sports Michael Tsai - Blog - Cleve Moler, RIP Michael Tsai - Blog - Steve Jobs in Exile Michael Tsai - Blog - Leaving CloudKit Michael Tsai - Blog - Lawsuits Claim OpenAI and Perplexity Shared User Data for Advertising Michael Tsai - Blog - Inkwell Rejected From the App Store Michael Tsai - Blog - Hijacking Apps Using Archive Utility Michael Tsai - Blog - Core Data Lab 3.0 Michael Tsai - Blog - Updating Shared Shortcuts Michael Tsai - Blog - Apple vs. Indian Antitrust Regulator Michael Tsai - Blog - Apple’s 2026 Accessibility Feature Preview Michael Tsai - Blog - How Fake Contacts Can Fix Dictation’s Proper Noun Problems Michael Tsai - Blog - Fantastical at 15 Michael Tsai - Blog - Fortnite Returns to the App Store Except in Australia
Michael Tsai - Blog - APFS Folder Clones
Michael J. Tsai · 2026-05-15 · via Michael Tsai

Anders Borum:

After my experiments with APFS cloning, I made a Quick Action shortcut for Finder that’s much faster than Duplicate or “cp -c -R”, both of which clone files individually instead of the whole tree in one go.

The regular file copying APIs also give you folders full of file clones rather than a directory clone. His shortcut runs a Python script:

The clone is made with the macOS clonefile(2) syscall, invoked directly through ctypes. clonefile asks APFS to create a new inode that shares the source’s data extents — no bytes are copied up front, the new tree just points at the same disk blocks. The two trees diverge lazily: only blocks that are later modified in one side get their own physical storage (copy-on-write).

However, it’s not clear to me what the benefit is. Aside from somehow being faster, it sounds like you end up with the same structure. The clonefile(2) man page says:

If src names a directory, the directory hierarchy is cloned as if each item was cloned individually. However, the use of clonefile(2) to clone directory hierarchies is strongly discouraged. Use copyfile(3) instead for copying directories.

I don’t think APFS really supports directory clones except at the snapshot level.

See also: Ask Different, Howard Oakely.

Previously:

Update (2026-05-15): Kevin Elliott (via Frizlab):

[You] can basically think of cloning a directory as doing two things:

  1. Pushing the copy operation into kernel, avoiding the syscall overhead of directory iteration, creation, and individual clonefile calls.

  2. Preventing all changes to the source hierarchy while the operation is in progress, making the process atomic.

That second point is what makes this potentially dangerous as, in the worst case, you could theoretically panic the kernel by stalling all activity on critical locations long enough that the kernel "gives up" and panics.

6 Comments