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 --- include/fstree.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/fstree.h b/include/fstree.h index d08ccae..96ddf8f 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -21,6 +21,7 @@ typedef struct fstree_defaults_t fstree_defaults_t; typedef struct tree_node_t tree_node_t; typedef struct fstree_t fstree_t; +typedef struct fstree_stats_t fstree_stats_t; enum { FLAG_DIR_CREATED_IMPLICITLY = 0x01, @@ -80,6 +81,15 @@ struct tree_node_t { sqfs_u8 payload[]; }; +struct fstree_stats_t { + size_t num_ipc; + size_t num_links; + size_t num_slinks; + size_t num_files; + size_t num_devices; + size_t num_dirs; +}; + /* Default settings for new nodes */ struct fstree_defaults_t { sqfs_u32 uid; @@ -201,4 +211,6 @@ tree_node_t *fstree_add_hard_link(fstree_t *fs, const char *path, */ int fstree_resolve_hard_links(fstree_t *fs); +void fstree_collect_stats(const fstree_t *fs, fstree_stats_t *out); + #endif /* FSTREE_H */ -- cgit v1.2.3