du: count links based on inode#10313
Conversation
Count links based on metadata in order to produce the same output as GNU dd
|
GNU testsuite comparison: |
|
a bunch of jobs are failing |
Merging this PR will degrade performance by 3.25%
Performance Changes
Comparing Footnotes
|
|
GNU testsuite comparison: |
1 similar comment
|
GNU testsuite comparison: |
| @@ -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) { | |||
There was a problem hiding this comment.
Ideally we would only have to stat this file once, and de-duplicate this call but that can be in another PR
There was a problem hiding this comment.
I'll de-duplicate this call in another PR
tests/by-util/test_du.rs
Outdated
| 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); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
|
GNU testsuite comparison: |
|
Thanks! |
* du: count links based on metadata Count links based on metadata in order to produce the same output as GNU dd
Fixes #10312 and #10241