diff options
Diffstat (limited to 'lib/sqfshelper/statistics.c')
-rw-r--r-- | lib/sqfshelper/statistics.c | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/lib/sqfshelper/statistics.c b/lib/sqfshelper/statistics.c index 0fe325b..fda4c3f 100644 --- a/lib/sqfshelper/statistics.c +++ b/lib/sqfshelper/statistics.c @@ -9,73 +9,25 @@ #include <stdio.h> -void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super) +void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats) { - size_t blocks_written = 0, duplicate_blocks = 0, sparse_blocks = 0; - size_t ratio, file_count = 0, file_dup_count = 0; - size_t frag_count = 0, frag_dup = 0; - size_t i, num_blocks, sparse; - uint64_t output_bytes = 0; - uint64_t input_bytes = 0; - file_info_t *fi; - bool is_dupe; + uint64_t bytes_written = super->inode_table_start - sizeof(*super); + size_t ratio; - 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)) { - ++num_blocks; - } - - for (sparse = 0, i = 0; i < num_blocks; ++i) { - if (fi->block_size[i] == 0) - sparse += 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) { - if (fi->flags & FILE_FLAG_FRAGMENT_IS_DUPLICATE) { - 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; - } - - if (input_bytes > 0) { - output_bytes = super->inode_table_start - sizeof(*super); - ratio = (100 * output_bytes) / input_bytes; + if (bytes_written > 0) { + ratio = (100 * bytes_written) / stats->bytes_read; } else { ratio = 100; } fputs("---------------------------------------------------\n", stdout); - printf("Input files processed: %zu\n", file_count); - printf("Files that were complete duplicates: %zu\n", file_dup_count); - printf("Data blocks actually written: %zu\n", blocks_written); - printf("Fragment blocks written: %u\n", super->fragment_entry_count); - printf("Duplicate data blocks omitted: %zu\n", duplicate_blocks); - printf("Sparse blocks omitted: %zu\n", sparse_blocks); - printf("Fragments actually written: %zu\n", frag_count); - printf("Duplicated fragments omitted: %zu\n", frag_dup); + printf("Input files processed: %zu\n", stats->file_count); + printf("Data blocks actually written: %zu\n", stats->blocks_written); + printf("Fragment blocks written: %zu\n", stats->frag_blocks_written); + printf("Duplicate data blocks omitted: %zu\n", stats->duplicate_blocks); + printf("Sparse blocks omitted: %zu\n", stats->sparse_blocks); + printf("Fragments actually written: %zu\n", stats->frag_count); + printf("Duplicated fragments omitted: %zu\n", stats->frag_dup); printf("Total number of inodes: %u\n", super->inode_count); printf("Number of unique group/user IDs: %u\n", super->id_count); printf("Data compression ratio: %zu%%\n", ratio); |