df: the `--total` row sums per-filesystem rounded-up block counts — wrong totals in release, `attempt to multiply with overflow` with `-h` (exit 134)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
df --total accumulates the total row's block count as Σ ceil(bytesᵢ / block_size) — summing each filesystem's rounded-up block count instead of rounding the summed bytes once. With a large --block-size every non-empty filesystem rounds up to one block, so the total degenerates into roughly a count of filesystems. The -h path then multiplies that inflated count back by the block size, which overflows. Normal rows take neither path, which is why every non-total row matches GNU exactly and only the total row is wrong.
Steps to reproduce
- default release build (shipped):
the total row reports wrong numbers — with-B 10000000000000000000GNU reports a total of1block where uutils reports29(or12Ewith-h).
$ df --total -h -B 10000000000000000000 -a | tail -1
total 12E 8.9E 15E 44% - # uutils
$ /usr/bin/df --total -h -B 10000000000000000000 -a | tail -1
total 1 1 1 43% - # GNU
$ df --total -B 10000000000000000000 -a | tail -1 # without -h
total 29 25 9 44% - # uutils
$ /usr/bin/df --total -B 10000000000000000000 -a | tail -1
total 1 1 1 43% - # GNU
- overflow-checks build:
adding-hmultiplies that inflated count back by the block size and the product overflowsu64—attempt to multiply with overflowat
df/src/table.rs:312:17, exit 134.
$ df --total -h -B 10000000000000000000 -a
thread 'main' panicked at src/uu/df/src/table.rs:312:17:
attempt to multiply with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
$ echo $?
134
Root cause
1. scaled sums per-row ceilings, not the ceiling of the sum.
2. The -h branch converts blocks back to bytes with an unguarded multiply.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in df/src/table.rs, especially the block-count accumulation around lines 214-235 and the human-readable conversion around lines 307-316. Run the supplied df --total commands with the large -B value, including -h, to observe the incorrect total and overflow. Done means the total matches GNU for these cases and the -h invocation no longer aborts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100