Skip to content

Align `G_FILE_MEASURE_APPARENT_SIZE` behaviour with `du` from GNU coreutils 9.2

This aligns the behaviour of GLib's G_FILE_MEASURE_APPARENT_SIZE flag with the behaviour of GNU Coreutils 9.2 du:

Since GNU Coreutils 9.2, du --apparent-size (including du --bytes) only counts the size of regular files and symlinks, it does no longer sum the st_size of other kinds of files (directories, FIFOs, etc.) for which st_size is not even defined by POSIX.

Note that this is may be a breaking change for some uses (though I believe G_FILE_MEASURE_APPARENT_SIZE is mostly designed for displaying sizes to users, so breakage shouldn't be very substantial).

This also fixes test_measure which was failing for GNU Coreutils 9.2+ (the test no longer depends on the system's du since there are multiple behaviours in the wild anyway).

Fixes: #2965 (closed)

Edited by Joan Bruguera

Merge request reports