1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

du: Fix double counting of hard links.

hard linked files are no longer counted - this mimcs the behaviour of
the original du.
This commit is contained in:
bootandy 2018-03-20 16:40:27 -04:00
parent e253406026
commit b6c7771087
2 changed files with 31 additions and 5 deletions

View file

@ -47,10 +47,22 @@ fn test_du_soft_link() {
assert_eq!(result.stdout, "32\tsubdir\n");
}
#[test]
fn test_du_hard_link() {
let ts = TestScenario::new("du");
let link = ts.cmd("ln").arg(SUB_FILE).arg(SUB_LINK).run();
assert!(link.success);
let result = ts.ucmd().arg(SUB_DIR).run();
assert!(result.success);
assert_eq!(result.stderr, "");
// We do not double count hard links as the inodes are identicle
assert_eq!(result.stdout, "24\tsubdir\n");
}
// todo:
// du on file with no permissions
// du on soft link
// du on hard link
// du on multi dir with '-d'
//
/*