Apple is now using APFS across several product lines, including macOS. This new filesystem has some nice features for minimizing how much actual disk space is consumed, such as sparse file support and COW clones similar to BSD's clonefile().
I've created a large sparse file as a disk image, and have furthermore cloned this file to a few others. The original and its clones have all been written to since then in varying amounts.
I've found the output of mdls(1) can tell me how much of a file is sparse. For example, a 16GB file may only consume 4.4GB on disk. However, if I clone that file, mdls still shows the same data for the clone even though all the blocks are shared between the two files.
Is there a way to determine how much of a file is shared with one or more clones? The only way I've been able to determine this is to delete the file and see how many fs blocks are freed.
See https://and1equals1.blogspot.com/2019/06/playing-with-cloned-sparse-files-on-apfs.html for more details and an example..