APFS how to test if a file is a clone

Is there an API to tell if a file is an APFS clone of another file in the same volume?


With hard links, there were APIs (e.g. getattrlist or statfs) to tell how many links there are pointing to the same file (inode). Obviouslty, clones are using different inodes, unlike hard links. So how to tell how many clones there are for a file?

Replies

I have same doubt: How to check it on Terminal?


I asked on stackoverflow too: https://stackoverflow.com/questions/46417747/apple-file-system-apfs-check-if-file-is-a-clone-on-terminal-shell

After 3 years and 2 months...
So yesterday I decided to revisit this topic :).

Using fcntl and F_LOG2PHYS is possible to check if files are using same physical blocks or not.

So I made an utility using this idea and put it on github ( https://github.com/dyorgio/apfs-clone-checker ).

It is only the first release guys, but I hope that the community can improve it.