From 2831c51d3386d12a97a6ce5f3d795cb51e02beec Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 20 Apr 2023 18:43:43 +0200 Subject: Collect and print statistics about the kind of files we are packing Using depth-first search, we collect some crude statistics about directory tree types (e.g. regular files, directories, device special files and so on) and print them out after serializing the tree. Signed-off-by: David Oberhollenzer --- lib/common/src/writer/finish.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'lib/common/src/writer') diff --git a/lib/common/src/writer/finish.c b/lib/common/src/writer/finish.c index c539579..60b3aa5 100644 --- a/lib/common/src/writer/finish.c +++ b/lib/common/src/writer/finish.c @@ -11,7 +11,8 @@ static void print_statistics(const sqfs_super_t *super, const sqfs_block_processor_t *blk, - const sqfs_block_writer_t *wr) + const sqfs_block_writer_t *wr, + const fstree_stats_t *fs_stat) { const sqfs_block_processor_stats_t *proc_stats; sqfs_u64 bytes_written, blocks_written; @@ -38,6 +39,14 @@ static void print_statistics(const sqfs_super_t *super, printf("Data compression ratio: " PRI_SZ "%%\n", ratio); fputc('\n', stdout); + printf("Files: " PRI_SZ "\n", fs_stat->num_files); + printf("Directories: " PRI_SZ "\n", fs_stat->num_dirs); + printf("IPC files: " PRI_SZ "\n", fs_stat->num_ipc); + printf("Device files: " PRI_SZ "\n", fs_stat->num_devices); + printf("Hard links: " PRI_SZ "\n", fs_stat->num_links); + printf("Soft links: " PRI_SZ "\n", fs_stat->num_slinks); + fputc('\n', stdout); + printf("Data blocks written: " PRI_U64 "\n", blocks_written); printf("Out of which were fragment blocks: " PRI_U64 "\n", proc_stats->frag_block_count); @@ -169,8 +178,14 @@ int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg) return -1; } - if (!cfg->quiet) - print_statistics(&sqfs->super, sqfs->data, sqfs->blkwr); + if (!cfg->quiet) { + fstree_stats_t fs_stat; + + fstree_collect_stats(&sqfs->fs, &fs_stat); + + print_statistics(&sqfs->super, sqfs->data, + sqfs->blkwr, &fs_stat); + } return 0; } -- cgit v1.2.3