#1088379 df: block count erroneously includes suffix when -B used

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
Michael Gold
Date:
2024-11-27 17:09:02 UTC
Severity:
normal
#1088379#5
Date:
2024-11-27 17:04:15 UTC
From:
To:
Dear Maintainer,

When I use the -B option to specify a block size, the block size is
erroneously included as a suffix in the block count.  For example:
	$ df /
	Filesystem               1K-blocks      Used  Available Use% Mounted on
	/dev/mapper/lucca0-root 1886389316 632645844 1247536332  34% /
	$ df -BK /
	Filesystem                1K-blocks       Used   Available Use% Mounted on
	/dev/mapper/lucca0-root 1886389316K 632645844K 1247536332K  34% /

Note that the same filesystem is reported as having 1886389316 blocks
(the correct value) and "1886389316K" blocks, despite the block size
being the same in both cases.  As "K" is defined as 1024, the second
form implies a total size of "1800T".  With -BG, the size is reported
as being more than an exabyte:
	$ df -BG /
	Filesystem              1G-blocks  Used Available Use% Mounted on
	/dev/mapper/lucca0-root     1800G  604G     1190G  34% /

The block count should not include the suffix.  Neither should "Used"
and "Available", if these are indeed in block-sized units as the manual
claims--though it's possible the manual is wrong here, as it is when
"-h" or "-H" is used:
	$ df -h /
	Filesystem               Size  Used Avail Use% Mounted on
	/dev/mapper/lucca0-root  1.8T  604G  1.2T  34% /
(The manual says "Otherwise, units default to 1024 bytes", but the units
are bytes here.  I think the actual output is clear enough.)

- Michael