- struct image_info *image_info;
-
- DEBUG("Updating the image info for image %d", image);
-
- image_info = &wim->wim_info->images[image - 1];
-
- image_info->file_count = 0;
- image_info->dir_count = 0;
- image_info->total_bytes = 0;
- image_info->hard_link_bytes = 0;
- image_info->blob_table = wim->blob_table;
+ struct image_info *info;
+ struct wim_image_metadata *imd;
+ struct wim_inode *inode;
+ u64 size;
+
+ info = &wim->wim_info->images[image - 1];
+ imd = wim->image_metadata[image - 1];
+
+ info->file_count = 0;
+ info->dir_count = 0;
+ info->total_bytes = 0;
+ info->hard_link_bytes = 0;
+
+ image_for_each_inode(inode, imd) {
+ if (inode_is_directory(inode))
+ info->dir_count += inode->i_nlink;
+ else
+ info->file_count += inode->i_nlink;
+ size = inode_sum_stream_sizes(inode, wim->blob_table);
+ info->total_bytes += size * inode->i_nlink;
+ info->hard_link_bytes += size * (inode->i_nlink - 1);
+ }