diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2023-03-04 16:51:11 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2023-03-04 16:57:16 -0800 |
commit | 110bcd28386b1f47a4cd876098acb708fdcbbb25 (patch) | |
tree | 8ed76d8b3e55d094e37a9ccb5d5c386d44abe3df /src/du.c | |
parent | 8022874d1242f3b094b6bd001e83845e289d2bb1 (diff) | |
download | coreutils-110bcd28386b1f47a4cd876098acb708fdcbbb25.tar.gz |
du: --apparent counts only symlinks and regular
Problem reported by Christoph Anton Mitterer (Bug#61884).
* src/du.c (process_file): When counting apparent sizes, count
only usable st_size members.
* tests/du/apparent.sh: New file.
* tests/local.mk (all_root_tests): Add it.
Diffstat (limited to 'src/du.c')
-rw-r--r-- | src/du.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -131,7 +131,7 @@ struct dulevel static bool opt_all = false; /* If true, rather than using the device usage of each file, - use the apparent size (a la stat.st_size). */ + use the apparent size (stat.st_size if usable, 0 otherwise). */ static bool apparent_size = false; /* If true, count each hard link of files with multiple links. */ @@ -494,8 +494,8 @@ process_file (FTS *fts, FTSENT *ent) size_t level; static size_t n_alloc; /* First element of the structure contains: - The sum of the st_size values of all entries in the single directory - at the corresponding level. Although this does include the st_size + The sum of the sizes of all entries in the single directory + at the corresponding level. Although this does include the sizes corresponding to each subdirectory, it does not include the size of any file in a subdirectory. Also corresponding last modified date. Second element of the structure contains: @@ -588,7 +588,7 @@ process_file (FTS *fts, FTSENT *ent) duinfo_set (&dui, (apparent_size - ? MAX (0, sb->st_size) + ? (usable_st_size (sb) ? MAX (0, sb->st_size) : 0) : (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE), (time_type == time_mtime ? get_stat_mtime (sb) : time_type == time_atime ? get_stat_atime (sb) |