Skip to content

du: count links based on inode#10313

Merged
ChrisDryden merged 6 commits intouutils:mainfrom
svlv:du-multiple-links-in-args
Jan 19, 2026
Merged

du: count links based on inode#10313
ChrisDryden merged 6 commits intouutils:mainfrom
svlv:du-multiple-links-in-args

Conversation

@svlv
Copy link
Contributor

@svlv svlv commented Jan 18, 2026

Fixes #10312 and #10241

Count links based on metadata in order to produce the same output as GNU dd
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)

@sylvestre
Copy link
Contributor

a bunch of jobs are failing

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 18, 2026

Merging this PR will degrade performance by 3.25%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 280 untouched benchmarks
⏩ 38 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory dd_copy_partial 127.7 KB 132 KB -3.25%
Memory cp_large_file[16] 115.4 KB 107.5 KB +7.28%

Comparing svlv:du-multiple-links-in-args (c170b2a) with main (425b232)

Open in CodSpeed

Footnotes

  1. 38 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.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

1 similar comment
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)

@@ -1114,6 +1114,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Pre-populate seen_inodes with the starting directory to detect cycles
if let Ok(stat) = Stat::new(&path, None, &traversal_options) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would only have to stat this file once, and de-duplicate this call but that can be in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll de-duplicate this call in another PR

let result = ts.ucmd().args(&["dir1", "dir2"]).succeeds();
let lines: Vec<&str> = result.stdout_str().lines().collect();
let size = |i: usize| lines[i].split_once('\t').unwrap().0.parse::<u64>().unwrap();
assert!(size(0) >= 8);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because these numbers can be based on block size which can vary based on filesystem:

Could this be changed to:

assert!(size(0) > size(1))


#[test]
#[cfg(target_os = "linux")]
fn test_du_hard_links_multiple_links_in_args() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I was thinking that this test was not useful because it should have the same behavior whether its -L or not with hardlinks since they share the same inode, but it could be useful as a regression test.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@ChrisDryden ChrisDryden merged commit 8d02762 into uutils:main Jan 19, 2026
154 of 157 checks passed
@ChrisDryden
Copy link
Collaborator

Thanks!

mattsu2020 pushed a commit to mattsu2020/coreutils that referenced this pull request Jan 23, 2026
* du: count links based on metadata

Count links based on metadata in order to produce the same output as GNU dd
@svlv svlv deleted the du-multiple-links-in-args branch January 24, 2026 14:27
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.

du: different output compared to GNU when links and targets in args

3 participants