Skip to content

find: right-align the inode column of -ls and -fls in 9 columns - #1079

Merged
sylvestre merged 1 commit into
uutils:mainfrom
andretorresdg:ls-inode-width
Nov 30, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
andretorresdg:ls-inode-width

Conversation

@andretorresdg

Copy link
Copy Markdown
Contributor

GNU find prints the inode number of -ls and -fls right-aligned in 9 columns. We printed a space and then the number left-aligned in 4 columns, so the line was one column short for 7 digit inodes and the block count moved right for small ones:

$ find /dev/null /etc/passwd -maxdepth 0 -ls     # GNU 4.9.0
        3      0 crw-rw-rw-   1 root     root       1,   3 Nov 28 17:54 /dev/null
   614673      4 -rw-r--r--   1 root     root         2835 Nov 26 01:59 /etc/passwd
$ target/debug/find /dev/null /etc/passwd -maxdepth 0 -ls     # before
 3         0 crw-rw-rw-   1 root     root       1,   3 Nov 28 17:54 /dev/null
 614673      4 -rw-r--r--   1 root     root         2835 Nov 26 01:59 /etc/passwd

The other columns already match. The non-Unix variant of print shares the format string, so it is changed too.

How I tested

  • Added find_ls_inode_column_is_right_aligned (fails before, passes after).
  • Compared -maxdepth 0 -ls with GNU 4.9.0 for a directory, a symlink, /etc/passwd, /dev/null and /tmp: identical after the change.
  • cargo test --test test_find find_ls, cargo test --lib ls, cargo fmt --check, cargo clippy --all-targets.

GNU find pads the inode number to 9 columns, right-aligned. We printed a leading space and left-aligned it in 4, so small inodes were mis-padded and 7 digit ones were one column short.
@codspeed

codspeed Bot commented Nov 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 20 untouched benchmarks


Comparing andretorresdg:ls-inode-width (427e137) with main (05ff4a6)

Open in CodSpeed

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.44%. Comparing base (05ff4a6) to head (427e137).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1079   +/-   ##
=======================================
  Coverage   92.44%   92.44%           
=======================================
  Files          38       38           
  Lines        8896     8896           
  Branches      440      440           
=======================================
  Hits         8224     8224           
  Misses        532      532           
  Partials      140      140           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvestre
sylvestre merged commit f2551c2 into uutils:main Nov 30, 2026
35 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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