I would like to compute how much "true" APFS disk space is used by a folder. This folder has many APFS "cloned" versions of the same files. A "true" count of the disk space used would only count each of these clones once.
One thought I've had is to do this:
- Go through each file in the folder, recursively.
- Somehow determine, for each file, which physical location on the drive that file maps to.
- Build an array of these locations for all files; prune duplicates when they appear (which would be clones).
- Get the total computed size.
I am curious if one could use this kind of method to get the true size of the folder. I'm also curious if there are any existing utilities to do this, or if not, how I could implement this on my own. Perhaps using fcntl
and F_LOG2PHYS
, from this answer?