- * @lookup_table: The lookup table for dentries. If non-NULL, the
- * reference counts in the lookup table for the lookup
- * table entries corresponding to the dentries will be
- * decremented.
- */
-void free_dentry_tree(struct dentry *root, struct lookup_table *lookup_table)
-{
- if (!root || !root->parent)
- return;
- for_dentry_in_tree_depth(root, do_free_dentry, lookup_table);
-}
-
-int increment_dentry_refcnt(struct dentry *dentry, void *ignore)
-{
- dentry->refcnt++;
- return 0;
-}
-
-/*
- * Links a dentry into the directory tree.
- *
- * @dentry: The dentry to link.
- * @parent: The dentry that will be the parent of @dentry.
- */
-void link_dentry(struct dentry *dentry, struct dentry *parent)
-{
- wimlib_assert(dentry_is_directory(parent));
- dentry->parent = parent;
- if (parent->inode->children) {
- /* Not an only child; link to siblings. */
- dentry->next = parent->inode->children;
- dentry->prev = parent->inode->children->prev;
- dentry->next->prev = dentry;
- dentry->prev->next = dentry;
- } else {
- /* Only child; link to parent. */
- parent->inode->children = dentry;
- dentry->next = dentry;
- dentry->prev = dentry;
- }
-}
-
-
-/*
- * Unlink a dentry from the directory tree.
- *
- * Note: This merely removes it from the in-memory tree structure.
- */
-void unlink_dentry(struct dentry *dentry)
-{
- if (dentry_is_root(dentry))
- return;
- if (dentry_is_only_child(dentry)) {
- dentry->parent->inode->children = NULL;
- } else {
- if (dentry_is_first_sibling(dentry))
- dentry->parent->inode->children = dentry->next;
- dentry->next->prev = dentry->prev;
- dentry->prev->next = dentry->next;
- }
-}
-
-
-/* Parameters for calculate_dentry_statistics(). */
-struct image_statistics {
- struct lookup_table *lookup_table;
- u64 *dir_count;
- u64 *file_count;
- u64 *total_bytes;
- u64 *hard_link_bytes;
-};
-
-static int calculate_dentry_statistics(struct dentry *dentry, void *arg)
-{
- struct image_statistics *stats;
- struct lookup_table_entry *lte;
-
- stats = arg;
-
- if (dentry_is_directory(dentry) && !dentry_is_root(dentry))
- ++*stats->dir_count;
- else
- ++*stats->file_count;
-
- for (unsigned i = 0; i <= dentry->inode->num_ads; i++) {
- lte = inode_stream_lte(dentry->inode, i, stats->lookup_table);
- if (lte) {
- *stats->total_bytes += wim_resource_size(lte);
- if (++lte->out_refcnt == 1)
- *stats->hard_link_bytes += wim_resource_size(lte);
- }
- }
- return 0;
-}
-
-/* Calculates some statistics about a dentry tree. */
-void calculate_dir_tree_statistics(struct dentry *root, struct lookup_table *table,
- u64 *dir_count_ret, u64 *file_count_ret,
- u64 *total_bytes_ret,
- u64 *hard_link_bytes_ret)