Oluwafemi Obajuluwa

Oluwafemi Obajuluwa › Reclaim

Counting honestly

Getting a number that is actually true

Counting honestly

Getting a number quickly is easy. Getting one that is actually true took most of the work.

Walking from the root naively counts everything twice, because /System/Volumes/Data is a firmlink that re-exposes the same data volume you are already inside. That one and a handful of synthetic mounts are excluded outright. Symlinks are skipped rather than followed. Other volumes are left alone unless you ask for them.

Hard links are the other way a disk lies to you. The same bytes can appear under many names, and adding them all up gives a total larger than the disk. Reclaim claims each inode the first time it sees it, and any later name for the same file counts as zero.

It also measures allocated size rather than file length. Those differ in both directions: a tiny file still occupies a whole block, and a sparse file can claim terabytes while occupying a few gigabytes.

Files under 1MB aren't kept as individual nodes. They're folded into a count and a byte total on the folder holding them, which keeps memory bounded on a six-million-file disk without changing any reported size.

Finally, some directories can't be read at all. Rather than skipping them quietly, the folders above them are marked as partial, so a total that is too low can say so instead of looking exact.

Reclaim's Browse view: the home folder split into Library, Documents, .gradle, .npm and Desktop with sizes and percentages

After the scan. Each row shows its share of the parent, the kind of file that dominates it, the number of items and when it last changed.