summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-27 21:34:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-28 16:33:58 +0200
commit91566adbb2e245937978673410750d9960cb86b8 (patch)
tree4f7a177425c135e9ce1239f5a57d532eac1e7b2b /lib
parent7d0772e2a11ee3d62bad7c6a225dc2882670df16 (diff)
Fix duplicate file accounting
A file is a complete duplicate if: - It has no blocks, only a single fragment and that is a duplicate - It has blocks but no fragment and the blocks are duplicate - It has blocks and a fragment and both are duplicate The previous version only counted the last one. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/statistics.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/sqfs/statistics.c b/lib/sqfs/statistics.c
index 2bd4acf..4452ad5 100644
--- a/lib/sqfs/statistics.c
+++ b/lib/sqfs/statistics.c
@@ -13,9 +13,11 @@ void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super)
uint64_t output_bytes = 0;
uint64_t input_bytes = 0;
file_info_t *fi;
+ bool is_dupe;
for (fi = fs->files; fi != NULL; fi = fi->next) {
num_blocks = fi->size / fs->block_size;
+ is_dupe = true;
if ((fi->size % fs->block_size) &&
!(fi->flags & FILE_FLAG_HAS_FRAGMENT)) {
@@ -27,15 +29,13 @@ void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super)
sparse += 1;
}
- if (fi->flags & FILE_FLAG_BLOCKS_ARE_DUPLICATE) {
- duplicate_blocks += num_blocks - sparse;
- } else {
- blocks_written += num_blocks - sparse;
- }
-
- if ((fi->flags & FILE_FLAG_FRAGMENT_IS_DUPLICATE) &&
- (fi->flags & FILE_FLAG_BLOCKS_ARE_DUPLICATE)) {
- file_dup_count += 1;
+ if (num_blocks > sparse) {
+ if (fi->flags & FILE_FLAG_BLOCKS_ARE_DUPLICATE) {
+ duplicate_blocks += num_blocks - sparse;
+ } else {
+ blocks_written += num_blocks - sparse;
+ is_dupe = false;
+ }
}
if (fi->flags & FILE_FLAG_HAS_FRAGMENT) {
@@ -43,9 +43,13 @@ void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super)
frag_dup += 1;
} else {
frag_count += 1;
+ is_dupe = false;
}
}
+ if (is_dupe)
+ file_dup_count += 1;
+
sparse_blocks += sparse;
file_count += 1;
input_bytes += fi->size;