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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
D
DataBreaches.Net
U
Unit 42
P
Proofpoint News Feed
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
博客园 - Franky
博客园_首页
IT之家
IT之家
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志

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