Skip to content

fix(truncate): implement --io-blocks#13432

Draft
ThomasHabets wants to merge 3 commits into
uutils:mainfrom
ThomasHabets:truncate-blocks
Draft

fix(truncate): implement --io-blocks#13432
ThomasHabets wants to merge 3 commits into
uutils:mainfrom
ThomasHabets:truncate-blocks

Conversation

@ThomasHabets

Copy link
Copy Markdown
Contributor

Scale SIZE by the preferred I/O block size of each output file, using the parent filesystem for files that do not exist yet.

Before

truncate --io-blocks --size=1 file produced a 1-byte file.

After

The same command produces a 4096-byte file on a filesystem with 4096-byte I/O blocks.

There is an unrelated bug in that translate macros seem to do some rounding, probably by needlessly converting to a float somewhere. Example:

$ cargo run --  truncate --io-blocks -s 18446744073709551615 a
truncate: overflow in 18446744073709552000 * 4096 byte blocks

I'm looking into that separately. I guess this PR could choose to print the string version of the number, but that seems like a less elegant solution?

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

Scale SIZE by the preferred I/O block size of each output file, using
the parent filesystem for files that do not exist yet.

# Before

`truncate --io-blocks --size=1` file produced a 1-byte file.

# After

The same command produces a 4096-byte file on a filesystem with
4096-byte I/O blocks.
@ThomasHabets
ThomasHabets marked this pull request as draft July 19, 2026 12:03
@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 339 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing ThomasHabets:truncate-blocks (d6e060f) with main (ef50d8b)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants